Categorize engine and profile options
[fio.git] / engines / e4defrag.c
index 5affaa0848f48139961daa5b5e76abfe31ab2fc5..d9ddf752bf6e39be2bdd61c4ddee12ab2ddb9f20 100644 (file)
@@ -47,6 +47,8 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_STR_STORE,
                .off1   = offsetof(struct e4defrag_options, donor_name),
                .help   = "File used as a block donor",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_E4DEFRAG,
        },
        {
                .name   = "inplace",
@@ -55,6 +57,8 @@ static struct fio_option options[] = {
                .minval = 0,
                .maxval = 1,
                .help   = "Alloc and free space inside defrag event",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_E4DEFRAG,
        },
        {
                .name   = NULL,
@@ -141,16 +145,14 @@ static int fio_e4defrag_queue(struct thread_data *td, struct io_u *io_u)
         * in order to satisfy strict read only access pattern
         */
        if (io_u->ddir != DDIR_WRITE) {
-               io_u->error = errno;
+               io_u->error = EINVAL;
                return FIO_Q_COMPLETED;
        }
 
        if (o->inplace) {
                ret = fallocate(ed->donor_fd, 0, io_u->offset, io_u->xfer_buflen);
-               if (ret) {
-                       io_u->error = errno;
+               if (ret)
                        goto out;
-               }
        }
 
        memset(&me, 0, sizeof(me));
@@ -163,9 +165,6 @@ static int fio_e4defrag_queue(struct thread_data *td, struct io_u *io_u)
        ret = ioctl(f->fd, EXT4_IOC_MOVE_EXT, &me);
        len = me.moved_len * ed->bsz;
 
-       if (io_u->file && len >= 0 && ddir_rw(io_u->ddir))
-               io_u->file->file_pos = io_u->offset + len;
-
        if (len > io_u->xfer_buflen)
                len = io_u->xfer_buflen;
 
@@ -175,16 +174,12 @@ static int fio_e4defrag_queue(struct thread_data *td, struct io_u *io_u)
        }
        if (ret)
                io_u->error = errno;
-       
-       if (o->inplace) {
+
+       if (o->inplace)
                ret = ftruncate(ed->donor_fd, 0);
-               if (ret)
-                       io_u->error = errno;
-       }
 out:
-       if (io_u->error)
-               td_verror(td, errno, "xfer");
-
+       if (ret && !io_u->error)
+               io_u->error = errno;
 
        return FIO_Q_COMPLETED;
 }