X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Flibhdfs.c;h=eb55c3c549e880eb9abfeef8ab2093095e15bc7b;hb=30bec59eab3908b681cbc2866179f7166a849c83;hp=faad3f875ac17504eb1cf634f0fc8f8043426ab1;hpb=d220c761f78bc04bf34355560a0b6b7b85fba0e8;p=fio.git diff --git a/engines/libhdfs.c b/engines/libhdfs.c index faad3f87..eb55c3c5 100644 --- a/engines/libhdfs.c +++ b/engines/libhdfs.c @@ -2,7 +2,7 @@ * libhdfs engine * * this engine helps perform read/write operations on hdfs cluster using - * libhdfs. hdfs doesnot support modification of data once file is created. + * libhdfs. hdfs does not support modification of data once file is created. * * so to mimic that create many files of small size (e.g 256k), and this * engine select a file based on the offset generated by fio. @@ -75,21 +75,24 @@ static struct fio_option options[] = { .type = FIO_OPT_STR_STORE, .off1 = offsetof(struct hdfsio_options, directory), .def = "/", - .help = "The HDFS directory where fio will create chuncks", + .help = "The HDFS directory where fio will create chunks", .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_HDFS, }, { - .name = "chunck_size", + .name = "chunk_size", + .alias = "chunck_size", + .lname = "Chunk size", .type = FIO_OPT_INT, .off1 = offsetof(struct hdfsio_options, chunck_size), .def = "1048576", - .help = "Size of individual chunck", + .help = "Size of individual chunk", .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_HDFS, }, { .name = "single_instance", + .lname = "Single Instance", .type = FIO_OPT_BOOL, .off1 = offsetof(struct hdfsio_options, single_instance), .def = "1", @@ -99,6 +102,7 @@ static struct fio_option options[] = { }, { .name = "hdfs_use_direct", + .lname = "HDFS Use Direct", .type = FIO_OPT_BOOL, .off1 = offsetof(struct hdfsio_options, use_direct), .def = "0", @@ -119,7 +123,7 @@ static int get_chunck_name(char *dest, char *file_name, uint64_t chunk_id) { static int fio_hdfsio_prep(struct thread_data *td, struct io_u *io_u) { struct hdfsio_options *options = td->eo; - struct hdfsio_data *hd = td->io_ops->data; + struct hdfsio_data *hd = td->io_ops_data; unsigned long f_id; char fname[CHUNCK_NAME_LENGTH_MAX]; int open_flags; @@ -161,9 +165,10 @@ static int fio_hdfsio_prep(struct thread_data *td, struct io_u *io_u) return 0; } -static int fio_hdfsio_queue(struct thread_data *td, struct io_u *io_u) +static enum fio_q_status fio_hdfsio_queue(struct thread_data *td, + struct io_u *io_u) { - struct hdfsio_data *hd = td->io_ops->data; + struct hdfsio_data *hd = td->io_ops_data; struct hdfsio_options *options = td->eo; int ret; unsigned long offset; @@ -172,7 +177,7 @@ static int fio_hdfsio_queue(struct thread_data *td, struct io_u *io_u) if( (io_u->ddir == DDIR_READ || io_u->ddir == DDIR_WRITE) && hdfsTell(hd->fs, hd->fp) != offset && hdfsSeek(hd->fs, hd->fp, offset) != 0 ) { - log_err("hdfs: seek failed: %s, are you doing random write smaller than chunck size ?\n", strerror(errno)); + log_err("hdfs: seek failed: %s, are you doing random write smaller than chunk size ?\n", strerror(errno)); io_u->error = errno; return FIO_Q_COMPLETED; }; @@ -223,7 +228,7 @@ int fio_hdfsio_open_file(struct thread_data *td, struct fio_file *f) int fio_hdfsio_close_file(struct thread_data *td, struct fio_file *f) { - struct hdfsio_data *hd = td->io_ops->data; + struct hdfsio_data *hd = td->io_ops_data; if (hd->curr_file_id != -1) { if ( hdfsCloseFile(hd->fs, hd->fp) == -1) { @@ -235,10 +240,10 @@ int fio_hdfsio_close_file(struct thread_data *td, struct fio_file *f) return 0; } -static int fio_hdfsio_init(struct thread_data *td) +static int fio_hdfsio_io_u_init(struct thread_data *td, struct io_u *io_u) { struct hdfsio_options *options = td->eo; - struct hdfsio_data *hd = td->io_ops->data; + struct hdfsio_data *hd = td->io_ops_data; struct fio_file *f; uint64_t j,k; int i, failure = 0; @@ -309,13 +314,13 @@ static int fio_hdfsio_setup(struct thread_data *td) int i; uint64_t file_size, total_file_size; - if (!td->io_ops->data) { + if (!td->io_ops_data) { hd = malloc(sizeof(*hd)); memset(hd, 0, sizeof(*hd)); hd->curr_file_id = -1; - td->io_ops->data = hd; + td->io_ops_data = hd; } total_file_size = 0; @@ -333,9 +338,9 @@ static int fio_hdfsio_setup(struct thread_data *td) } f->real_file_size = file_size; } - /* If the size doesn't divide nicely with the chunck size, + /* If the size doesn't divide nicely with the chunk size, * make the last files bigger. - * Used only if filesize was not explicitely given + * Used only if filesize was not explicitly given */ if (!td->o.file_size_low && total_file_size < td->o.size) { f->real_file_size += (td->o.size - total_file_size); @@ -344,9 +349,9 @@ static int fio_hdfsio_setup(struct thread_data *td) return 0; } -static int fio_hdfsio_io_u_init(struct thread_data *td, struct io_u *io_u) +static int fio_hdfsio_init(struct thread_data *td) { - struct hdfsio_data *hd = td->io_ops->data; + struct hdfsio_data *hd = td->io_ops_data; struct hdfsio_options *options = td->eo; int failure; struct hdfsBuilder *bld; @@ -369,7 +374,7 @@ static int fio_hdfsio_io_u_init(struct thread_data *td, struct io_u *io_u) } hd->fs = hdfsBuilderConnect(bld); - /* hdfsSetWorkingDirectory succeed on non existend directory */ + /* hdfsSetWorkingDirectory succeed on non-existent directory */ if (hdfsExists(hd->fs, options->directory) < 0 || hdfsSetWorkingDirectory(hd->fs, options->directory) < 0) { failure = errno; log_err("hdfs: invalid working directory %s: %s\n", options->directory, strerror(errno)); @@ -381,14 +386,14 @@ static int fio_hdfsio_io_u_init(struct thread_data *td, struct io_u *io_u) static void fio_hdfsio_io_u_free(struct thread_data *td, struct io_u *io_u) { - struct hdfsio_data *hd = td->io_ops->data; + struct hdfsio_data *hd = td->io_ops_data; if (hd->fs && hdfsDisconnect(hd->fs) < 0) { log_err("hdfs: disconnect failed: %d\n", errno); } } -static struct ioengine_ops ioengine_hdfs = { +FIO_STATIC struct ioengine_ops ioengine = { .name = "libhdfs", .version = FIO_IOOPS_VERSION, .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NODISKUTIL, @@ -407,10 +412,10 @@ static struct ioengine_ops ioengine_hdfs = { static void fio_init fio_hdfsio_register(void) { - register_ioengine(&ioengine_hdfs); + register_ioengine(&ioengine); } static void fio_exit fio_hdfsio_unregister(void) { - unregister_ioengine(&ioengine_hdfs); + unregister_ioengine(&ioengine); }