X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fe4defrag.c;h=4d87f676a128f1ab6cda8c826a9479098190d5b9;hb=4ff1f2d08b89a84223bff6310db7a18946c42ecd;hp=5affaa0848f48139961daa5b5e76abfe31ab2fc5;hpb=9c25d2e3f498707c4fd5a4bb0adf9867ecb17768;p=fio.git diff --git a/engines/e4defrag.c b/engines/e4defrag.c index 5affaa08..4d87f676 100644 --- a/engines/e4defrag.c +++ b/engines/e4defrag.c @@ -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, @@ -88,7 +92,7 @@ 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); + log_err("Can't open donor file %s err:%d", donor_name, ed->donor_fd); free(ed); return 1; } @@ -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; }