options: make the groups/categories constant
[fio.git] / engines / e4defrag.c
index 5affaa0848f48139961daa5b5e76abfe31ab2fc5..d6113a97ee9b6565dbdf8e5dc0381491bf6b61a4 100644 (file)
@@ -36,7 +36,7 @@ struct e4defrag_data {
 };
 
 struct e4defrag_options {
-       struct thread_data *td;
+       void *pad;
        unsigned int inplace;
        char * donor_name;
 };
@@ -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,
@@ -76,7 +80,7 @@ static int fio_e4defrag_init(struct thread_data *td)
 
        ed = malloc(sizeof(*ed));
        if (!ed) {
-               td_verror(td, -ENOMEM, "io_queue_init");
+               td_verror(td, ENOMEM, "io_queue_init");
                return 1;
        }
        memset(ed, 0 ,sizeof(*ed));
@@ -87,15 +91,15 @@ static int fio_e4defrag_init(struct thread_data *td)
 
        ed->donor_fd = open(donor_name, O_CREAT|O_WRONLY, 0644);
        if (ed->donor_fd < 0) {
-               td_verror(td, ed->donor_fd, "io_queue_init");
-               log_err("Can't open donor file %s err:%d", ed->donor_fd);
+               td_verror(td, errno, "io_queue_init");
+               log_err("Can't open donor file %s err:%d", donor_name, ed->donor_fd);
                free(ed);
                return 1;
        }
 
        if (!o->inplace) {
-               long long len = td->o.file_size_high - td->o.start_offset;
-               r = fallocate(ed->donor_fd, 0, td->o.start_offset, len);
+               long long __len = td->o.file_size_high - td->o.start_offset;
+               r = fallocate(ed->donor_fd, 0, td->o.start_offset, __len);
                if (r)
                        goto err;
        }
@@ -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;
 }