From 0632de2b0144ee751cc5a38e0aa2dcad43523bea Mon Sep 17 00:00:00 2001 From: "hongchao.zhang" Date: Thu, 11 Feb 2010 12:41:06 -0800 Subject: [PATCH] b=19069 save nid string into buffer before creating dir in lprocfs_exp_setup, save the nid string gotten from libcfs_nid2str into a temporary buffer before calling lprocfs_register to create proc directory, then to avoid the race on the internal nid string buffer. i=johann@sun.com i=zhen.liang@sun.com --- libcfs/libcfs/nidstrings.c | 3 --- lnet/include/lnet/lnet.h | 3 +++ lustre/obdclass/lprocfs_status.c | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libcfs/libcfs/nidstrings.c b/libcfs/libcfs/nidstrings.c index 68c2ebc..36009d4 100644 --- a/libcfs/libcfs/nidstrings.c +++ b/libcfs/libcfs/nidstrings.c @@ -64,9 +64,6 @@ * between getting its string and using it. */ -#define LNET_NIDSTR_COUNT 128 /* # of nidstrings */ -#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ - static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE]; static int libcfs_nidstring_idx = 0; diff --git a/lnet/include/lnet/lnet.h b/lnet/include/lnet/lnet.h index b30d737..5c3f46d 100644 --- a/lnet/include/lnet/lnet.h +++ b/lnet/include/lnet/lnet.h @@ -55,4 +55,7 @@ #include #include +#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ +#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ + #endif diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 754c515..9510296 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1768,6 +1768,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) struct nid_stat *new_stat, *old_stat; struct obd_device *obd = NULL; cfs_proc_dir_entry_t *entry; + char *buffer = NULL; int rc = 0; ENTRY; @@ -1820,9 +1821,16 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) GOTO(destroy_new, rc = -EALREADY); } /* not found - create */ - new_stat->nid_proc = lprocfs_register(libcfs_nid2str(*nid), + OBD_ALLOC(buffer, LNET_NIDSTR_SIZE); + if (buffer == NULL) + GOTO(destroy_new, rc = -ENOMEM); + + memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE); + new_stat->nid_proc = lprocfs_register(buffer, obd->obd_proc_exports_entry, NULL, NULL); + OBD_FREE(buffer, LNET_NIDSTR_SIZE); + if (new_stat->nid_proc == NULL) { CERROR("Error making export directory for nid %s\n", libcfs_nid2str(*nid)); -- 1.8.3.1