fio_plugin: Use the prefix "g_" for global variables throughout

Change-Id: I000a3973ca624bf8d1224f910c3bf0dded9a2e36
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/441280
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-01-21 13:20:16 +09:00 committed by Darek Stojaczyk
parent 45593f39d9
commit fa92414ce4

View File

@ -47,10 +47,10 @@
#define NVME_IO_ALIGN 4096 #define NVME_IO_ALIGN 4096
#define FIO_NVME_PI_APPTAG 0x1234 #define FIO_NVME_PI_APPTAG 0x1234
static bool spdk_env_initialized; static bool g_spdk_env_initialized;
static int spdk_enable_sgl = 0; static int g_spdk_enable_sgl = 0;
static uint32_t spdk_pract_flag; static uint32_t g_spdk_pract_flag;
static uint32_t spdk_prchk_flags; static uint32_t g_spdk_prchk_flags;
struct spdk_fio_options { struct spdk_fio_options {
void *pad; /* off1 used in option descriptions may not be 0 */ void *pad; /* off1 used in option descriptions may not be 0 */
@ -82,10 +82,10 @@ struct spdk_fio_ctrlr {
struct spdk_fio_ctrlr *next; struct spdk_fio_ctrlr *next;
}; };
static struct spdk_fio_ctrlr *ctrlr_g; static struct spdk_fio_ctrlr *g_ctrlr;
static int td_count; static int g_td_count;
static pthread_t g_ctrlr_thread_id = 0; static pthread_t g_ctrlr_thread_id = 0;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool g_error; static bool g_error;
struct spdk_fio_qpair { struct spdk_fio_qpair {
@ -126,15 +126,15 @@ spdk_fio_poll_ctrlrs(void *arg)
rc, spdk_strerror(rc)); rc, spdk_strerror(rc));
} }
pthread_mutex_lock(&mutex); pthread_mutex_lock(&g_mutex);
fio_ctrlr = ctrlr_g; fio_ctrlr = g_ctrlr;
while (fio_ctrlr) { while (fio_ctrlr) {
spdk_nvme_ctrlr_process_admin_completions(fio_ctrlr->ctrlr); spdk_nvme_ctrlr_process_admin_completions(fio_ctrlr->ctrlr);
fio_ctrlr = fio_ctrlr->next; fio_ctrlr = fio_ctrlr->next;
} }
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&g_mutex);
rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
if (rc != 0) { if (rc != 0) {
@ -177,7 +177,7 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
static struct spdk_fio_ctrlr * static struct spdk_fio_ctrlr *
get_fio_ctrlr(const struct spdk_nvme_transport_id *trid) get_fio_ctrlr(const struct spdk_nvme_transport_id *trid)
{ {
struct spdk_fio_ctrlr *fio_ctrlr = ctrlr_g; struct spdk_fio_ctrlr *fio_ctrlr = g_ctrlr;
while (fio_ctrlr) { while (fio_ctrlr) {
if (spdk_nvme_transport_id_compare(trid, &fio_ctrlr->tr_id) == 0) { if (spdk_nvme_transport_id_compare(trid, &fio_ctrlr->tr_id) == 0) {
return fio_ctrlr; return fio_ctrlr;
@ -265,8 +265,8 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
fio_ctrlr->opts = *opts; fio_ctrlr->opts = *opts;
fio_ctrlr->ctrlr = ctrlr; fio_ctrlr->ctrlr = ctrlr;
fio_ctrlr->tr_id = *trid; fio_ctrlr->tr_id = *trid;
fio_ctrlr->next = ctrlr_g; fio_ctrlr->next = g_ctrlr;
ctrlr_g = fio_ctrlr; g_ctrlr = fio_ctrlr;
} }
ns = spdk_nvme_ctrlr_get_ns(fio_ctrlr->ctrlr, ns_id); ns = spdk_nvme_ctrlr_get_ns(fio_ctrlr->ctrlr, ns_id);
@ -316,7 +316,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
fio_thread->fio_qpair = fio_qpair; fio_thread->fio_qpair = fio_qpair;
if (spdk_nvme_ns_get_flags(ns) & SPDK_NVME_NS_DPS_PI_SUPPORTED) { if (spdk_nvme_ns_get_flags(ns) & SPDK_NVME_NS_DPS_PI_SUPPORTED) {
fio_qpair->io_flags = spdk_pract_flag | spdk_prchk_flags; fio_qpair->io_flags = g_spdk_pract_flag | g_spdk_prchk_flags;
} }
fio_qpair->do_nvme_pi = fio_do_nvme_pi_check(fio_qpair); fio_qpair->do_nvme_pi = fio_do_nvme_pi_check(fio_qpair);
@ -339,22 +339,22 @@ static void parse_prchk_flags(const char *prchk_str)
} }
if (strstr(prchk_str, "GUARD") != NULL) { if (strstr(prchk_str, "GUARD") != NULL) {
spdk_prchk_flags = SPDK_NVME_IO_FLAGS_PRCHK_GUARD; g_spdk_prchk_flags = SPDK_NVME_IO_FLAGS_PRCHK_GUARD;
} }
if (strstr(prchk_str, "REFTAG") != NULL) { if (strstr(prchk_str, "REFTAG") != NULL) {
spdk_prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG; g_spdk_prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
} }
if (strstr(prchk_str, "APPTAG") != NULL) { if (strstr(prchk_str, "APPTAG") != NULL) {
spdk_prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_APPTAG; g_spdk_prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_APPTAG;
} }
} }
static void parse_pract_flag(int pract) static void parse_pract_flag(int pract)
{ {
if (pract == 1) { if (pract == 1) {
spdk_pract_flag = SPDK_NVME_IO_FLAGS_PRACT; g_spdk_pract_flag = SPDK_NVME_IO_FLAGS_PRACT;
} else { } else {
spdk_pract_flag = 0; g_spdk_pract_flag = 0;
} }
} }
@ -381,7 +381,7 @@ static int spdk_fio_setup(struct thread_data *td)
return 1; return 1;
} }
pthread_mutex_lock(&mutex); pthread_mutex_lock(&g_mutex);
fio_thread = calloc(1, sizeof(*fio_thread)); fio_thread = calloc(1, sizeof(*fio_thread));
assert(fio_thread != NULL); assert(fio_thread != NULL);
@ -393,12 +393,12 @@ static int spdk_fio_setup(struct thread_data *td)
fio_thread->iocq = calloc(fio_thread->iocq_size, sizeof(struct io_u *)); fio_thread->iocq = calloc(fio_thread->iocq_size, sizeof(struct io_u *));
assert(fio_thread->iocq != NULL); assert(fio_thread->iocq != NULL);
if (!spdk_env_initialized) { if (!g_spdk_env_initialized) {
spdk_env_opts_init(&opts); spdk_env_opts_init(&opts);
opts.name = "fio"; opts.name = "fio";
opts.mem_size = fio_options->mem_size; opts.mem_size = fio_options->mem_size;
opts.shm_id = fio_options->shm_id; opts.shm_id = fio_options->shm_id;
spdk_enable_sgl = fio_options->enable_sgl; g_spdk_enable_sgl = fio_options->enable_sgl;
parse_pract_flag(fio_options->pi_act); parse_pract_flag(fio_options->pi_act);
parse_prchk_flags(fio_options->pi_chk); parse_prchk_flags(fio_options->pi_chk);
if (spdk_env_init(&opts) < 0) { if (spdk_env_init(&opts) < 0) {
@ -406,10 +406,10 @@ static int spdk_fio_setup(struct thread_data *td)
free(fio_thread->iocq); free(fio_thread->iocq);
free(fio_thread); free(fio_thread);
fio_thread = NULL; fio_thread = NULL;
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&g_mutex);
return 1; return 1;
} }
spdk_env_initialized = true; g_spdk_env_initialized = true;
spdk_unaffinitize_thread(); spdk_unaffinitize_thread();
/* Spawn a thread to continue polling the controllers */ /* Spawn a thread to continue polling the controllers */
@ -478,9 +478,9 @@ static int spdk_fio_setup(struct thread_data *td)
} }
} }
td_count++; g_td_count++;
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&g_mutex);
return rc; return rc;
} }
@ -720,7 +720,7 @@ spdk_fio_queue(struct thread_data *td, struct io_u *io_u)
switch (io_u->ddir) { switch (io_u->ddir) {
case DDIR_READ: case DDIR_READ:
if (!spdk_enable_sgl) { if (!g_spdk_enable_sgl) {
rc = spdk_nvme_ns_cmd_read_with_md(ns, fio_qpair->qpair, io_u->buf, NULL, lba, lba_count, rc = spdk_nvme_ns_cmd_read_with_md(ns, fio_qpair->qpair, io_u->buf, NULL, lba, lba_count,
spdk_fio_completion_cb, fio_req, spdk_fio_completion_cb, fio_req,
fio_qpair->io_flags, fio_req->appmask, fio_req->apptag); fio_qpair->io_flags, fio_req->appmask, fio_req->apptag);
@ -732,7 +732,7 @@ spdk_fio_queue(struct thread_data *td, struct io_u *io_u)
} }
break; break;
case DDIR_WRITE: case DDIR_WRITE:
if (!spdk_enable_sgl) { if (!g_spdk_enable_sgl) {
rc = spdk_nvme_ns_cmd_write_with_md(ns, fio_qpair->qpair, io_u->buf, NULL, lba, lba_count, rc = spdk_nvme_ns_cmd_write_with_md(ns, fio_qpair->qpair, io_u->buf, NULL, lba, lba_count,
spdk_fio_completion_cb, fio_req, spdk_fio_completion_cb, fio_req,
fio_qpair->io_flags, fio_req->appmask, fio_req->apptag); fio_qpair->io_flags, fio_req->appmask, fio_req->apptag);
@ -844,22 +844,22 @@ static void spdk_fio_cleanup(struct thread_data *td)
free(fio_thread); free(fio_thread);
pthread_mutex_lock(&mutex); pthread_mutex_lock(&g_mutex);
td_count--; g_td_count--;
if (td_count == 0) { if (g_td_count == 0) {
struct spdk_fio_ctrlr *fio_ctrlr, *fio_ctrlr_tmp; struct spdk_fio_ctrlr *fio_ctrlr, *fio_ctrlr_tmp;
fio_ctrlr = ctrlr_g; fio_ctrlr = g_ctrlr;
while (fio_ctrlr != NULL) { while (fio_ctrlr != NULL) {
spdk_nvme_detach(fio_ctrlr->ctrlr); spdk_nvme_detach(fio_ctrlr->ctrlr);
fio_ctrlr_tmp = fio_ctrlr->next; fio_ctrlr_tmp = fio_ctrlr->next;
free(fio_ctrlr); free(fio_ctrlr);
fio_ctrlr = fio_ctrlr_tmp; fio_ctrlr = fio_ctrlr_tmp;
} }
ctrlr_g = NULL; g_ctrlr = NULL;
} }
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&g_mutex);
if (!ctrlr_g) { if (!g_ctrlr) {
if (pthread_cancel(g_ctrlr_thread_id) == 0) { if (pthread_cancel(g_ctrlr_thread_id) == 0) {
pthread_join(g_ctrlr_thread_id, NULL); pthread_join(g_ctrlr_thread_id, NULL);
} }