From: Niu Yawei Date: Fri, 18 May 2012 06:09:11 +0000 (-0700) Subject: LU-694 config: make 'jobid_var' global X-Git-Tag: 2.2.55~59 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=33db53607dac6ee63755358147526c16843ac9c8;hp=60b5c3e464d6b4b333506e6db6b0635bb5a06577 LU-694 config: make 'jobid_var' global This patch makes the global parameter able to accept string value, and move the 'jobid_var' from the llite folder into the lustre proc root /proc/fs/lustre. Signed-off-by: Niu Yawei Change-Id: Ibaac19d2f29f8631d4717c6b0f82853cff64fc96 Reviewed-on: http://review.whamcloud.com/2785 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_param.h b/lustre/include/lustre_param.h index ca4c3dc..49e5dc5 100644 --- a/lustre/include/lustre_param.h +++ b/lustre/include/lustre_param.h @@ -82,6 +82,7 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, #define PARAM_AT_EXTRA "at_extra=" /* global */ #define PARAM_AT_EARLY_MARGIN "at_early_margin=" /* global */ #define PARAM_AT_HISTORY "at_history=" /* global */ +#define PARAM_JOBID_VAR "jobid_var=" /* global */ #define PARAM_MGSNODE "mgsnode=" /* only at mounttime */ #define PARAM_FAILNODE "failover.node=" /* add failover nid */ #define PARAM_FAILMODE "failover.mode=" /* initial mount only */ diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index f6a5fb8..b3a7fe1 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -650,24 +650,6 @@ static int ll_rd_maxea_size(char *page, char **start, off_t off, return snprintf(page, count, "%u\n", ealen); } -static int ll_rd_jobidvar(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - return snprintf(page, count, "%s\n", obd_jobid_var); -} - -static int ll_wr_jobidvar(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) - return -EINVAL; - - memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); - /* Trim the trailing '\n' if any */ - memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n')); - return count; -} - static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "uuid", ll_rd_sb_uuid, 0, 0 }, //{ "mntpt_path", ll_rd_path, 0, 0 }, @@ -698,7 +680,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "statahead_stats", ll_rd_statahead_stats, 0, 0 }, { "lazystatfs", ll_rd_lazystatfs, ll_wr_lazystatfs, 0 }, { "max_easize", ll_rd_maxea_size, 0, 0 }, - { "jobid_var", ll_rd_jobidvar, ll_wr_jobidvar, 0 }, { 0 } }; diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 806c273..04d1326 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -2004,51 +2004,53 @@ static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb, /* write global variable settings into log */ static int mgs_write_log_sys(struct obd_device *obd, struct fs_db *fsdb, - struct mgs_target_info *mti, char *sys, char *ptr) -{ - struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; - char *tmp; - char sep; - int cmd, val; - int rc; - - if (class_match_param(ptr, PARAM_TIMEOUT, &tmp) == 0) - cmd = LCFG_SET_TIMEOUT; - else if (class_match_param(ptr, PARAM_LDLM_TIMEOUT, &tmp) == 0) - cmd = LCFG_SET_LDLM_TIMEOUT; - /* Check for known params here so we can return error to lctl */ - else if ((class_match_param(ptr, PARAM_AT_MIN, &tmp) == 0) - || (class_match_param(ptr, PARAM_AT_MAX, &tmp) == 0) - || (class_match_param(ptr, PARAM_AT_EXTRA, &tmp) == 0) - || (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, &tmp) == 0) - || (class_match_param(ptr, PARAM_AT_HISTORY, &tmp) == 0)) - cmd = LCFG_PARAM; - else - return -EINVAL; - - /* separate the value */ - val = simple_strtoul(tmp, NULL, 0); - if (*tmp == '\0') - CDEBUG(D_MGS, "global '%s' removed\n", sys); - else - CDEBUG(D_MGS, "global '%s' val=%d\n", sys, val); - - lustre_cfg_bufs_reset(&bufs, NULL); - lustre_cfg_bufs_set_string(&bufs, 1, sys); - lcfg = lustre_cfg_new(cmd, &bufs); - lcfg->lcfg_num = val; - /* truncate the comment to the parameter name */ - ptr = tmp - 1; - sep = *ptr; - *ptr = '\0'; - /* modify all servers and clients */ - rc = mgs_write_log_direct_all(obd, fsdb, mti, - *tmp == '\0' ? NULL : lcfg, - mti->mti_fsname, sys); - *ptr = sep; - lustre_cfg_free(lcfg); - return rc; + struct mgs_target_info *mti, char *sys, char *ptr) +{ + struct lustre_cfg_bufs bufs; + struct lustre_cfg *lcfg; + char *tmp, sep; + int rc, cmd, convert = 1; + + if (class_match_param(ptr, PARAM_TIMEOUT, &tmp) == 0) { + cmd = LCFG_SET_TIMEOUT; + } else if (class_match_param(ptr, PARAM_LDLM_TIMEOUT, &tmp) == 0) { + cmd = LCFG_SET_LDLM_TIMEOUT; + /* Check for known params here so we can return error to lctl */ + } else if ((class_match_param(ptr, PARAM_AT_MIN, &tmp) == 0) || + (class_match_param(ptr, PARAM_AT_MAX, &tmp) == 0) || + (class_match_param(ptr, PARAM_AT_EXTRA, &tmp) == 0) || + (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, &tmp) == 0) || + (class_match_param(ptr, PARAM_AT_HISTORY, &tmp) == 0)) { + cmd = LCFG_PARAM; + } else if (class_match_param(ptr, PARAM_JOBID_VAR, &tmp) == 0) { + convert = 0; /* Don't convert string value to integer */ + cmd = LCFG_PARAM; + } else { + return -EINVAL; + } + + if (mgs_param_empty(ptr)) + CDEBUG(D_MGS, "global '%s' removed\n", sys); + else + CDEBUG(D_MGS, "global '%s' val=%s\n", sys, tmp); + + lustre_cfg_bufs_reset(&bufs, NULL); + lustre_cfg_bufs_set_string(&bufs, 1, sys); + if (!convert && *tmp != '\0') + lustre_cfg_bufs_set_string(&bufs, 2, tmp); + lcfg = lustre_cfg_new(cmd, &bufs); + lcfg->lcfg_num = convert ? simple_strtoul(tmp, NULL, 0) : 0; + /* truncate the comment to the parameter name */ + ptr = tmp - 1; + sep = *ptr; + *ptr = '\0'; + /* modify all servers and clients */ + rc = mgs_write_log_direct_all(obd, fsdb, mti, + *tmp == '\0' ? NULL : lcfg, + mti->mti_fsname, sys); + *ptr = sep; + lustre_cfg_free(lcfg); + return rc; } static int mgs_srpc_set_param_disk(struct obd_device *obd, diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c index 381152e..577dff4 100644 --- a/lustre/obdclass/linux/linux-module.c +++ b/lustre/obdclass/linux/linux-module.c @@ -321,14 +321,34 @@ static int obd_proc_read_health(char *page, char **start, off_t off, return rc; } +static int obd_proc_rd_jobid_var(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + return snprintf(page, count, "%s\n", obd_jobid_var); +} + +static int obd_proc_wr_jobid_var(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) + return -EINVAL; + + memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); + /* Trim the trailing '\n' if any */ + memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n')); + return count; +} + /* Root for /proc/fs/lustre */ struct proc_dir_entry *proc_lustre_root = NULL; struct lprocfs_vars lprocfs_base[] = { - { "version", obd_proc_read_version, NULL, NULL }, - { "pinger", obd_proc_read_pinger, NULL, NULL }, - { "health_check", obd_proc_read_health, NULL, NULL }, - { 0 } + { "version", obd_proc_read_version, NULL, NULL }, + { "pinger", obd_proc_read_pinger, NULL, NULL }, + { "health_check", obd_proc_read_health, NULL, NULL }, + { "jobid_var", obd_proc_rd_jobid_var, + obd_proc_wr_jobid_var, NULL }, + { 0 } }; #else #define lprocfs_base NULL diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 641227a..903f302 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -868,25 +868,28 @@ void class_del_profiles(void) EXIT; } -static int class_set_global(char *ptr, int val) { - ENTRY; - - if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0) - at_min = val; - else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0) - at_max = val; - else if (class_match_param(ptr, PARAM_AT_EXTRA, NULL) == 0) - at_extra = val; - else if (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, NULL) == 0) - at_early_margin = val; - else if (class_match_param(ptr, PARAM_AT_HISTORY, NULL) == 0) - at_history = val; - else - RETURN(-EINVAL); - - CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val); - - RETURN(0); +static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) +{ + ENTRY; + if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0) + at_min = val; + else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0) + at_max = val; + else if (class_match_param(ptr, PARAM_AT_EXTRA, NULL) == 0) + at_extra = val; + else if (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, NULL) == 0) + at_early_margin = val; + else if (class_match_param(ptr, PARAM_AT_HISTORY, NULL) == 0) + at_history = val; + else if (class_match_param(ptr, PARAM_JOBID_VAR, NULL) == 0) { + memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); + memcpy(obd_jobid_var, lustre_cfg_string(lcfg, 2), + JOBSTATS_JOBID_VAR_MAX_LEN + 1); + } else + RETURN(-EINVAL); + + CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val); + RETURN(0); } @@ -993,7 +996,7 @@ int class_process_config(struct lustre_cfg *lcfg) } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_SYS, &tmp) == 0)) { /* Global param settings */ - err = class_set_global(tmp, lcfg->lcfg_num); + err = class_set_global(tmp, lcfg->lcfg_num, lcfg); /* Note that since LCFG_PARAM is LCFG_REQUIRED, new unknown globals would cause config to fail */ if (err) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index f1c0519..a0ef2df 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8764,10 +8764,10 @@ verify_jobstats() { test_205() { # Job stats local cmd - OLD_JOBENV=`$LCTL get_param -n llite.*.jobid_var` + OLD_JOBENV=`$LCTL get_param -n jobid_var` if [ $OLD_JOBENV != $JOBENV ]; then - do_facet mgs $LCTL conf_param $FSNAME.llite.jobid_var=$JOBENV - wait_update $HOSTNAME "$LCTL get_param -n llite.*.jobid_var" \ + do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV + wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \ $JOBENV || return 1 fi @@ -8806,8 +8806,8 @@ test_205() { # Job stats rm -f $DIR/jobstats_test_rename if [ $OLD_JOBENV != $JOBENV ]; then - do_facet mgs $LCTL conf_param $FSNAME.llite.jobid_var=$OLD_JOBENV - wait_update $HOSTNAME "$LCTL get_param -n llite.*.jobid_var" \ + do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV + wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \ $OLD_JOBENV || return 1 fi }