diff --git a/lustre/include/lustre_param.h b/lustre/include/lustre_param.h index 286ffa5df6883239d1ae06418bf8aeaeb45c2d9d..c8ce9707b6d13a432c6307ba6e5b1d24c3e420b5 100644 --- a/lustre/include/lustre_param.h +++ b/lustre/include/lustre_param.h @@ -74,6 +74,7 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, #define PARAM_OST "ost." #define PARAM_OSC "osc." #define PARAM_MDT "mdt." +#define PARAM_MDD "mdd." #define PARAM_MDC "mdc." #define PARAM_LLITE "llite." #define PARAM_LOV "lov." diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 94afb7cdaf18da52ef89b060d141864869c6348e..5e9676529892785e6b7989f79cc1f51a5e72edb6 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -56,6 +56,7 @@ #include <linux/ldiskfs_fs.h> #include <lustre_mds.h> #include <lustre/lustre_idl.h> +#include <lustre_param.h> #include "mdd_internal.h" @@ -140,6 +141,16 @@ static int mdd_process_config(const struct lu_env *env, ENTRY; switch (cfg->lcfg_command) { + case LCFG_PARAM: { + struct lprocfs_static_vars lvars; + + lprocfs_mdd_init_vars(&lvars); + rc = class_process_proc_param(PARAM_MDD, lvars.obd_vars, cfg,m); + if (rc == -ENOSYS) + /* we don't understand; pass it on */ + rc = next->ld_ops->ldo_process_config(env, next, cfg); + break; + } case LCFG_SETUP: rc = next->ld_ops->ldo_process_config(env, next, cfg); if (rc) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 5eecc297f1c9ea6d58da4ca0b0931c377d6f1c61..b108250e0051b5a81ae1c58d90e1d97d61df77c5 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4132,9 +4132,10 @@ static int mdt_process_config(const struct lu_env *env, struct obd_device *obd = d->ld_obd; lprocfs_mdt_init_vars(&lvars); - rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, cfg, obd); - if (rc) - /* others are passed further */ + rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, + cfg, obd); + if (rc == -ENOSYS) + /* we don't understand; pass it on */ rc = next->ld_ops->ldo_process_config(env, next, cfg); break; } diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index b621ca690184d1af2b9f5623d02d6fe464812b3a..bb4ce90063d5f0e01ad25d06623570c8aac7d21c 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -1231,7 +1231,7 @@ static int mgs_write_log_lmv(struct obd_device *obd, struct fs_db *fsdb, CDEBUG(D_MGS, "Writing lmv(%s) log for %s\n", lmvname,logname); - OBD_ALLOC(lmvdesc, sizeof(*lmvdesc)); + OBD_ALLOC_PTR(lmvdesc); if (lmvdesc == NULL) RETURN(-ENOMEM); lmvdesc->ld_active_tgt_count = 0; @@ -1246,10 +1246,9 @@ static int mgs_write_log_lmv(struct obd_device *obd, struct fs_db *fsdb, rc = record_marker(obd, llh, fsdb, CM_END, lmvname, "lmv setup"); rc = record_end_log(obd, &llh); - OBD_FREE(lmvdesc, sizeof(*lmvdesc)); + OBD_FREE_PTR(lmvdesc); RETURN(rc); } -/***************************************END PROTO**********************/ /* lov is the first thing in the mdt and client logs */ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb, @@ -1271,7 +1270,7 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb, */ /* FIXME just make lov_setup accept empty desc (put uuid in buf 2) */ - OBD_ALLOC(lovdesc, sizeof(*lovdesc)); + OBD_ALLOC_PTR(lovdesc); if (lovdesc == NULL) RETURN(-ENOMEM); lovdesc->ld_magic = LOV_DESC_MAGIC; @@ -1297,9 +1296,11 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb, rc = record_lov_setup(obd, llh, lovname, lovdesc); rc = record_marker(obd, llh, fsdb, CM_END, lovname, "lov setup"); rc = record_end_log(obd, &llh); -out: - OBD_FREE(lovdesc, sizeof(*lovdesc)); - RETURN(rc); + + EXIT; +out: + OBD_FREE_PTR(lovdesc); + return rc; } /* add failnids to open log */ @@ -2628,7 +2629,7 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb, CDEBUG(D_MGS, "next param '%s'\n", ptr); /* The params are stored in MOUNT_DATA_FILE and modified - via tunefs.lustre */ + via tunefs.lustre, or set using lctl conf_param */ /* Processed in lustre_start_mgc */ if (class_match_param(ptr, PARAM_MGSNODE, NULL) == 0) @@ -2849,6 +2850,7 @@ active_err: /* All mdt., ost. params in proc */ if ((class_match_param(ptr, PARAM_MDT, NULL) == 0) || + (class_match_param(ptr, PARAM_MDD, NULL) == 0) || (class_match_param(ptr, PARAM_OST, NULL) == 0)) { CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4); if (mgs_log_is_empty(obd, mti->mti_svname)) { @@ -3235,24 +3237,24 @@ out: RETURN(rc); } -static int mgs_write_log_pool(struct obd_device *obd, char *logname, struct fs_db *fsdb, - char *lovname, - enum lcfg_command_type cmd, - char *poolname, char *fsname, - char *ostname, char *comment) +static int mgs_write_log_pool(struct obd_device *obd, char *logname, + struct fs_db *fsdb, char *lovname, + enum lcfg_command_type cmd, + char *poolname, char *fsname, + char *ostname, char *comment) { struct llog_handle *llh = NULL; int rc; rc = record_start_log(obd, &llh, logname); if (rc) - RETURN(rc); + return rc; rc = record_marker(obd, llh, fsdb, CM_START, lovname, comment); record_base(obd, llh, lovname, 0, cmd, poolname, fsname, ostname, 0); rc = record_marker(obd, llh, fsdb, CM_END, lovname, comment); rc = record_end_log(obd, &llh); - return(rc); + return rc; } int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, @@ -3262,10 +3264,10 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, char mdt_index[16]; char *lovname; char *logname; - char *label, *canceled_label = NULL; + char *label = NULL, *canceled_label = NULL; int label_sz; - struct mgs_target_info *mti; - int rc; + struct mgs_target_info *mti = NULL; + int rc, i; ENTRY; rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb); @@ -3294,7 +3296,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, OBD_ALLOC(label, label_sz); if (label == NULL) - RETURN(-ENOMEM); + GOTO(out, rc = -ENOMEM); switch(cmd) { case LCFG_POOL_NEW: { @@ -3310,7 +3312,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, case LCFG_POOL_REM: { OBD_ALLOC(canceled_label, label_sz); if (canceled_label == NULL) - RETURN(-ENOMEM); + GOTO(out, rc = -ENOMEM); sprintf(label, "rem %s.%s.%s", fsname, poolname, ostname); sprintf(canceled_label, @@ -3320,7 +3322,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, case LCFG_POOL_DEL: { OBD_ALLOC(canceled_label, label_sz); if (canceled_label == NULL) - RETURN(-ENOMEM); + GOTO(out, rc = -ENOMEM); sprintf(label, "del %s.%s", fsname, poolname); sprintf(canceled_label, @@ -3334,44 +3336,56 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, down(&fsdb->fsdb_sem); - sprintf(mdt_index, "-MDT%04x", 0); - name_create(&logname, fsname, mdt_index); - name_create(&lovname, logname, "-mdtlov"); - - mti = NULL; if (canceled_label != NULL) { - OBD_ALLOC(mti, sizeof(*mti)); - if (mti != NULL) { - strcpy(mti->mti_svname, "lov pool"); - mgs_modify(obd, fsdb, mti, logname, lovname, - canceled_label, CM_SKIP); - } + OBD_ALLOC_PTR(mti); + if (mti == NULL) + GOTO(out, rc = -ENOMEM); } - mgs_write_log_pool(obd, logname, fsdb, lovname, - cmd, fsname, poolname, ostname, label); - name_destroy(&logname); + /* loop on all potential MDT */ + for (i = 0; i < INDEX_MAP_SIZE * 8; i++) { + if (test_bit(i, fsdb->fsdb_mdt_index_map)) { + sprintf(mdt_index, "-MDT%04x", i); + name_create(&logname, fsname, mdt_index); + name_create(&lovname, logname, "-mdtlov"); + + if (canceled_label != NULL) { + strcpy(mti->mti_svname, "lov pool"); + mgs_modify(obd, fsdb, mti, logname, lovname, + canceled_label, CM_SKIP); + } + + mgs_write_log_pool(obd, logname, fsdb, lovname, + cmd, fsname, poolname, ostname, + label); + name_destroy(&logname); + name_destroy(&lovname); + } + } name_create(&logname, fsname, "-client"); - if (canceled_label != NULL) { - mgs_modify(obd, fsdb, mti, logname, lovname, + if (canceled_label != NULL) + mgs_modify(obd, fsdb, mti, logname, fsdb->fsdb_clilov, canceled_label, CM_SKIP); - } + mgs_write_log_pool(obd, logname, fsdb, fsdb->fsdb_clilov, cmd, fsname, poolname, ostname, label); name_destroy(&logname); - name_destroy(&lovname); up(&fsdb->fsdb_sem); - OBD_FREE(label, label_sz); + EXIT; +out: + if (label != NULL) + OBD_FREE(label, label_sz); + if (canceled_label != NULL) OBD_FREE(canceled_label, label_sz); if (mti != NULL) - OBD_FREE(mti, sizeof(*mti)); + OBD_FREE_PTR(mti); - RETURN(rc); + return rc; } #if 0 diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 76e91ba200b8838cfd14b41691ff1b6232fb2263..e7802fb4a49dd6c07705e7196ae561a0dd005b5e 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -255,7 +255,7 @@ struct file_operations lprocfs_evict_client_fops = { EXPORT_SYMBOL(lprocfs_evict_client_fops); /** - * Add /proc entrys. + * Add /proc entries. * * \param root [in] The parent proc entry on which new entry will be added. * \param list [in] Array of proc entries to be added. diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 7a90d8eefbe84dc0a0446c405f91931ac65d6875..05867da0044bc4e66c3c781337ec8d554aa27296 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -887,7 +887,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, class_match_param(key, prefix, &key); sval = strchr(key, '='); if (!sval || (*(sval + 1) == 0)) { - CERROR("Can't parse param %s\n", key); + CERROR("Can't parse param %s (missing '=')\n", key); /* rc = -EINVAL; continue parsing other params */ continue; } @@ -919,6 +919,10 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, j++; } if (!matched) { + /* If the prefix doesn't match, return error so we + can pass it down the stack */ + if (strnchr(key, keylen, '.')) + RETURN(-ENOSYS); CERROR("%s: unknown param %s\n", (char *)lustre_cfg_string(lcfg, 0), key); /* rc = -EINVAL; continue parsing other params */ diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index aeeb8c86350aceaf2d58eff4c3a27b26e1549169..60b66ee4b7294f44d2149933ecf85ae38b2432be 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5611,14 +5611,14 @@ check_file_in_pool() return 0 } -test_200() { +test_200a() { do_facet mgs $LCTL pool_new $FSNAME.$POOL do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL [ $? == 0 ] || error "Pool creation of $POOL failed" } -run_test 200 "Create new pool ==========================================" +run_test 200a "Create new pool ==========================================" -test_201() { +test_200b() { TGT=$(seq -f $FSNAME-OST%04g_UUID $TGTPOOL_FIRST $TGTPOOL_STEP \ $TGTPOOL_MAX | tr '\n' ' ') do_facet mgs $LCTL pool_add $FSNAME.$POOL \ @@ -5627,22 +5627,22 @@ test_201() { | tr '\n' ' ') [ "$res" = "$TGT" ] || error "Pool content ($res) do not match requested ($TGT)" } -run_test 201 "Add targets to a pool ====================================" +run_test 200b "Add targets to a pool ====================================" -test_202a() { +test_200c() { mkdir -p $POOL_DIR $SETSTRIPE -c 2 -p $POOL $POOL_DIR [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR" } -run_test 202a "Set pool on a directory =================================" +run_test 200c "Set pool on a directory =================================" -test_202b() { +test_200d() { res=$($GETSTRIPE $POOL_DIR | grep pool: | cut -f8 -d " ") [ "$res" = $POOL ] || error "Pool on $POOL_DIR is not $POOL" } -run_test 202b "Check pool on a directory ===============================" +run_test 200d "Check pool on a directory ===============================" -test_202c() { +test_200e() { failed=0 for i in $(seq -w 1 $(($TGT_COUNT * 3))) do @@ -5656,9 +5656,9 @@ test_202c() { done [ "$failed" = 0 ] || error "$failed files not allocated in $POOL" } -run_test 202c "Check files allocation from directory pool ==============" +run_test 200e "Check files allocation from directory pool ==============" -test_203() { +test_200f() { mkdir -p $POOL_FILE failed=0 for i in $(seq -w 1 $(($TGT_COUNT * 3))) @@ -5673,17 +5673,17 @@ test_203() { done [ "$failed" = 0 ] || error "$failed files not allocated in $POOL" } -run_test 203 "Create files in a pool ===================================" +run_test 200f "Create files in a pool ===================================" -test_210a() { +test_200g() { TGT=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL | head -1) do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT res=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL | grep $TGT) [ "$res" = "" ] || error "$TGT not removed from $FSNAME.$POOL" } -run_test 210a "Remove a target from a pool =============================" +run_test 200g "Remove a target from a pool =============================" -test_210b() { +test_200h() { for TGT in $(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL) do do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT @@ -5691,14 +5691,14 @@ test_210b() { res=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL) [ "$res" = "" ] || error "Pool $FSNAME.$POOL cannot be drained" } -run_test 210b "Remove all targets from a pool ==========================" +run_test 200h "Remove all targets from a pool ==========================" -test_211() { +test_200i() { do_facet mgs $LCTL pool_destroy $FSNAME.$POOL res=$(do_facet mgs "$LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL 2>/dev/null") [ "$res" = "" ] || error "Pool $FSNAME.$POOL is not destroyed" } -run_test 211 "Remove a pool ============================================" +run_test 200i "Remove a pool ============================================" TMPDIR=$OLDTMPDIR TMP=$OLDTMP diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 478a930b3b62053a072b0eb7edb2fa96cb7fec15..712dc7fbcbb40ef5f75b6b3ccd9f789a7e1c37d6 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -547,6 +547,7 @@ static char *display_name(char *filename) } /* Find a character in a length limited string */ +/* BEWARE - kernel definition of strnchr has args in different order! */ static char *strnchr(const char *p, char c, size_t n) { if (!p)