pmemblk: Clarify fsize is in MiB not MB
[fio.git] / engines / pmemblk.c
index cf13a7e6c7e5bbc9b4a1b7196bab5e09d7cd66fd..e8476f99ab0782557387a79226dbb3edee4c36a8 100644 (file)
@@ -18,7 +18,6 @@
  * Boston, MA 02111-1307 USA
  */
 
  * Boston, MA 02111-1307 USA
  */
 
-
 /*
  * pmemblk engine
  *
 /*
  * pmemblk engine
  *
  *   ioengine=pmemblk
  *
  * Other relevant settings:
  *   ioengine=pmemblk
  *
  * Other relevant settings:
+ *   thread=1   REQUIRED
  *   iodepth=1
  *   direct=1
  *   iodepth=1
  *   direct=1
- *   thread=1   REQUIRED
  *   unlink=1
  *   unlink=1
- *   filename=/pmem0/fiotestfile,BSIZE,FSIZEMB
+ *   filename=/mnt/pmem0/fiotestfile,BSIZE,FSIZEMiB
  *
  *   thread must be set to 1 for pmemblk as multiple processes cannot
  *     open the same block pool file.
  *
  *   thread must be set to 1 for pmemblk as multiple processes cannot
  *     open the same block pool file.
  *   iodepth should be set to 1 as pmemblk is always synchronous.
  *   Use numjobs to scale up.
  *
  *   iodepth should be set to 1 as pmemblk is always synchronous.
  *   Use numjobs to scale up.
  *
- *   direct=1 is implied as pmemblk is always direct.
+ *   direct=1 is implied as pmemblk is always direct. A warning message
+ *   is printed if this is not specified.
+ *
+ *   unlink=1 removes the block pool file after testing, and is optional.
+ *
+ *   The pmem device must have a DAX-capable filesystem and be mounted
+ *   with DAX enabled.  filename must point to a file on that filesystem.
  *
  *
- *   Can set unlink to 1 to remove the block pool file after testing.
+ *   Example:
+ *     mkfs.xfs /dev/pmem0
+ *     mkdir /mnt/pmem0
+ *     mount -o dax /dev/pmem0 /mnt/pmem0
  *
  *   When specifying the filename, if the block pool file does not already
  *
  *   When specifying the filename, if the block pool file does not already
- *   exist, then the pmemblk engine can create the pool file if you specify
+ *   exist, then the pmemblk engine creates the pool file if you specify
  *   the block and file sizes.  BSIZE is the block size in bytes.
  *   the block and file sizes.  BSIZE is the block size in bytes.
- *   FSIZEMB is the pool file size in MB.
+ *   FSIZEMB is the pool file size in MiB.
  *
  *   See examples/pmemblk.fio for more.
  *
  *
  *   See examples/pmemblk.fio for more.
  *
- * libpmemblk.so
- *   By default, the pmemblk engine will let the system find the libpmemblk.so
- *   that it uses.  You can use an alternative libpmemblk by setting the
- *   FIO_PMEMBLK_LIB environment variable to the full path to the desired
- *   libpmemblk.so.
- *
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
 #include <sys/uio.h>
 #include <errno.h>
 #include <assert.h>
 #include <sys/uio.h>
 #include <errno.h>
 #include <assert.h>
-#include <dlfcn.h>
 #include <string.h>
 #include <string.h>
+#include <libpmem.h>
+#include <libpmemblk.h>
 
 #include "../fio.h"
 
 
 #include "../fio.h"
 
-
-
 /*
  * libpmemblk
  */
 /*
  * libpmemblk
  */
-struct PMEMblkpool_s;
-typedef struct PMEMblkpool_s PMEMblkpool;
-
-PMEMblkpool* (*pmemblk_create)(const char*, size_t, size_t, mode_t) = NULL;
-PMEMblkpool* (*pmemblk_open)(const char*, size_t) = NULL;
-void (*pmemblk_close)(PMEMblkpool*) = NULL;
-size_t (*pmemblk_nblock)(PMEMblkpool*) = NULL;
-size_t (*pmemblk_bsize)(PMEMblkpool*) = NULL;
-int (*pmemblk_read)(PMEMblkpool*, void*, off_t) = NULL;
-int (*pmemblk_write)(PMEMblkpool*, const void*, off_t) = NULL;
-
-int
-load_libpmemblk(
-       const char* path
-)
-{
-       void*   dl;
-
-       if (NULL == path)
-               path = "libpmemblk.so";
-
-       dl = dlopen(path, RTLD_NOW | RTLD_NODELETE);
-       if (NULL == dl)
-               goto errorout;
-
-       if (NULL == (pmemblk_create = dlsym(dl, "pmemblk_create")))
-               goto errorout;
-       if (NULL == (pmemblk_open = dlsym(dl, "pmemblk_open")))
-               goto errorout;
-       if (NULL == (pmemblk_close = dlsym(dl, "pmemblk_close")))
-               goto errorout;
-       if (NULL == (pmemblk_nblock = dlsym(dl, "pmemblk_nblock")))
-               goto errorout;
-       if (NULL == (pmemblk_bsize = dlsym(dl, "pmemblk_bsize")))
-               goto errorout;
-       if (NULL == (pmemblk_read = dlsym(dl, "pmemblk_read")))
-               goto errorout;
-       if (NULL == (pmemblk_write = dlsym(dl, "pmemblk_write")))
-               goto errorout;
-       
-       return 0;
-
-errorout:
-       log_err("fio: unable to load libpmemblk: %s\n", dlerror());
-       if (NULL != dl)
-               dlclose(dl);
-
-       return (-1);
-       
-}  /* load_libpmemblk() */
-
+typedef struct fio_pmemblk_file *fio_pmemblk_file_t;
 
 
-typedef struct fio_pmemblk_file*   fio_pmemblk_file_t;
 struct fio_pmemblk_file {
 struct fio_pmemblk_file {
-       fio_pmemblk_file_t   pmb_next;
-       char*                pmb_filename;
-       uint64_t             pmb_refcnt;
-       PMEMblkpool*         pmb_pool;
-       size_t               pmb_bsize;
-       size_t               pmb_nblocks;
+       fio_pmemblk_file_t pmb_next;
+       char *pmb_filename;
+       uint64_t pmb_refcnt;
+       PMEMblkpool *pmb_pool;
+       size_t pmb_bsize;
+       size_t pmb_nblocks;
 };
 #define FIOFILEPMBSET(_f, _v)  do {                 \
        (_f)->engine_data = (uint64_t)(uintptr_t)(_v);  \
 } while(0)
 #define FIOFILEPMBGET(_f)  ((fio_pmemblk_file_t)((_f)->engine_data))
 
 };
 #define FIOFILEPMBSET(_f, _v)  do {                 \
        (_f)->engine_data = (uint64_t)(uintptr_t)(_v);  \
 } while(0)
 #define FIOFILEPMBGET(_f)  ((fio_pmemblk_file_t)((_f)->engine_data))
 
-static fio_pmemblk_file_t   Cache = NULL;
+static fio_pmemblk_file_t Cache;
 
 
-static pthread_mutex_t      CacheLock = PTHREAD_MUTEX_INITIALIZER;
-#define CACHE_LOCK()  \
-       (void)pthread_mutex_lock(&CacheLock)
-#define CACHE_UNLOCK()  \
-       (void)pthread_mutex_unlock(&CacheLock)
+static pthread_mutex_t CacheLock = PTHREAD_MUTEX_INITIALIZER;
 
 
-#define PMB_CREATE   (0x0001)  /* should create file */
+#define PMB_CREATE   (0x0001)  /* should create file */
 
 
-
-fio_pmemblk_file_t
-fio_pmemblk_cache_lookup(
-       const char* filename
-)
+fio_pmemblk_file_t fio_pmemblk_cache_lookup(const char *filename)
 {
 {
-       fio_pmemblk_file_t   i;
+       fio_pmemblk_file_t i;
 
        for (i = Cache; i != NULL; i = i->pmb_next)
 
        for (i = Cache; i != NULL; i = i->pmb_next)
-               if (0 == strcmp(filename, i->pmb_filename))
+               if (!strcmp(filename, i->pmb_filename))
                        return i;
 
        return NULL;
                        return i;
 
        return NULL;
+}
 
 
-}  /* fio_pmemblk_cache_lookup() */
-
-
-static void
-fio_pmemblk_cache_insert(
-       fio_pmemblk_file_t pmb
-)
+static void fio_pmemblk_cache_insert(fio_pmemblk_file_t pmb)
 {
        pmb->pmb_next = Cache;
        Cache = pmb;
 {
        pmb->pmb_next = Cache;
        Cache = pmb;
+}
 
 
-       return;
-
-}  /* fio_pmemblk_cache_insert() */
-
-
-static void
-fio_pmemblk_cache_remove(
-       fio_pmemblk_file_t pmb
-)
+static void fio_pmemblk_cache_remove(fio_pmemblk_file_t pmb)
 {
 {
-       fio_pmemblk_file_t   i;
+       fio_pmemblk_file_t i;
 
        if (pmb == Cache) {
                Cache = Cache->pmb_next;
 
        if (pmb == Cache) {
                Cache = Cache->pmb_next;
@@ -200,18 +130,14 @@ fio_pmemblk_cache_remove(
                        pmb->pmb_next = NULL;
                        return;
                }
                        pmb->pmb_next = NULL;
                        return;
                }
-
-       return;
-
-}  /* fio_pmemblk_cache_remove() */
-
+}
 
 /*
  * to control block size and gross file size at the libpmemblk
  * level, we allow the block size and file size to be appended
  * to the file name:
  *
 
 /*
  * to control block size and gross file size at the libpmemblk
  * level, we allow the block size and file size to be appended
  * to the file name:
  *
- *   path[,bsize,fsizemb]
+ *   path[,bsize,fsizemib]
  *
  * note that we do not use the fio option "filesize" to dictate
  * the file size because we can only give libpmemblk the gross
  *
  * note that we do not use the fio option "filesize" to dictate
  * the file size because we can only give libpmemblk the gross
@@ -221,139 +147,113 @@ fio_pmemblk_cache_remove(
  * the final path without the parameters is returned in ppath.
  * the block size and file size are returned in pbsize and fsize.
  *
  * the final path without the parameters is returned in ppath.
  * the block size and file size are returned in pbsize and fsize.
  *
- * note that the user should specify the file size in MiB, but
+ * note that the user specifies the file size in MiB, but
  * we return bytes from here.
  */
  * we return bytes from here.
  */
-static void
-pmb_parse_path(
-       const char* pathspec,
-       char**      ppath,
-       uint64_t*   pbsize,
-       uint64_t*   pfsize
-)
+static void pmb_parse_path(const char *pathspec, char **ppath, uint64_t *pbsize,
+                          uint64_t *pfsize)
 {
 {
-       char*      path;
-       char*      s;
-       uint64_t   bsize;
-       uint64_t   fsizemb;
+       char *path;
+       char *s;
+       uint64_t bsize;
+       uint64_t fsizemib;
 
        path = strdup(pathspec);
 
        path = strdup(pathspec);
-       if (NULL == path) {
+       if (!path) {
                *ppath = NULL;
                return;
        }
 
        /* extract sizes, if given */
        s = strrchr(path, ',');
                *ppath = NULL;
                return;
        }
 
        /* extract sizes, if given */
        s = strrchr(path, ',');
-       if (s && (fsizemb = strtoull(s+1, NULL, 10))) {
+       if (s && (fsizemib = strtoull(s + 1, NULL, 10))) {
                *s = 0;
                s = strrchr(path, ',');
                *s = 0;
                s = strrchr(path, ',');
-               if (s && (bsize = strtoull(s+1, NULL, 10))) {
+               if (s && (bsize = strtoull(s + 1, NULL, 10))) {
                        *s = 0;
                        *s = 0;
-                       *ppath  = path;
+                       *ppath = path;
                        *pbsize = bsize;
                        *pbsize = bsize;
-                       *pfsize = fsizemb << 20;
+                       *pfsize = fsizemib << 20;
                        return;
                }
        }
 
        /* size specs not found */
        strcpy(path, pathspec);
                        return;
                }
        }
 
        /* size specs not found */
        strcpy(path, pathspec);
-       *ppath  = path;
+       *ppath = path;
        *pbsize = 0;
        *pfsize = 0;
        *pbsize = 0;
        *pfsize = 0;
-       return;
-
-}  /* pmb_parse_path() */
-
+}
 
 
-static
-fio_pmemblk_file_t
-pmb_open(
-       const char* pathspec,
-       int         flags
-)
+static fio_pmemblk_file_t pmb_open(const char *pathspec, int flags)
 {
 {
-       fio_pmemblk_file_t   pmb;
-       char*                path  = NULL;
-       uint64_t             bsize = 0;
-       uint64_t             fsize = 0;
+       fio_pmemblk_file_t pmb;
+       char *path = NULL;
+       uint64_t bsize = 0;
+       uint64_t fsize = 0;
 
        pmb_parse_path(pathspec, &path, &bsize, &fsize);
 
        pmb_parse_path(pathspec, &path, &bsize, &fsize);
-       if (NULL == path)
+       if (!path)
                return NULL;
 
                return NULL;
 
-       CACHE_LOCK();
+       pthread_mutex_lock(&CacheLock);
 
        pmb = fio_pmemblk_cache_lookup(path);
 
        pmb = fio_pmemblk_cache_lookup(path);
-
-       if (NULL == pmb) {
-               /* load libpmemblk if needed */
-               if (NULL == pmemblk_open)
-                       if (0 != load_libpmemblk(getenv("FIO_PMEMBLK_LIB")))
-                               goto error;
-
+       if (!pmb) {
                pmb = malloc(sizeof(*pmb));
                pmb = malloc(sizeof(*pmb));
-               if (NULL == pmb)
+               if (!pmb)
                        goto error;
 
                /* try opening existing first, create it if needed */
                pmb->pmb_pool = pmemblk_open(path, bsize);
                        goto error;
 
                /* try opening existing first, create it if needed */
                pmb->pmb_pool = pmemblk_open(path, bsize);
-               if ((NULL == pmb->pmb_pool) &&
-                   (ENOENT == errno) &&
-                   (flags & PMB_CREATE) &&
-                   (0 < fsize) &&
-                   (0 < bsize)) {
-                       pmb->pmb_pool = pmemblk_create(path, bsize, fsize, 0644);
+               if (!pmb->pmb_pool && (errno == ENOENT) &&
+                   (flags & PMB_CREATE) && (0 < fsize) && (0 < bsize)) {
+                       pmb->pmb_pool =
+                           pmemblk_create(path, bsize, fsize, 0644);
                }
                }
-               if (NULL == pmb->pmb_pool) {
-                       log_err("fio: enable to open pmemblk pool file (errno %d)\n",
-                               errno);
+               if (!pmb->pmb_pool) {
+                       log_err("pmemblk: unable to open pmemblk pool file %s (%s)\n",
+                            path, strerror(errno));
                        goto error;
                }
 
                pmb->pmb_filename = path;
                        goto error;
                }
 
                pmb->pmb_filename = path;
-               pmb->pmb_next     = NULL;
-               pmb->pmb_refcnt   = 0;
-               pmb->pmb_bsize    = pmemblk_bsize(pmb->pmb_pool);
-               pmb->pmb_nblocks  = pmemblk_nblock(pmb->pmb_pool);
+               pmb->pmb_next = NULL;
+               pmb->pmb_refcnt = 0;
+               pmb->pmb_bsize = pmemblk_bsize(pmb->pmb_pool);
+               pmb->pmb_nblocks = pmemblk_nblock(pmb->pmb_pool);
 
                fio_pmemblk_cache_insert(pmb);
        }
 
        pmb->pmb_refcnt += 1;
 
 
                fio_pmemblk_cache_insert(pmb);
        }
 
        pmb->pmb_refcnt += 1;
 
-       CACHE_UNLOCK();
-       
+       pthread_mutex_unlock(&CacheLock);
+
        return pmb;
 
 error:
        return pmb;
 
 error:
-       if (NULL != pmb) {
-               if (NULL != pmb->pmb_pool)
+       if (pmb) {
+               if (pmb->pmb_pool)
                        pmemblk_close(pmb->pmb_pool);
                        pmemblk_close(pmb->pmb_pool);
-               pmb->pmb_pool     = NULL;
+               pmb->pmb_pool = NULL;
                pmb->pmb_filename = NULL;
                free(pmb);
        }
                pmb->pmb_filename = NULL;
                free(pmb);
        }
-       if (NULL != path)
+       if (path)
                free(path);
                free(path);
-       CACHE_UNLOCK();
-       return NULL;
-
-}  /* pmb_open() */
 
 
+       pthread_mutex_unlock(&CacheLock);
+       return NULL;
+}
 
 
-static void
-pmb_close(
-       fio_pmemblk_file_t pmb,
-       const int          keep
-)
+static void pmb_close(fio_pmemblk_file_t pmb, const bool keep)
 {
 {
-       CACHE_LOCK();
+       pthread_mutex_lock(&CacheLock);
 
        pmb->pmb_refcnt--;
 
 
        pmb->pmb_refcnt--;
 
-       if (!keep && (0 == pmb->pmb_refcnt)) {
+       if (!keep && !pmb->pmb_refcnt) {
                pmemblk_close(pmb->pmb_pool);
                pmb->pmb_pool = NULL;
                free(pmb->pmb_filename);
                pmemblk_close(pmb->pmb_pool);
                pmb->pmb_pool = NULL;
                free(pmb->pmb_filename);
@@ -362,33 +262,27 @@ pmb_close(
                free(pmb);
        }
 
                free(pmb);
        }
 
-       CACHE_UNLOCK();
-
-}  /* pmb_close() */
-
+       pthread_mutex_unlock(&CacheLock);
+}
 
 
-static int
-pmb_get_flags(
-       struct thread_data* td,
-       uint64_t*           pflags
-)
+static int pmb_get_flags(struct thread_data *td, uint64_t *pflags)
 {
 {
-       static int thread_warned  = 0;
+       static int thread_warned = 0;
        static int odirect_warned = 0;
 
        static int odirect_warned = 0;
 
-       uint64_t   flags          = 0;
+       uint64_t flags = 0;
 
        if (!td->o.use_thread) {
                if (!thread_warned) {
                        thread_warned = 1;
 
        if (!td->o.use_thread) {
                if (!thread_warned) {
                        thread_warned = 1;
-                       log_err("fio: must set thread=1 for pmemblk engine\n");
+                       log_err("pmemblk: must set thread=1 for pmemblk engine\n");
                }
                return 1;
        }
 
        if (!td->o.odirect && !odirect_warned) {
                odirect_warned = 1;
                }
                return 1;
        }
 
        if (!td->o.odirect && !odirect_warned) {
                odirect_warned = 1;
-               log_info("fio: direct == 0, but pmemblk is always direct\n");
+               log_info("pmemblk: direct == 0, but pmemblk is always direct\n");
        }
 
        if (td->o.allow_create)
        }
 
        if (td->o.allow_create)
@@ -396,67 +290,49 @@ pmb_get_flags(
 
        (*pflags) = flags;
        return 0;
 
        (*pflags) = flags;
        return 0;
+}
 
 
-}  /* pmb_get_flags() */
-
-
-static int
-fio_pmemblk_open_file(
-       struct thread_data* td,
-       struct fio_file*    f)
+static int fio_pmemblk_open_file(struct thread_data *td, struct fio_file *f)
 {
 {
-       uint64_t             flags = 0;
-       fio_pmemblk_file_t   pmb;
+       uint64_t flags = 0;
+       fio_pmemblk_file_t pmb;
 
 
-       if (0 != pmb_get_flags(td, &flags))
+       if (pmb_get_flags(td, &flags))
                return 1;
 
        pmb = pmb_open(f->file_name, flags);
                return 1;
 
        pmb = pmb_open(f->file_name, flags);
-       if (NULL == pmb)
+       if (!pmb)
                return 1;
 
        FIOFILEPMBSET(f, pmb);
                return 1;
 
        FIOFILEPMBSET(f, pmb);
-
        return 0;
        return 0;
+}
 
 
-}  /* fio_pmemblk_open_file() */
-
-
-static int
-fio_pmemblk_close_file(
-       struct thread_data fio_unused* td,
-       struct fio_file*               f
-)
+static int fio_pmemblk_close_file(struct thread_data fio_unused *td,
+                                 struct fio_file *f)
 {
 {
-       fio_pmemblk_file_t   pmb = FIOFILEPMBGET(f);
+       fio_pmemblk_file_t pmb = FIOFILEPMBGET(f);
 
        if (pmb)
 
        if (pmb)
-               pmb_close(pmb, 0);
+               pmb_close(pmb, false);
 
        FIOFILEPMBSET(f, NULL);
 
        FIOFILEPMBSET(f, NULL);
-
        return 0;
        return 0;
+}
 
 
-}  /* fio_pmemblk_close_file() */
-
-
-static int
-fio_pmemblk_get_file_size(
-       struct thread_data* td,
-       struct fio_file*    f
-)
+static int fio_pmemblk_get_file_size(struct thread_data *td, struct fio_file *f)
 {
 {
-       uint64_t             flags = 0;
-       fio_pmemblk_file_t   pmb   = FIOFILEPMBGET(f);
+       uint64_t flags = 0;
+       fio_pmemblk_file_t pmb = FIOFILEPMBGET(f);
 
        if (fio_file_size_known(f))
                return 0;
 
 
        if (fio_file_size_known(f))
                return 0;
 
-       if (NULL == pmb) {
-               if (0 != pmb_get_flags(td, &flags))
+       if (!pmb) {
+               if (pmb_get_flags(td, &flags))
                        return 1;
                pmb = pmb_open(f->file_name, flags);
                        return 1;
                pmb = pmb_open(f->file_name, flags);
-               if (NULL == pmb)
+               if (!pmb)
                        return 1;
        }
 
                        return 1;
        }
 
@@ -464,41 +340,33 @@ fio_pmemblk_get_file_size(
 
        fio_file_set_size_known(f);
 
 
        fio_file_set_size_known(f);
 
-       if (NULL == FIOFILEPMBGET(f))
-               pmb_close(pmb, 1);
+       if (!FIOFILEPMBGET(f))
+               pmb_close(pmb, true);
 
        return 0;
 
        return 0;
+}
 
 
-}  /* fio_pmemblk_get_file_size() */
-
-
-static int
-fio_pmemblk_queue(
-       struct thread_data* td,
-       struct io_u*        io_u)
+static int fio_pmemblk_queue(struct thread_data *td, struct io_u *io_u)
 {
 {
-       struct fio_file*     f   = io_u->file;
-       fio_pmemblk_file_t   pmb = FIOFILEPMBGET(f);
+       struct fio_file *f = io_u->file;
+       fio_pmemblk_file_t pmb = FIOFILEPMBGET(f);
 
 
-       unsigned long long   off;
-       unsigned long        len;
-       void*                buf;
-       int (*blkop)(PMEMblkpool*, void*, off_t) = (void*)pmemblk_write;
+       unsigned long long off;
+       unsigned long len;
+       void *buf;
 
        fio_ro_check(td, io_u);
 
        switch (io_u->ddir) {
        case DDIR_READ:
 
        fio_ro_check(td, io_u);
 
        switch (io_u->ddir) {
        case DDIR_READ:
-               blkop = pmemblk_read;
-               /* fall through */
        case DDIR_WRITE:
                off = io_u->offset;
                len = io_u->xfer_buflen;
 
                io_u->error = EINVAL;
        case DDIR_WRITE:
                off = io_u->offset;
                len = io_u->xfer_buflen;
 
                io_u->error = EINVAL;
-               if (0 != (off % pmb->pmb_bsize))
+               if (off % pmb->pmb_bsize)
                        break;
                        break;
-               if (0 != (len % pmb->pmb_bsize))
+               if (len % pmb->pmb_bsize)
                        break;
                if ((off + len) / pmb->pmb_bsize > pmb->pmb_nblocks)
                        break;
                        break;
                if ((off + len) / pmb->pmb_bsize > pmb->pmb_nblocks)
                        break;
@@ -508,7 +376,11 @@ fio_pmemblk_queue(
                off /= pmb->pmb_bsize;
                len /= pmb->pmb_bsize;
                while (0 < len) {
                off /= pmb->pmb_bsize;
                len /= pmb->pmb_bsize;
                while (0 < len) {
-                       if (0 != blkop(pmb->pmb_pool, buf, off)) {
+                       if (io_u->ddir == DDIR_READ &&
+                          0 != pmemblk_read(pmb->pmb_pool, buf, off)) {
+                               io_u->error = errno;
+                               break;
+                       } else if (0 != pmemblk_write(pmb->pmb_pool, buf, off)) {
                                io_u->error = errno;
                                break;
                        }
                                io_u->error = errno;
                                break;
                        }
@@ -532,19 +404,13 @@ fio_pmemblk_queue(
        }
 
        return FIO_Q_COMPLETED;
        }
 
        return FIO_Q_COMPLETED;
+}
 
 
-}  /* fio_pmemblk_queue() */
-
-
-static int
-fio_pmemblk_unlink_file(
-       struct thread_data* td,
-       struct fio_file*    f
-)
+static int fio_pmemblk_unlink_file(struct thread_data *td, struct fio_file *f)
 {
 {
-       char*      path  = NULL;
-       uint64_t   bsize = 0;
-       uint64_t   fsize = 0;
+       char *path = NULL;
+       uint64_t bsize = 0;
+       uint64_t fsize = 0;
 
        /*
         * we need our own unlink in case the user has specified
 
        /*
         * we need our own unlink in case the user has specified
@@ -553,39 +419,31 @@ fio_pmemblk_unlink_file(
         */
 
        pmb_parse_path(f->file_name, &path, &bsize, &fsize);
         */
 
        pmb_parse_path(f->file_name, &path, &bsize, &fsize);
-       if (NULL == path)
-               return 1;
+       if (!path)
+               return ENOENT;
 
        unlink(path);
        free(path);
 
        unlink(path);
        free(path);
-
        return 0;
        return 0;
+}
 
 
-}  /* fio_pmemblk_unlink_file() */
-
-
-struct ioengine_ops ioengine = {
-       .name           = "pmemblk",
-       .version        = FIO_IOOPS_VERSION,
-       .queue          = fio_pmemblk_queue,
-       .open_file      = fio_pmemblk_open_file,
-       .close_file     = fio_pmemblk_close_file,
-       .get_file_size  = fio_pmemblk_get_file_size,
-       .unlink_file    = fio_pmemblk_unlink_file,
-       .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NOEXTEND | FIO_NODISKUTIL,
+static struct ioengine_ops ioengine = {
+       .name = "pmemblk",
+       .version = FIO_IOOPS_VERSION,
+       .queue = fio_pmemblk_queue,
+       .open_file = fio_pmemblk_open_file,
+       .close_file = fio_pmemblk_close_file,
+       .get_file_size = fio_pmemblk_get_file_size,
+       .unlink_file = fio_pmemblk_unlink_file,
+       .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NOEXTEND | FIO_NODISKUTIL,
 };
 
 };
 
-
-static void
-fio_init fio_pmemblk_register(void)
+static void fio_init fio_pmemblk_register(void)
 {
        register_ioengine(&ioengine);
 }
 
 {
        register_ioengine(&ioengine);
 }
 
-
-static void
-fio_exit fio_pmemblk_unregister(void)
+static void fio_exit fio_pmemblk_unregister(void)
 {
        unregister_ioengine(&ioengine);
 }
 {
        unregister_ioengine(&ioengine);
 }
-