/* * Initializes the ioengine configured for a job, if it has not been done so * already. */ int ioengine_load(struct thread_data *td) { const char *engine; /* * Engine has already been loaded. */ if (td->io_ops) return 0; if (!td->o.ioengine) { log_err("fio: internal fault, no IO engine specified\n"); return 1; } engine = get_engine_name(td->o.ioengine); td->io_ops = load_ioengine(td, engine); if (!td->io_ops) { log_err("fio: failed to load engine %s\n", engine); return 1; } if (td->io_ops->option_struct_size && td->io_ops->options) { /* * In cases where td->eo is set, clone it for a child thread. * This requires that the parent thread has the same ioengine, * but that requirement must be enforced by the code which * cloned the thread. */ void *origeo = td->eo; /* * Otherwise use the default thread options. */ if (!origeo && td != &def_thread && def_thread.eo && def_thread.io_ops->options == td->io_ops->options) origeo = def_thread.eo; options_init(td->io_ops->options); td->eo = malloc(td->io_ops->option_struct_size); /* * Use the default thread as an option template if this uses the * same options structure and there are non-default options * used. */ if (origeo) { memcpy(td->eo, origeo, td->io_ops->option_struct_size); options_mem_dupe(td->eo, td->io_ops->options); } else { memset(td->eo, 0, td->io_ops->option_struct_size); fill_default_options(td->eo, td->io_ops->options); } *(struct thread_data **)td->eo = td; } return 0; }
char *h_net_engine_get_name(unsigned long engine_id, h_net_engine_get_name_f get_engine_name) { char *engine_name; if (engine_id < H_NET_ENGINE_TYPE_COUNT) { engine_name = engine_names[engine_id]; } else { if (get_engine_name) { engine_name = get_engine_name(engine_id); } else { engine_name = "[unknown]"; } } return engine_name; }