X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fmtd.c;h=b9f431643f6d182eb65f59c0287ee127360fea32;hb=196ccc44e70333cc87f9d417967bd06288602dac;hp=9381089aa57eb3b8a2997e6b0f29b4c53b695d57;hpb=8a68c41c2e7e0a1d5128e7e30ab673a6699c2f45;p=fio.git diff --git a/engines/mtd.c b/engines/mtd.c index 9381089a..b9f43164 100644 --- a/engines/mtd.c +++ b/engines/mtd.c @@ -4,24 +4,44 @@ * IO engine that reads/writes from MTD character devices. * */ -#include #include #include -#include #include #include #include #include "../fio.h" -#include "../verify.h" -#include "../lib/libmtd.h" +#include "../optgroup.h" +#include "../oslib/libmtd.h" -libmtd_t desc; +static libmtd_t desc; struct fio_mtd_data { struct mtd_dev_info info; }; +struct fio_mtd_options { + void *pad; /* avoid off1 == 0 */ + unsigned int skip_bad; +}; + +static struct fio_option options[] = { + { + .name = "skip_bad", + .lname = "Skip operations against bad blocks", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct fio_mtd_options, skip_bad), + .help = "Skip operations against known bad blocks.", + .hide = 1, + .def = "0", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_MTD, + }, + { + .name = NULL, + }, +}; + static int fio_mtd_maybe_mark_bad(struct thread_data *td, struct fio_mtd_data *fmd, struct io_u *io_u, int eb) @@ -51,10 +71,12 @@ static int fio_mtd_is_bad(struct thread_data *td, return ret; } -static int fio_mtd_queue(struct thread_data *td, struct io_u *io_u) +static enum fio_q_status fio_mtd_queue(struct thread_data *td, + struct io_u *io_u) { struct fio_file *f = io_u->file; struct fio_mtd_data *fmd = FILE_ENG_DATA(f); + struct fio_mtd_options *o = td->eo; int local_offs = 0; int ret; @@ -77,7 +99,7 @@ static int fio_mtd_queue(struct thread_data *td, struct io_u *io_u) (int)fmd->info.eb_size - eb_offs); char *buf = ((char *)io_u->buf) + local_offs; - if (td->o.skip_bad) { + if (o->skip_bad) { ret = fio_mtd_is_bad(td, fmd, io_u, eb); if (ret == -1) break; @@ -168,7 +190,7 @@ static int fio_mtd_close_file(struct thread_data *td, struct fio_file *f) return generic_close_file(td, f); } -int fio_mtd_get_file_size(struct thread_data *td, struct fio_file *f) +static int fio_mtd_get_file_size(struct thread_data *td, struct fio_file *f) { struct mtd_dev_info info; @@ -190,6 +212,8 @@ static struct ioengine_ops ioengine = { .close_file = fio_mtd_close_file, .get_file_size = fio_mtd_get_file_size, .flags = FIO_SYNCIO | FIO_NOEXTEND, + .options = options, + .option_struct_size = sizeof(struct fio_mtd_options), }; static void fio_init fio_mtd_register(void)