fio: fix aio trim completion latencies
[fio.git] / engines / dev-dax.c
index 45aca4e82382393f12977ce9fe95abd0fd51ca06..422ea634ff1d2530b6dae4ba40747417281ee27c 100644 (file)
@@ -106,7 +106,7 @@ static int fio_devdax_prep_limited(struct thread_data *td, struct io_u *io_u)
        struct fio_devdax_data *fdd = FILE_ENG_DATA(f);
 
        if (io_u->buflen > f->real_file_size) {
-               log_err("fio: bs too big for dev-dax engine\n");
+               log_err("dev-dax: bs too big for dev-dax engine\n");
                return EIO;
        }
 
@@ -157,7 +157,7 @@ static int fio_devdax_prep(struct thread_data *td, struct io_u *io_u)
         * It fits within existing mapping, use it
         */
        if (io_u->offset >= fdd->devdax_off &&
-           io_u->offset + io_u->buflen < fdd->devdax_off + fdd->devdax_sz)
+           io_u->offset + io_u->buflen <= fdd->devdax_off + fdd->devdax_sz)
                goto done;
 
        /*
@@ -182,7 +182,8 @@ done:
        return 0;
 }
 
-static int fio_devdax_queue(struct thread_data *td, struct io_u *io_u)
+static enum fio_q_status fio_devdax_queue(struct thread_data *td,
+                                         struct io_u *io_u)
 {
        fio_ro_check(td, io_u);
        io_u->error = 0;
@@ -213,8 +214,8 @@ static int fio_devdax_init(struct thread_data *td)
 
        if ((o->rw_min_bs & page_mask) &&
            (o->fsync_blocks || o->fdatasync_blocks)) {
-               log_err("fio: mmap options dictate a minimum block size of "
-                       "%llu bytes\n", (unsigned long long) page_size);
+               log_err("dev-dax: mmap options dictate a minimum block size of %llu bytes\n",
+                       (unsigned long long) page_size);
                return 1;
        }
 
@@ -258,7 +259,7 @@ fio_devdax_get_file_size(struct thread_data *td, struct fio_file *f)
 {
        char spath[PATH_MAX];
        char npath[PATH_MAX];
-       char *rpath;
+       char *rpath, *basename;
        FILE *sfile;
        uint64_t size;
        struct stat st;
@@ -272,8 +273,8 @@ fio_devdax_get_file_size(struct thread_data *td, struct fio_file *f)
 
        rc = stat(f->file_name, &st);
        if (rc < 0) {
-               log_err("%s: failed to stat file %s: %d\n",
-                       td->o.name, f->file_name, errno);
+               log_err("%s: failed to stat file %s (%s)\n",
+                       td->o.name, f->file_name, strerror(errno));
                return -errno;
        }
 
@@ -282,13 +283,14 @@ fio_devdax_get_file_size(struct thread_data *td, struct fio_file *f)
 
        rpath = realpath(spath, npath);
        if (!rpath) {
-               log_err("%s: realpath on %s failed: %d\n",
-                       td->o.name, spath, errno);
+               log_err("%s: realpath on %s failed (%s)\n",
+                       td->o.name, spath, strerror(errno));
                return -errno;
        }
 
        /* check if DAX device */
-       if (strcmp("/sys/class/dax", rpath)) {
+       basename = strrchr(rpath, '/');
+       if (!basename || strcmp("dax", basename+1)) {
                log_err("%s: %s not a DAX device!\n",
                        td->o.name, f->file_name);
        }
@@ -298,15 +300,16 @@ fio_devdax_get_file_size(struct thread_data *td, struct fio_file *f)
 
        sfile = fopen(spath, "r");
        if (!sfile) {
-               log_err("%s: fopen on %s failed: %d\n",
-                       td->o.name, spath, errno);
+               log_err("%s: fopen on %s failed (%s)\n",
+                       td->o.name, spath, strerror(errno));
                return 1;
        }
 
        rc = fscanf(sfile, "%lu", &size);
        if (rc < 0) {
-               log_err("%s: fscanf on %s failed: %d\n",
-                       td->o.name, spath, errno);
+               log_err("%s: fscanf on %s failed (%s)\n",
+                       td->o.name, spath, strerror(errno));
+               fclose(sfile);
                return 1;
        }