X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fe4defrag.c;h=8f71d02caa947867339d980e0f2722c9a5751b8d;hp=1e4996f155ef5d258ae98a2a6748701c84e5413c;hb=HEAD;hpb=c58390119ccf711ab66e53aff6aa31507c509900 diff --git a/engines/e4defrag.c b/engines/e4defrag.c index 1e4996f1..37cc2ada 100644 --- a/engines/e4defrag.c +++ b/engines/e4defrag.c @@ -9,11 +9,7 @@ #include #include #include -#include -#include -#include #include -#include #include #include "../fio.h" @@ -76,17 +72,16 @@ static int fio_e4defrag_init(struct thread_data *td) struct stat stub; char donor_name[PATH_MAX]; - if (!strlen(o->donor_name)) { + if (!o->donor_name || !strlen(o->donor_name)) { log_err("'donorname' options required\n"); return 1; } - ed = malloc(sizeof(*ed)); + ed = calloc(1, sizeof(*ed)); if (!ed) { td_verror(td, ENOMEM, "io_queue_init"); return 1; } - memset(ed, 0 ,sizeof(*ed)); if (td->o.directory) len = sprintf(donor_name, "%s/", td->o.directory); @@ -131,7 +126,8 @@ static void fio_e4defrag_cleanup(struct thread_data *td) } -static int fio_e4defrag_queue(struct thread_data *td, struct io_u *io_u) +static enum fio_q_status fio_e4defrag_queue(struct thread_data *td, + struct io_u *io_u) { int ret; @@ -172,8 +168,13 @@ static int fio_e4defrag_queue(struct thread_data *td, struct io_u *io_u) len = io_u->xfer_buflen; if (len != io_u->xfer_buflen) { - io_u->resid = io_u->xfer_buflen - len; - io_u->error = 0; + if (len) { + io_u->resid = io_u->xfer_buflen - len; + io_u->error = 0; + } else { + /* access beyond i_size */ + io_u->error = EINVAL; + } } if (ret) io_u->error = errno;