From: Mikhail Pershin Date: Tue, 31 Aug 2010 11:17:20 +0000 (+0400) Subject: Revert "b=17471 change conf_param syntax to match set_param" X-Git-Tag: 2.0.51.0~15 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e03aa1d2d933c28c9a31fa06708c3244424807f8 Revert "b=17471 change conf_param syntax to match set_param" This reverts commit 9fe6b20f03f57eb3a224dd203f74fb8fd8411c36. --- diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index 51dc986..d7dfac6 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -318,7 +318,6 @@ __u32 libcfs_str2net(const char *str); lnet_nid_t libcfs_str2nid(const char *str); int libcfs_str2anynid(lnet_nid_t *nid, const char *str); char *libcfs_id2str(lnet_process_id_t id); -int libcfs_str2server(char *name, int *type, __u32 *idx, char **endptr); int cfs_iswhite(char c); void cfs_free_nidlist(cfs_list_t *list); int cfs_parse_nidlist(char *str, int len, cfs_list_t *list); @@ -342,7 +341,6 @@ int cfs_match_nid(lnet_nid_t nid, cfs_list_t *list); /* max value for numeric network address */ #define MAX_NUMERIC_VALUE 0xffffffff - /* implication */ #define ergo(a, b) (!(a) || (b)) /* logical equivalence */ @@ -352,12 +350,6 @@ int cfs_match_nid(lnet_nid_t nid, cfs_list_t *list); # define CFS_CURRENT_TIME time(0) #endif -/* Server types */ -#define SVTYPE_MDT 0x0001 -#define SVTYPE_OST 0x0002 -#define SVTYPE_MGS 0x0004 -#define SVTYPE_ALL 0x0008 - /* -------------------------------------------------------------------- * Light-weight trace * Support for temporary event tracing with minimal Heisenberg effect. diff --git a/libcfs/libcfs/nidstrings.c b/libcfs/libcfs/nidstrings.c index fa8ca85..d5b03ed 100644 --- a/libcfs/libcfs/nidstrings.c +++ b/libcfs/libcfs/nidstrings.c @@ -557,54 +557,6 @@ libcfs_str2anynid(lnet_nid_t *nidp, const char *str) return *nidp != LNET_NID_ANY; } -/* parse server details from name */ -int libcfs_str2server(char *name, int *type, __u32 *idx, char **endptr) -{ - char *ptr; - int i; - - ptr = strstr(name, "-MDT"); - if (ptr) { - *type = SVTYPE_MDT; - } else { - ptr = strstr(name, "-OST"); - if (ptr) - *type = SVTYPE_OST; - else - return -EINVAL; - } - ptr += 4; - - if (strncmp(ptr, "all", 3) == 0) { - ptr += 3; - *type |= SVTYPE_ALL; - goto out; - } - if (*ptr == '*') { - ptr++; - *type |= SVTYPE_ALL; - goto out; - } - -#if __KERNEL__ - *idx = simple_strtoul(ptr, NULL, 16); -#else - *idx = strtoul(ptr, NULL, 16); -#endif - /* Require 4 hex digits */ - for (i = 0; i < 4; i++) - if (!isxdigit(*ptr++)) - return -EINVAL; -out: - /* Only acceptable garbage at the end of name is [-.:,] etc. */ - if (isalnum(*ptr)) - return -EINVAL; - - if (endptr) - *endptr = ptr; - return 0; -} - /** * Nid range list syntax. * \verbatim @@ -1322,7 +1274,6 @@ EXPORT_SYMBOL(libcfs_str2net); EXPORT_SYMBOL(libcfs_str2nid); EXPORT_SYMBOL(libcfs_id2str); EXPORT_SYMBOL(libcfs_str2anynid); -EXPORT_SYMBOL(libcfs_str2server); EXPORT_SYMBOL(cfs_iswhite); EXPORT_SYMBOL(cfs_free_nidlist); EXPORT_SYMBOL(cfs_parse_nidlist); diff --git a/lustre/doc/lctl.8 b/lustre/doc/lctl.8 index d931871..53ea4ee 100644 --- a/lustre/doc/lctl.8 +++ b/lustre/doc/lctl.8 @@ -203,11 +203,11 @@ Disable printing of the key name when printing values. .br 20 .TP -.BI conf_param " [-d] ..=" +.BI conf_param " [-d] .=" Set a permanent configuration parameter for any device via the MGS. This command must be run on the MGS node. .br -.B -d .. +.B -d . Delete a parameter setting (use the default value at the next restart). A null value for also deletes the parameter setting. .br .B Parameters: @@ -218,25 +218,25 @@ All of the writable parameters under .I lctl list_param -F osc.*.* | grep = ) can be permanently set using .B lctl conf_param -. The format is similar to set_param, except a single device (or fsname) is specified. Wildcards are not supported. See examples below. +, but the format is slightly different. For conf_param, the device is specified first, then the obdtype. (See examples below.) Wildcards are not supported. .br -Additionally, failover nodes may be added (or removed), and some system-wide parameters may be set as well (sys.at_max, sys.at_min, sys.at_extra, sys.at_early_margin, sys.at_history, sys.timeout, sys.ldlm_timeout.) Note system wide parameters affect all devices running on a node. +Additionally, failover nodes may be added (or removed), and some system-wide parameters may be set as well (sys.at_max, sys.at_min, sys.at_extra, sys.at_early_margin, sys.at_history, sys.timeout, sys.ldlm_timeout.) is ignored for system wide parameters. .br .B Examples: .br -# lctl conf_param sys.testfs.at_max=1200 +# lctl conf_param testfs.sys.at_max=1200 .br -# lctl conf_param llite.testfs.max_read_ahead_mb=16 +# lctl conf_param testfs.llite.max_read_ahead_mb=16 .br -# lctl conf_param lov.testfs-MDT0000.stripesize=2M +# lctl conf_param testfs-MDT0000.lov.stripesize=2M .br -# lctl conf_param osc.testfs-OST0001.active=0 +# lctl conf_param lustre-OST0001.osc.active=0 .br -# lctl conf_param osc.testfs-OST0000.max_dirty_mb=29.15 +# lctl conf_param testfs-OST0000.osc.max_dirty_mb=29.15 .br -# lctl conf_param ost.testfs-OST0000.client_cache_seconds=15 +# lctl conf_param testfs-OST0000.ost.client_cache_seconds=15 .br -# lctl conf_param osc.testfs-OST0000.failover.node=1.2.3.4@tcp1 +# lctl conf_param testfs-OST0000.failover.node=1.2.3.4@tcp1 .TP .BI activate Reactivate an import after deactivating, below. This setting is only effective until the next restart (see diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 5add59e..0915d80 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -67,7 +67,10 @@ /****************** persistent mount data *********************/ -/* First 4 bits reserved for SVTYPEs */ +#define LDD_F_SV_TYPE_MDT 0x0001 +#define LDD_F_SV_TYPE_OST 0x0002 +#define LDD_F_SV_TYPE_MGS 0x0004 +#define LDD_F_SV_ALL 0x0008 /** need an index assignment */ #define LDD_F_NEED_INDEX 0x0010 /** never registered */ @@ -119,7 +122,7 @@ struct lustre_disk_data { __u32 ldd_feature_incompat;/* incompatible feature flags */ __u32 ldd_config_ver; /* config rewrite count - not used */ - __u32 ldd_flags; /* SVTYPE */ + __u32 ldd_flags; /* LDD_SV_TYPE */ __u32 ldd_svindex; /* server index (0001), must match svname */ __u32 ldd_mount_type; /* target fs type LDD_MT_* */ @@ -134,21 +137,21 @@ struct lustre_disk_data { /*8192*/char ldd_params[4096]; /* key=value pairs */ }; -#define IS_MDT(data) ((data)->ldd_flags & SVTYPE_MDT) -#define IS_OST(data) ((data)->ldd_flags & SVTYPE_OST) -#define IS_MGS(data) ((data)->ldd_flags & SVTYPE_MGS) +#define IS_MDT(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MDT) +#define IS_OST(data) ((data)->ldd_flags & LDD_F_SV_TYPE_OST) +#define IS_MGS(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MGS) #define MT_STR(data) mt_str((data)->ldd_mount_type) /* Make the mdt/ost server obd name based on the filesystem name */ static inline int server_make_name(__u32 flags, __u16 index, char *fs, char *name) { - if (flags & (SVTYPE_MDT | SVTYPE_OST)) { - if (!(flags & SVTYPE_ALL)) + if (flags & (LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) { + if (!(flags & LDD_F_SV_ALL)) sprintf(name, "%.8s-%s%04x", fs, - (flags & SVTYPE_MDT) ? "MDT" : "OST", + (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST", index); - } else if (flags & SVTYPE_MGS) { + } else if (flags & LDD_F_SV_TYPE_MGS) { sprintf(name, "MGS"); } else { CERROR("unknown server type %#x\n", flags); @@ -157,6 +160,9 @@ static inline int server_make_name(__u32 flags, __u16 index, char *fs, return 0; } +/* Get the index from the obd name */ +int server_name2index(char *svname, __u32 *idx, char **endptr); + /****************** mount command *********************/ diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c index 44a35cd..d9d3d91 100644 --- a/lustre/lov/lproc_lov.c +++ b/lustre/lov/lproc_lov.c @@ -62,7 +62,7 @@ static int lov_wr_stripesize(struct file *file, const char *buffer, struct lov_desc *desc; __u64 val; int rc; - + LASSERT(dev != NULL); desc = &dev->u.lov.desc; rc = lprocfs_write_u64_helper(buffer, count, &val); @@ -93,7 +93,7 @@ static int lov_wr_stripeoffset(struct file *file, const char *buffer, struct lov_desc *desc; __u64 val; int rc; - + LASSERT(dev != NULL); desc = &dev->u.lov.desc; rc = lprocfs_write_u64_helper(buffer, count, &val); @@ -122,7 +122,7 @@ static int lov_wr_stripetype(struct file *file, const char *buffer, struct obd_device *dev = (struct obd_device *)data; struct lov_desc *desc; int val, rc; - + LASSERT(dev != NULL); desc = &dev->u.lov.desc; rc = lprocfs_write_helper(buffer, count, &val); @@ -153,7 +153,7 @@ static int lov_wr_stripecount(struct file *file, const char *buffer, struct obd_device *dev = (struct obd_device *)data; struct lov_desc *desc; int val, rc; - + LASSERT(dev != NULL); desc = &dev->u.lov.desc; rc = lprocfs_write_helper(buffer, count, &val); @@ -202,7 +202,7 @@ static int lov_rd_desc_uuid(char *page, char **start, off_t off, int count, return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid); } -/* free priority (0-256): how badly user wants to choose empty osts */ +/* free priority (0-255): how badly user wants to choose empty osts */ static int lov_rd_qos_priofree(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -212,9 +212,8 @@ static int lov_rd_qos_priofree(char *page, char **start, off_t off, int count, LASSERT(dev != NULL); lov = &dev->u.lov; *eof = 1; - /* Round the conversion; see below */ - return snprintf(page, count, "%d%%\n", - (lov->lov_qos.lq_prio_free * 100 + 128) >> 8); + return snprintf(page, count, "%d%%\n", + (lov->lov_qos.lq_prio_free * 100) >> 8); } static int lov_wr_qos_priofree(struct file *file, const char *buffer, @@ -230,12 +229,9 @@ static int lov_wr_qos_priofree(struct file *file, const char *buffer, if (rc) return rc; - if (val > 100 || val < 0) + if (val > 100) return -EINVAL; - /* We're converting a 0-100% range to 0-256. - * Add some rounding so that when we convert back to % - * for printout below, we end up with the original value */ - lov->lov_qos.lq_prio_free = ((val << 8) + 50) / 100; + lov->lov_qos.lq_prio_free = (val << 8) / 100; lov->lov_qos.lq_dirty = 1; lov->lov_qos.lq_reset = 1; return count; @@ -251,7 +247,7 @@ static int lov_rd_qos_thresholdrr(char *page, char **start, off_t off, lov = &dev->u.lov; *eof = 1; return snprintf(page, count, "%d%%\n", - ((lov->lov_qos.lq_threshold_rr * 100) + 128) >> 8); + (lov->lov_qos.lq_threshold_rr * 100) >> 8); } static int lov_wr_qos_thresholdrr(struct file *file, const char *buffer, @@ -270,7 +266,7 @@ static int lov_wr_qos_thresholdrr(struct file *file, const char *buffer, if (val > 100 || val < 0) return -EINVAL; - lov->lov_qos.lq_threshold_rr = ((val << 8) + 50) / 100; + lov->lov_qos.lq_threshold_rr = (val << 8) / 100; lov->lov_qos.lq_dirty = 1; return count; } @@ -338,8 +334,8 @@ static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos) static int lov_tgt_seq_show(struct seq_file *p, void *v) { struct lov_tgt_desc *tgt = v; - return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index, - obd_uuid2str(&tgt->ltd_uuid), + return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index, + obd_uuid2str(&tgt->ltd_uuid), tgt->ltd_active ? "" : "IN"); } diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 2796994..476b965 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -459,7 +459,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_PAUSE_TARGET_REG, 10); if (mti->mti_flags & LDD_F_WRITECONF) { - if (mti->mti_flags & SVTYPE_MDT && + if (mti->mti_flags & LDD_F_SV_TYPE_MDT && mti->mti_stripe_index == 0) { rc = mgs_erase_logs(obd, mti->mti_fsname); LCONSOLE_WARN("%s: Logs for fs %s were removed by user " @@ -467,7 +467,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) "in order to regenerate the logs." "\n", obd->obd_name, mti->mti_fsname); } else if (mti->mti_flags & - (SVTYPE_OST | SVTYPE_MDT)) { + (LDD_F_SV_TYPE_OST | LDD_F_SV_TYPE_MDT)) { rc = mgs_erase_log(obd, mti->mti_svname); LCONSOLE_WARN("%s: Regenerating %s log by user " "request.\n", diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 299032b..35534d0 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -71,7 +71,7 @@ struct mgs_tgt_srpc_conf { struct fs_db { - char fsdb_name[MTI_NAME_MAXLEN]; + char fsdb_name[9]; cfs_list_t fsdb_list; /* list of databases */ cfs_semaphore_t fsdb_sem; void *fsdb_ost_index_map; /* bitmap of used indicies */ diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index dc8ed62..1b99b6c 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -183,10 +183,9 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, /* attach 0:MDC_uml1_mdsA_MNT_client 1:mdc 2:1d834_MNT_client_03f */ if ((lcfg->lcfg_command == LCFG_ATTACH) && (strcmp(lustre_cfg_string(lcfg, 1), LUSTRE_MDC_NAME) == 0)) { - int type; - rc = libcfs_str2server(lustre_cfg_string(lcfg, 0), &type, + rc = server_name2index(lustre_cfg_string(lcfg, 0), &index, NULL); - if (rc || type != SVTYPE_MDT) { + if (rc != LDD_F_SV_TYPE_MDT) { CWARN("Unparsable MDC name %s, assuming index 0\n", lustre_cfg_string(lcfg, 0)); index = 0; @@ -507,9 +506,9 @@ int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti) if (cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) RETURN(-1); - if (mti->mti_flags & SVTYPE_OST) + if (mti->mti_flags & LDD_F_SV_TYPE_OST) imap = fsdb->fsdb_ost_index_map; - else if (mti->mti_flags & SVTYPE_MDT) + else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) imap = fsdb->fsdb_mdt_index_map; else RETURN(-EINVAL); @@ -547,9 +546,9 @@ static int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti) RETURN(rc); } - if (mti->mti_flags & SVTYPE_OST) { + if (mti->mti_flags & LDD_F_SV_TYPE_OST) { imap = fsdb->fsdb_ost_index_map; - } else if (mti->mti_flags & SVTYPE_MDT) { + } else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { imap = fsdb->fsdb_mdt_index_map; if (fsdb->fsdb_mdt_count >= MAX_MDT_COUNT) { LCONSOLE_ERROR_MSG(0x13f, "The max mdt count" @@ -565,7 +564,7 @@ static int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti) if (rc == -1) RETURN(-ERANGE); mti->mti_stripe_index = rc; - if (mti->mti_flags & SVTYPE_MDT) + if (mti->mti_flags & LDD_F_SV_TYPE_MDT) fsdb->fsdb_mdt_count ++; } @@ -1519,17 +1518,12 @@ out: RETURN(rc); } -static inline void name_create_sv(char **buf, char *fsname, char *type, int i) +static inline void name_create_mdt(char **logname, char *fsname, int i) { - char sv_index[9]; + char mdt_index[9]; - sprintf(sv_index, "-%s%04x", type, i); - name_create(buf, fsname, sv_index); -} - -static inline void name_create_mdt(char **buf, char *fsname, int i) -{ - name_create_sv(buf, fsname, "MDT", i); + sprintf(mdt_index, "-MDT%04x", i); + name_create(logname, fsname, mdt_index); } static void name_create_mdt_and_lov(char **logname, char **lovname, @@ -1894,9 +1888,9 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb, } /* Create mdc/osc client name (e.g. lustre-OST0001-osc) */ - if (mti->mti_flags & SVTYPE_MDT) { + if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { name_create(&cliname, mti->mti_svname, "-mdc"); - } else if (mti->mti_flags & SVTYPE_OST) { + } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { name_create(&cliname, mti->mti_svname, "-osc"); } else { RETURN(-EINVAL); @@ -1908,7 +1902,7 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb, name_destroy(&logname); name_destroy(&cliname); - if (mti->mti_flags & SVTYPE_OST) { + if (mti->mti_flags & LDD_F_SV_TYPE_OST) { /* Add OST failover nids to the MDT logs as well */ int i; @@ -1927,13 +1921,6 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb, RETURN(rc); } -/** write_log_param helper to add or modify a parameter change lcfg record - * in a config log. - * @logname log to add lcfg to (e.g. client, mdt, ost) - * @bufs empty bufs for temp usage - * @tgtname target obd device this param is meant to affect - * @ptr ptr to param=val - */ static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb, struct mgs_target_info *mti, char *logname, struct lustre_cfg_bufs *bufs, @@ -2367,59 +2354,10 @@ out: RETURN(rc); } -/** write_log_params helper for server logs (MDT or OST) - * Figures out which server logs to modify, adds lcfg to each one. - * Understands "match all" wildcard (lustre-OST*) - * @param svtype MDT or OST - * @param bufs empty lcfg bufs to use - * @param ptr pointer to param=val string - */ -static int mgs_wlp_server(struct obd_device *obd, struct fs_db *fsdb, - struct mgs_target_info *mti, int svtype, - struct lustre_cfg_bufs *bufs, - char *ptr) -{ - int rc = 0, type, i; - __u32 idx; - - if (strncmp(mti->mti_svname, mti->mti_fsname, MTI_NAME_MAXLEN) == 0) - /* device is unspecified completely? */ - type = svtype | SVTYPE_ALL; - else - rc = libcfs_str2server(mti->mti_svname, &type, &idx, NULL); - if (rc < 0) - return rc; - - if (type & SVTYPE_ALL) { - char *logname; - - for (i = 0; i < INDEX_MAP_SIZE * 8; i++) { - if (!cfs_test_bit(i, type & SVTYPE_MDT ? - fsdb->fsdb_mdt_index_map : - fsdb->fsdb_ost_index_map)) - continue; - name_create_sv(&logname, mti->mti_fsname, - type & SVTYPE_MDT ? "MDT" : "OST", i); - rc = mgs_wlp_lcfg(obd, fsdb, mti, - logname, bufs, - logname, ptr); - name_destroy(&logname); - } - } else { - if (mgs_log_is_empty(obd, mti->mti_svname)) - return -ENODEV; - rc = mgs_wlp_lcfg(obd, fsdb, mti, - mti->mti_svname, bufs, - mti->mti_svname, ptr); - } - return rc; -} - /* Permanent settings of all parameters by writing into the appropriate * configuration logs. * A parameter with null value ("='\0'") means to erase it out of * the logs. - * @param ptr pointer to param=value string */ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, struct mgs_target_info *mti, char *ptr) @@ -2457,7 +2395,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, GOTO(end, rc); } - if (class_find_param(ptr, PARAM_FAILNODE, NULL) == 0) { + if (class_match_param(ptr, PARAM_FAILNODE, NULL) == 0) { /* Add a failover nidlist */ rc = 0; /* We already processed failovers params for new @@ -2479,7 +2417,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, int flag = (*tmp == '0') ? CM_EXCLUDE : 0; int i; - if (!(mti->mti_flags & SVTYPE_OST)) { + if (!(mti->mti_flags & LDD_F_SV_TYPE_OST)) { LCONSOLE_ERROR_MSG(0x144, "%s: Only OSCs can " "be (de)activated.\n", mti->mti_svname); @@ -2508,7 +2446,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, } active_err: if (rc) { - LCONSOLE_ERROR_MSG(0x145, "Couldn't find %s in " + LCONSOLE_ERROR_MSG(0x145, "Couldn't find %s in" "log (%d). No permanent " "changes were made to the " "config log.\n", @@ -2532,7 +2470,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, char *mdtlovname; CDEBUG(D_MGS, "lov param %s\n", ptr); - if (!(mti->mti_flags & SVTYPE_MDT)) { + if (!(mti->mti_flags & LDD_F_SV_TYPE_MDT)) { LCONSOLE_ERROR_MSG(0x147, "LOV params must be " "set on the MDT, not %s. " "Ignoring.\n", @@ -2570,14 +2508,14 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, name_create(&cname, mti->mti_fsname, "-client"); /* Add the client type to match the obdname in class_config_llog_handler */ - } else if (mti->mti_flags & SVTYPE_MDT) { + } else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { /* COMPAT_146 */ if (fsdb->fsdb_mdc) name_create(&cname, fsdb->fsdb_mdc, ""); else name_create(&cname, mti->mti_svname, "-mdc"); - } else if (mti->mti_flags & SVTYPE_OST) { + } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { /* COMPAT_146 */ if (cfs_test_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags)) { LCONSOLE_ERROR_MSG(0x148, "Upgraded " @@ -2605,7 +2543,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, cname, ptr); /* osc params affect the MDT as well */ - if (!rc && (mti->mti_flags & SVTYPE_OST)) { + if (!rc && (mti->mti_flags & LDD_F_SV_TYPE_OST)) { int i; for (i = 0; i < INDEX_MAP_SIZE * 8; i++){ @@ -2628,20 +2566,54 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb, GOTO(end, rc); } - /* All mdt., mdd. params in proc */ - if ((class_match_param(ptr, PARAM_MDT, NULL) == 0) || - (class_match_param(ptr, PARAM_MDD, NULL) == 0)) { + /* All mdt. params in proc */ + if (class_match_param(ptr, PARAM_MDT, NULL) == 0) { + int i; + __u32 idx; + CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4); - rc = mgs_wlp_server(obd, fsdb, mti, SVTYPE_MDT, - &bufs, ptr); + if (strncmp(mti->mti_svname, mti->mti_fsname, + MTI_NAME_MAXLEN) == 0) + /* device is unspecified completely? */ + rc = LDD_F_SV_TYPE_MDT | LDD_F_SV_ALL; + else + rc = server_name2index(mti->mti_svname, &idx, NULL); + if (rc < 0) + goto active_err; + if ((rc & LDD_F_SV_TYPE_MDT) == 0) + goto active_err; + if (rc & LDD_F_SV_ALL) { + for (i = 0; i < INDEX_MAP_SIZE * 8; i++) { + if (!cfs_test_bit(i, + fsdb->fsdb_mdt_index_map)) + continue; + name_create_mdt(&logname, mti->mti_fsname, i); + rc = mgs_wlp_lcfg(obd, fsdb, mti, + logname, &bufs, + logname, ptr); + name_destroy(&logname); + if (rc) + goto active_err; + } + } else { + rc = mgs_wlp_lcfg(obd, fsdb, mti, + mti->mti_svname, &bufs, + mti->mti_svname, ptr); + if (rc) + goto active_err; + } GOTO(end, rc); } - /* All ost. params in proc */ - if (class_match_param(ptr, PARAM_OST, NULL) == 0) { + /* All mdd., ost. params in proc */ + if ((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); - rc = mgs_wlp_server(obd, fsdb, mti, SVTYPE_OST, - &bufs, ptr); + if (mgs_log_is_empty(obd, mti->mti_svname)) + GOTO(end, rc = -ENODEV); + + rc = mgs_wlp_lcfg(obd, fsdb, mti, mti->mti_svname, + &bufs, mti->mti_svname, ptr); GOTO(end, rc); } @@ -2738,9 +2710,9 @@ int mgs_write_log_target(struct obd_device *obd, if (mti->mti_flags & (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) { /* Generate a log from scratch */ - if (mti->mti_flags & SVTYPE_MDT) { + if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { rc = mgs_write_log_mdt(obd, fsdb, mti); - } else if (mti->mti_flags & SVTYPE_OST) { + } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) { rc = mgs_write_log_ost(obd, fsdb, mti); } else { CERROR("Unknown target type %#x, can't create log for " @@ -2822,7 +2794,7 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti, CDEBUG(D_MGS, "found old, unupdated client log\n"); } - if (mti->mti_flags & SVTYPE_MDT) { + if (mti->mti_flags & LDD_F_SV_TYPE_MDT) { if (mgs_log_is_empty(obd, mti->mti_svname)) { LCONSOLE_ERROR_MSG(0x14b, "The old MDT log %s is " "missing. Was tunefs.lustre " @@ -2957,39 +2929,45 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname) struct fs_db *fsdb; struct mgs_target_info *mti; char *devname, *param; - char *ptr; - __u32 index = 0; - int rc = 0, type = 0; + char *ptr, *tmp; + __u32 index; + int rc = 0; ENTRY; print_lustre_cfg(lcfg); + /* lustre, lustre-mdtlov, lustre-client, lustre-MDT0000 */ + devname = lustre_cfg_string(lcfg, 0); param = lustre_cfg_string(lcfg, 1); - /* format is lustre-OST0000.osc.max_dirty_mb=32 */ - ptr = strchr(param, '.'); - if (!ptr) { + if (!devname) { + /* Assume device name embedded in param: + lustre-OST0000.osc.max_dirty_mb=32 */ + ptr = strchr(param, '.'); + if (ptr) { + devname = param; + *ptr = 0; + param = ptr + 1; + } + } + if (!devname) { LCONSOLE_ERROR_MSG(0x14d, "No target specified: %s\n", param); - RETURN(-ENOENT); + RETURN(-ENOSYS); } - devname = param; - *ptr = '\0'; - param = ptr + 1; - CDEBUG(D_MGS, "device='%s' param='%s'\n", devname, param); /* Extract fsname */ + ptr = strrchr(devname, '-'); memset(fsname, 0, MTI_NAME_MAXLEN); - /* Check to see if we're a particular device */ - if (libcfs_str2server(devname, &type, &index, &ptr) == 0) { + if (ptr && (server_name2index(ptr, &index, NULL) >= 0)) { /* param related to llite isn't allowed to set by OST or MDT */ if (strncmp(param, PARAM_LLITE, sizeof(PARAM_LLITE)) == 0) RETURN(-EINVAL); - while (*(--ptr) != '-') ; /* I know it has a - */ + strncpy(fsname, devname, ptr - devname); } else { /* assume devname is the fsname */ strncpy(fsname, devname, MTI_NAME_MAXLEN); } - fsname[MTI_NAME_MAXLEN - 1] = '\0'; + fsname[MTI_NAME_MAXLEN - 1] = 0; CDEBUG(D_MGS, "setparam fs='%s' device='%s'\n", fsname, devname); rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb); @@ -2997,9 +2975,10 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname) RETURN(rc); if (!cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags) && cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) { - LCONSOLE_ERROR("setparam: Unknown filesystem '%s'.\n", fsname); + CERROR("No filesystem targets for %s. cfg_device from lctl " + "is '%s'\n", fsname, devname); mgs_free_fsdb(obd, fsdb); - RETURN(-ENOENT); + RETURN(-EINVAL); } /* Create a fake mti to hold everything */ @@ -3009,8 +2988,17 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname) strncpy(mti->mti_fsname, fsname, MTI_NAME_MAXLEN); strncpy(mti->mti_svname, devname, MTI_NAME_MAXLEN); strncpy(mti->mti_params, param, sizeof(mti->mti_params)); - mti->mti_stripe_index = index; - mti->mti_flags = type | LDD_F_PARAM; + rc = server_name2index(mti->mti_svname, &mti->mti_stripe_index, &tmp); + if (rc < 0) + /* Not a valid server; may be only fsname */ + rc = 0; + else + /* Strip -osc or -mdc suffix from svname */ + if (server_make_name(rc, mti->mti_stripe_index, mti->mti_fsname, + mti->mti_svname)) + GOTO(out, rc = -EINVAL); + + mti->mti_flags = rc | LDD_F_PARAM; cfs_down(&fsdb->fsdb_sem); rc = mgs_write_log_param(obd, fsdb, mti, mti->mti_params); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index a8ff6c2..1618a15 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -923,13 +923,13 @@ static int server_stop_servers(int lddflags, int lsiflags) /* Either an MDT or an OST or neither */ /* if this was an MDT, and there are no more MDT's, clean up the MDS */ - if ((lddflags & SVTYPE_MDT) && + if ((lddflags & LDD_F_SV_TYPE_MDT) && (obd = class_name2obd(LUSTRE_MDS_OBDNAME))) { /*FIXME pre-rename, should eventually be LUSTRE_MDT_NAME*/ type = class_search_type(LUSTRE_MDS_NAME); } /* if this was an OST, and there are no more OST's, clean up the OSS */ - if ((lddflags & SVTYPE_OST) && + if ((lddflags & LDD_F_SV_TYPE_OST) && (obd = class_name2obd(LUSTRE_OSS_OBDNAME))) { type = class_search_type(LUSTRE_OST_NAME); } @@ -1095,7 +1095,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) #if 0 /* If we're an MDT, make sure the global MDS is running */ - if (lsi->lsi_ldd->ldd_flags & SVTYPE_MDT) { + if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_MDT) { /* make sure the MDS is started */ cfs_mutex_down(&server_start_lock); obd = class_name2obd(LUSTRE_MDS_OBDNAME); @@ -1116,7 +1116,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) #endif /* If we're an OST, make sure the global OSS is running */ - if (lsi->lsi_ldd->ldd_flags & SVTYPE_OST) { + if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_OST) { /* make sure OSS is started */ cfs_mutex_down(&server_start_lock); obd = class_name2obd(LUSTRE_OSS_OBDNAME); @@ -1729,6 +1729,41 @@ out_mnt: return rc; } +/* Get the index from the obd name. + rc = server type, or + rc < 0 on error + if endptr isn't NULL it is set to end of name */ +int server_name2index(char *svname, __u32 *idx, char **endptr) +{ + unsigned long index; + int rc; + char *dash = strrchr(svname, '-'); + if (!dash) + return(-EINVAL); + + /* intepret -MDTXXXXX-mdc as mdt, the better way is to pass + * in the fsname, then determine the server index */ + if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) { + dash--; + for (; dash > svname && *dash != '-'; dash--); + if (dash == svname) + return(-EINVAL); + } + + if (strncmp(dash + 1, "MDT", 3) == 0) + rc = LDD_F_SV_TYPE_MDT; + else if (strncmp(dash + 1, "OST", 3) == 0) + rc = LDD_F_SV_TYPE_OST; + else + return(-EINVAL); + if (strcmp(dash + 4, "all") == 0) + return rc | LDD_F_SV_ALL; + + index = simple_strtoul(dash + 4, endptr, 16); + *idx = index; + return rc; +} + /*************** mount common betweeen server and client ***************/ /* Common umount */ @@ -1792,8 +1827,8 @@ int lustre_check_exclusion(struct super_block *sb, char *svname) int i, rc; ENTRY; - rc = libcfs_str2server(svname, &i, &index, NULL); - if (rc || i != SVTYPE_OST) + rc = server_name2index(svname, &index, NULL); + if (rc != LDD_F_SV_TYPE_OST) /* Only exclude OSTs */ RETURN(0); @@ -1814,7 +1849,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, char *ptr) { char *s1 = ptr, *s2; __u32 index, *exclude_list; - int rc = 0, devmax, type; + int rc = 0, devmax; ENTRY; /* The shortest an ost name can be is 8 chars: -OST0000. @@ -1830,12 +1865,12 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, char *ptr) /* we enter this fn pointing at the '=' */ while (*s1 && *s1 != ' ' && *s1 != ',') { s1++; - rc = libcfs_str2server(s1, &type, &index, &s2); + rc = server_name2index(s1, &index, &s2); if (rc < 0) { CERROR("Can't parse server name '%s'\n", s1); break; } - if (type == SVTYPE_OST) + if (rc == LDD_F_SV_TYPE_OST) exclude_list[lmd->lmd_exclude_count++] = index; else CDEBUG(D_MOUNT, "ignoring exclude %.7s\n", s1); @@ -2186,5 +2221,6 @@ EXPORT_SYMBOL(server_get_mount_2); EXPORT_SYMBOL(server_put_mount); EXPORT_SYMBOL(server_put_mount_2); EXPORT_SYMBOL(server_register_target); +EXPORT_SYMBOL(server_name2index); EXPORT_SYMBOL(server_mti_print); EXPORT_SYMBOL(do_lcfg); diff --git a/lustre/scripts/lustre_createcsv.in b/lustre/scripts/lustre_createcsv.in index 584b0e4..37d6ecd 100644 --- a/lustre/scripts/lustre_createcsv.in +++ b/lustre/scripts/lustre_createcsv.in @@ -82,9 +82,9 @@ declare -a VG_NAME VG_PVNAMES # VG declare -a LV_NAME LV_SIZE LV_VGNAME # LV # Lustre target service types -let "SVTYPE_MDT = 0x0001" -let "SVTYPE_OST = 0x0002" -let "SVTYPE_MGS = 0x0004" +let "LDD_F_SV_TYPE_MDT = 0x0001" +let "LDD_F_SV_TYPE_OST = 0x0002" +let "LDD_F_SV_TYPE_MGS = 0x0004" # Permanent mount options for ext3 or ldiskfs ALWAYS_MNTOPTS=${ALWAYS_MNTOPTS:-"errors=remount-ro"} @@ -1096,9 +1096,9 @@ get_devnames(){ # Check the service type of a lustre target is_target() { case "$1" in - "mdt") let "ret = $2 & SVTYPE_MDT";; - "ost") let "ret = $2 & SVTYPE_OST";; - "mgs") let "ret = $2 & SVTYPE_MGS";; + "mdt") let "ret = $2 & LDD_F_SV_TYPE_MDT";; + "ost") let "ret = $2 & LDD_F_SV_TYPE_OST";; + "mgs") let "ret = $2 & LDD_F_SV_TYPE_MGS";; "*") error_output "is_target(): Invalid" \ "target service type - \"$1\"!" diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 055302d..24bdbc9 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -835,10 +835,10 @@ test_27b() { } run_test 27b "Reacquire MGS lock after failover" -test_28a() { +test_28() { setup TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb" - PARAM="llite.$FSNAME.max_read_ahead_whole_mb" + PARAM="$FSNAME.llite.max_read_ahead_whole_mb" ORIG=$($TEST) FINAL=$(($ORIG + 1)) set_and_check client "$TEST" "$PARAM" $FINAL || return 3 @@ -856,58 +856,22 @@ test_28a() { set_and_check client "$TEST" "$PARAM" $ORIG || return 5 cleanup } -run_test 28a "permanent parameter setting" - -check_28b() { - local NODE=$1 - shift - set_and_check $NODE "$LCTL get_param -n $1*.$2 | head -1" "$1.$2" "$3" || \ - error "conf_param $1.$2 failed" -} - -test_28b() { - setup > /dev/null - # should error - do_facet mgs "$LCTL conf_param foo=1 2>/dev/null" && \ - error "Bad format should fail" - do_facet mgs "$LCTL conf_param osc.notanfs-OST0000.active=0 2>/dev/null" && \ - error "Setting on unknown fs should fail" - do_facet mgs "$LCTL conf_param osc.$FSNAME-OST00000.active=0 2>/dev/null" && \ - error "Bad target name should fail" - # should succeed - check_28b mds mdt.$FSNAME-MDT0000 capa_timeout 1500 - check_28b mds mdt.$FSNAME-MDT* identity_expire 150 - check_28b mds mdd.$FSNAME-MDT0000 atime_diff 15 - check_28b mds mdd.$FSNAME-MDT* sync_permission 0 - check_28b ost1 obdfilter.$FSNAME-OST0000 client_cache_seconds 15 - check_28b ost1 obdfilter.$FSNAME-OST* client_cache_count 15 - check_28b mds lov.$FSNAME-MDT0000 qos_maxage "15 Sec" - check_28b mds lov.$FSNAME-MDT0000 qos_prio_free "15%" - check_28b client mdc.$FSNAME-MDT0000 max_rpcs_in_flight 15 - check_28b client osc.$FSNAME-OST0000 active 0 - check_28b client osc.$FSNAME-OST0000 active 1 - check_28b client osc.$FSNAME-OST0000 max_dirty_mb 15 - check_28b client llite.$FSNAME max_read_ahead_mb 15 - set_and_check client "$LCTL get_param -n at_max" "sys.$FSNAME.at_max" 1500 || \ - error "conf_param sys.fsname.at_max failed" - cleanup > /dev/null -} -run_test 28b "permanent parameter setting, set_param syntax" +run_test 28 "permanent parameter setting" test_29() { [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return - setup > /dev/null 2>&1 + setup > /dev/null 2>&1 start_ost2 sleep 10 - local PARAM="osc.$FSNAME-OST0001.active" - local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active" - local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid" + local PARAM="$FSNAME-OST0001.osc.active" + local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active" + local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid" - ACTV=$(lctl get_param -n $PROC_ACT) + ACTV=$(lctl get_param -n $PROC_ACT) DEAC=$((1 - $ACTV)) set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2 - # also check ost_server_uuid status + # also check ost_server_uuid status RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV) if [ -z "$RESULT" ]; then echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)" @@ -968,7 +932,7 @@ test_30a() { ORIG=$($TEST) LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5) for i in ${LIST[@]}; do - set_and_check client "$TEST" "llite.$FSNAME.max_read_ahead_whole_mb" $i || return 3 + set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3 done # make sure client restart still works umount_client $MOUNT @@ -977,7 +941,7 @@ test_30a() { pass echo Erase parameter setting - do_facet mgs "$LCTL conf_param -d llite.$FSNAME.max_read_ahead_whole_mb" || return 6 + do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6 umount_client $MOUNT mount_client $MOUNT || return 6 FINAL=$($TEST) @@ -1002,13 +966,13 @@ test_30b() { echo "Using fake nid $NEW" TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'" - set_and_check client "$TEST" "osc.$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW" + set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW" NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids) echo $NIDS NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1)) echo "should have 2 failover nids: $NIDCOUNT" [ $NIDCOUNT -eq 2 ] || error "Failover nid not added" - do_facet mgs "$LCTL conf_param -d osc.$FSNAME-OST0000.failover.node" || error "conf_param delete failed" + do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed" umount_client $MOUNT mount_client $MOUNT || return 3 @@ -1224,7 +1188,7 @@ test_33a() { # bug 12333, was test_33 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT start fs2ost $fs2ostdev $OST_MOUNT_OPTS - do_facet mgs "$LCTL conf_param sys.$FSNAME2.timeout=200" || rc=1 + do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1 mkdir -p $MOUNT2 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2 echo "ok." @@ -1266,7 +1230,7 @@ test_34a() { sleep 1 cleanup } -run_test 34a "umount with opened file should fail" +run_test 34a "umount with opened file should be fail" test_34b() { @@ -1310,7 +1274,7 @@ test_35a() { # bug 12459 log "Set up a fake failnode for the MDS" FAKENID="127.0.0.2" local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1) - do_facet $SINGLEMDS $LCTL conf_param mdc.${device}.failover.node=$FAKENID || return 4 + do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4 log "Wait for RECONNECT_INTERVAL seconds (10s)" sleep 10 @@ -1364,7 +1328,7 @@ test_35b() { # bug 18674 FAKENID="127.0.0.2" local device=$(do_facet mds "$LCTL get_param -n devices" | \ awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1) - do_facet mds "$LCTL conf_param mdc.${device}.failover.node=$FAKENID" || \ + do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \ return 1 local at_max_saved=0 @@ -1621,7 +1585,7 @@ run_test 41 "mount mds with --nosvc and --nomgs" test_42() { #bug 14693 setup check_mount || return 2 - do_facet mgs $LCTL conf_param llite.$FSNAME.some_wrong_param=10 + do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10 umount_client $MOUNT mount_client $MOUNT || return 1 cleanup @@ -1635,11 +1599,11 @@ test_43() { chmod ugo+x $DIR || error "chmod 0 failed" set_and_check mds \ "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \ - "mdt.$FSNAME-MDT*.root_squash" \ + "$FSNAME.mdt.root_squash" \ "0:0" set_and_check mds \ "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \ - "mdt.$FSNAME-MDT*.nosquash_nids" \ + "$FSNAME.mdt.nosquash_nids" \ "NONE" # @@ -1663,7 +1627,7 @@ test_43() { # set_and_check mds \ "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \ - "mdt.$FSNAME-MDT*.root_squash" \ + "$FSNAME.mdt.root_squash" \ "$RUNAS_ID:$RUNAS_ID" ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile) @@ -1705,7 +1669,7 @@ test_43() { NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ') set_and_check mds \ "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \ - "mdt.$FSNAME-MDT*.nosquash_nids" \ + "$FSNAME-MDTall.mdt.nosquash_nids" \ "$NIDLIST" ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile) @@ -2333,8 +2297,7 @@ thread_sanity() { # We need to expand $parampat, but it may match multiple parameters, so # we'll pick the first one - paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1) - if [ -z "$paramp" ]; then + if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then error "Couldn't expand ${parampat}.threads_min parameter name" return 22 fi diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index fb50169..7c424df 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -1464,7 +1464,7 @@ test_18bc_sub() { fi DDPID=$! - do_facet $SINGLEMDS "$LCTL conf_param mdd.${FSNAME}-MDT*.quota_type=ug" + do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug" log "failing mds for $((2 * timeout)) seconds" fail $SINGLEMDS $((2 * timeout)) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 9945365..5bcd2da 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6438,11 +6438,11 @@ som_mode_switch() { if [ x$som = x"enabled" ]; then [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected" MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'` - do_facet mgs "$LCTL conf_param mdt.$FSNAME.som=disabled" + do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled" else [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected" MOUNTOPT="$MOUNTOPT,som_preview" - do_facet mgs "$LCTL conf_param mdt.$FSNAME.som=enabled" + do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled" fi # do remount to make new mount-conf parameters actual diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index a56027f..4ddc243 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -612,12 +612,12 @@ quota_save_version() { [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; } - do_facet mgs "lctl conf_param mdd.${fsname}-MDT*.quota_type=$spec" + do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec" local varsvc local osts=$(get_facets OST) for ost in ${osts//,/ }; do varsvc=${ost}_svc - do_facet mgs "lctl conf_param ost.${!varsvc}.quota_type=$spec" + do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec" done } diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 3a44cdd..8e08071 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -132,7 +132,8 @@ command_t cmdlist[] = { {"set_timeout", jt_lcfg_set_timeout, 0, "usage: conf_param obd_timeout=\n"}, {"conf_param", jt_lcfg_mgsparam, 0,"set a permanent config parameter.\n" - "usage: conf_param [-d] ..=\n" + "This command must be run on the MGS node\n" + "usage: conf_param [-d] \n" " -d Remove the permanent setting."}, {"local_param", jt_lcfg_param, 0, "set a temporary, local param\n" "usage: local_param \n"}, @@ -140,8 +141,8 @@ command_t cmdlist[] = { "usage: get_param [-n|-N|-F] \n" "Get the value of Lustre or LNET parameter from the specified path.\n" "The path can contain shell-style filename patterns.\n" - " -n Do not print the parameter name.\n" - " -N Do not print the parameter values.\n" + " -n Print only the value and not parameter name.\n" + " -N Print only matched parameter names and not the values.\n" " (Especially useful when using patterns.)\n" " -F When -N specified, add '/', '@' or '=' for directories,\n" " symlinks and writeable files, respectively."}, @@ -155,9 +156,7 @@ command_t cmdlist[] = { "List the name of Lustre or LNET parameter from the specified path.\n" " -F Add '/', '@' or '=' for dirs, symlinks and writeable files,\n" "respectively.\n" - " -R Recursively list all parameters under the specified path.\n" - " -q Quiet. Just return success or failure for parameter existance." - "\n" }, + " -R Recursively list all parameters under the specified path.\n"}, /* Debug commands */ {"==== debugging control ====", jt_noop, 0, "debug"}, diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 83f98ab..b2ed7e9 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -364,10 +364,32 @@ int jt_lcfg_del_mount_option(int argc, char **argv) int jt_lcfg_set_timeout(int argc, char **argv) { + int rc; + struct lustre_cfg_bufs bufs; + struct lustre_cfg *lcfg; + fprintf(stderr, "%s has been deprecated. Use conf_param instead.\n" - "e.g. conf_param sys.testfs.obd_timeout=50\n", + "e.g. conf_param lustre-MDT0000 obd_timeout=50\n", jt_cmdname(argv[0])); return CMD_HELP; + + + if (argc != 2) + return CMD_HELP; + + lustre_cfg_bufs_reset(&bufs, lcfg_devname); + lcfg = lustre_cfg_new(LCFG_SET_TIMEOUT, &bufs); + lcfg->lcfg_num = atoi(argv[1]); + + rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); + //rc = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg); + + lustre_cfg_free(lcfg); + if (rc < 0) { + fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), + strerror(rc = errno)); + } + return rc; } int jt_lcfg_add_conn(int argc, char **argv) @@ -468,148 +490,6 @@ int jt_lcfg_param(int argc, char **argv) return rc; } -/* Could this element of a parameter be an obd type? - * returns boolean - */ -static int element_could_be_obd(char *el) -{ - char *ptr = el; - - /* Rather than try to enumerate known obd types and risk - * becoming stale, I'm just going to check for no wacky chars */ - while ((*ptr != '\0') && (*ptr != '.')) { - if (!isalpha(*ptr++)) - return 0; - } - return 1; -} - -/* Convert set_param into conf_param format. Examples of differences: - * conf_param testfs.sys.at_max=1200 - * set_param at_max=1200 -- no fsname, but conf_param needs a valid one - * conf_param lustre.llite.max_read_ahead_mb=16 - * set_param llite.lustre-ffff81003f157000.max_read_ahead_mb=16 - * conf_param lustre-MDT0000.lov.stripesize=2M - * set_param lov.lustre-MDT0000-mdtlov.stripesize=2M - * set_param lov.lustre-clilov-ffff81003f157000.stripesize=2M -- clilov - * conf_param lustre-OST0001.osc.active=0 - * set_param osc.lustre-OST0000-osc-ffff81003f157000.active=0 - * conf_param lustre-OST0000.osc.max_dirty_mb=29.15 - * set_param osc.lustre-OST0000-osc-ffff81003f157000.max_dirty_mb=16 - * conf_param lustre-OST0001.ost.client_cache_seconds=15 - * set_param obdfilter.lustre-OST0001.client_cache_seconds=15 -- obdfilter/ost - * conf_param testfs-OST0000.failover.node=1.2.3.4@tcp1 - * no proc, but osc.testfs-OST0000.failover.node -- would be appropriate - */ -static int rearrange_setparam_syntax(char *in) -{ - char buf[MGS_PARAM_MAXLEN]; - char *element[3]; - int elements = 0; - int dev, obd; - char *ptr, *value; - __u32 index; - int type; - int rc; - - value = strchr(in, '='); - if (!value) - return -EINVAL; - *value = '\0'; - - /* Separate elements 0.1.all_the_rest */ - element[elements++] = in; - for (ptr = in; *ptr != '\0' && (elements < 3); ptr++) { - if (*ptr == '.') { - *ptr = '\0'; - element[elements++] = ++ptr; - } - } - if (elements != 3) { - fprintf(stderr, "error: Parameter format is " - "...\n" - "Wildcards are not supported. Examples:\n" - "sys.testfs.at_max=1200\n" - "llite.testfs.max_read_ahead_mb=16\n" - "lov.testfs-MDT0000.qos_threshold_rr=30\n" - "mdc.testfs-MDT0000.max_rpcs_in_flight=6\n" - "osc.testfs-OST0000.active=0\n" - "osc.testfs-OST0000.max_dirty_mb=16\n" - "obdfilter.testfs-OST0001.client_cache_seconds=15\n" - "osc.testfs-OST0000.failover.node=1.2.3.4@tcp\n\n" - ); - return -EINVAL; - } - - /* e.g. testfs-OST003f-junk.ost.param */ - rc = libcfs_str2server(element[0], &type, &index, &ptr); - if (rc == 0) { - *ptr = '\0'; /* trunc the junk */ - goto out0; - } - /* e.g. ost.testfs-OST003f-junk.param */ - rc = libcfs_str2server(element[1], &type, &index, &ptr); - if (rc == 0) { - *ptr = '\0'; - goto out1; - } - - /* llite.fsname.param or fsname.obd.param */ - if (!element_could_be_obd(element[0]) && - element_could_be_obd(element[1])) - /* fsname-junk.obd.param */ - goto out0; - if (element_could_be_obd(element[0]) && - !element_could_be_obd(element[1])) - /* obd.fsname-junk.param */ - goto out1; - if (!element_could_be_obd(element[0]) && - !element_could_be_obd(element[1])) { - fprintf(stderr, "error: Parameter format is " - "..\n"); - return -EINVAL; - } - /* Either element could be obd. Assume set_param syntax - * (obd.fsname.param) */ - goto out1; - -out0: - dev = 0; - obd = 1; - goto out; -out1: - dev = 1; - obd = 0; -out: - /* Don't worry Mom, we'll check it out */ - if (strncmp(element[2], "failover", 8) != 0) { /* no proc for this */ - char *argt[3]; - - if (strcmp(element[obd], "sys") == 0) - sprintf(buf, "%s", element[2]); - else - sprintf(buf, "%s.%s*.%s", element[obd], element[dev], - element[2]); - argt[1] = "-q"; - argt[2] = buf; - rc = jt_lcfg_listparam(3, argt); - if (rc) - fprintf(stderr, "warning: can't find local param '%s'\n" - "(but that service may not be running locally)." - "\n", buf); - } - - /* s/obdfilter/ost/ */ - if (strcmp(element[obd], "obdfilter") == 0) - sprintf(element[obd], "ost"); - - sprintf(buf, "%s.%s.%s=%s", element[dev], element[obd], - element[2], value + 1); - strcpy(in, buf); - - return 0; -} - /* Param set in config log on MGS */ /* conf_param key=value */ /* Note we can actually send mgc conf_params from clients, but currently @@ -623,7 +503,7 @@ int jt_lcfg_mgsparam(int argc, char **argv) int del = 0; struct lustre_cfg_bufs bufs; struct lustre_cfg *lcfg; - char buf[MGS_PARAM_MAXLEN]; + char *buf = NULL; /* mgs_setparam processes only lctl buf #1 */ if ((argc > 3) || (argc <= 1)) @@ -639,44 +519,32 @@ int jt_lcfg_mgsparam(int argc, char **argv) } } + lustre_cfg_bufs_reset(&bufs, NULL); if (del) { char *ptr; /* for delete, make it "=\0" */ + buf = malloc(strlen(argv[optind]) + 2); /* put an '=' on the end in case it doesn't have one */ sprintf(buf, "%s=", argv[optind]); /* then truncate after the first '=' */ ptr = strchr(buf, '='); *(++ptr) = '\0'; + lustre_cfg_bufs_set_string(&bufs, 1, buf); } else { - sprintf(buf, "%s", argv[optind]); + lustre_cfg_bufs_set_string(&bufs, 1, argv[optind]); } - rc = rearrange_setparam_syntax(buf); - if (rc) - return CMD_HELP; - - lustre_cfg_bufs_reset(&bufs, NULL); - lustre_cfg_bufs_set_string(&bufs, 1, buf); - /* We could put other opcodes here. */ lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); rc = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg); lustre_cfg_free(lcfg); + if (buf) + free(buf); if (rc < 0) { fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), strerror(rc = errno)); - if (rc == ENOENT) { - char *argt[3]; - fprintf(stderr, "Does this filesystem/target exist on " - "the MGS?\n"); - printf("Known targets:\n"); - sprintf(buf, "mgs.MGS.live.*"); - argt[1] = "-n"; - argt[2] = buf; - jt_lcfg_getparam(3, argt); - } } return rc; @@ -794,7 +662,7 @@ static int listparam_cmdline(int argc, char **argv, struct param_opts *popt) popt->show_type = 0; popt->recursive = 0; - while ((ch = getopt(argc, argv, "FRq")) != -1) { + while ((ch = getopt(argc, argv, "FR")) != -1) { switch (ch) { case 'F': popt->show_type = 1; @@ -802,9 +670,6 @@ static int listparam_cmdline(int argc, char **argv, struct param_opts *popt) case 'R': popt->recursive = 1; break; - case 'q': - popt->show_path = 0; - break; default: return -1; } @@ -823,34 +688,31 @@ static int listparam_display(struct param_opts *popt, char *pattern) rc = glob(pattern, GLOB_BRACE | (popt->recursive ? GLOB_MARK : 0), NULL, &glob_info); if (rc) { - if (popt->show_path) /* when quiet, don't show errors */ - fprintf(stderr, "error: list_param: %s: %s\n", - pattern, globerrstr(rc)); + fprintf(stderr, "error: list_param: %s: %s\n", + pattern, globerrstr(rc)); return -ESRCH; } - if (popt->show_path) { - for (i = 0; i < glob_info.gl_pathc; i++) { - char *valuename = NULL; - int last; + for (i = 0; i < glob_info.gl_pathc; i++) { + char *valuename = NULL; + int last; - /* Trailing '/' will indicate recursion into directory */ - last = strlen(glob_info.gl_pathv[i]) - 1; + /* Trailing '/' will indicate recursion into directory */ + last = strlen(glob_info.gl_pathv[i]) - 1; - /* Remove trailing '/' or it will be converted to '.' */ - if (last > 0 && glob_info.gl_pathv[i][last] == '/') - glob_info.gl_pathv[i][last] = '\0'; - else - last = 0; + /* Remove trailing '/' or it will be converted to '.' */ + if (last > 0 && glob_info.gl_pathv[i][last] == '/') + glob_info.gl_pathv[i][last] = '\0'; + else + last = 0; + strcpy(filename, glob_info.gl_pathv[i]); + valuename = display_name(filename, popt->show_type); + if (valuename) + printf("%s\n", valuename); + if (last) { strcpy(filename, glob_info.gl_pathv[i]); - valuename = display_name(filename, popt->show_type); - if (valuename) - printf("%s\n", valuename); - if (last) { - strcpy(filename, glob_info.gl_pathv[i]); - strcat(filename, "/*"); - listparam_display(popt, filename); - } + strcat(filename, "/*"); + listparam_display(popt, filename); } } @@ -972,7 +834,7 @@ static int getparam_display(struct param_opts *popt, char *pattern) break; } /* Print the output in the format path=value if the - * value contains no new line character or can be + * value contains no new line character or cab be * occupied in a line, else print value on new line */ if (valuename && popt->show_path) { int longbuf = strnchr(buf, rc - 1, '\n') != NULL diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index bcdfc29..0e62785 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -883,8 +883,8 @@ int write_local_files(struct mkfs_opts *mop) /* COMPAT_146 */ #ifdef TUNEFS /* Check for upgrade */ - if ((mop->mo_ldd.ldd_flags & (LDD_F_UPGRADE14 | SVTYPE_MGS)) - == (LDD_F_UPGRADE14 | SVTYPE_MGS)) { + if ((mop->mo_ldd.ldd_flags & (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS)) + == (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS)) { char cmd[128]; char *term; int cmdsz = sizeof(cmd); @@ -1042,7 +1042,7 @@ int read_local_files(struct mkfs_opts *mop) if ((lsd.lsd_feature_compat & OBD_COMPAT_OST) || (lsd.lsd_feature_incompat & OBD_INCOMPAT_OST)) { - mop->mo_ldd.ldd_flags = SVTYPE_OST; + mop->mo_ldd.ldd_flags = LDD_F_SV_TYPE_OST; mop->mo_ldd.ldd_svindex = lsd.lsd_ost_index; } else if ((lsd.lsd_feature_compat & OBD_COMPAT_MDT) || (lsd.lsd_feature_incompat & OBD_INCOMPAT_MDT)) { @@ -1050,7 +1050,7 @@ int read_local_files(struct mkfs_opts *mop) If user doesn't want this, they can copy the old logs manually and re-tunefs. */ mop->mo_ldd.ldd_flags = - SVTYPE_MDT | SVTYPE_MGS; + LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_MGS; mop->mo_ldd.ldd_svindex = lsd.lsd_mdt_index; } else { /* If neither is set, we're pre-1.4.6, make a guess. */ @@ -1061,21 +1061,21 @@ int read_local_files(struct mkfs_opts *mop) sprintf(filepnm, "%s/%s", tmpdir, MDT_LOGS_DIR); if (lsd.lsd_ost_index > 0) { - mop->mo_ldd.ldd_flags = SVTYPE_OST; + mop->mo_ldd.ldd_flags = LDD_F_SV_TYPE_OST; mop->mo_ldd.ldd_svindex = lsd.lsd_ost_index; } else { /* If there's a LOGS dir, it's an MDT */ if ((ret = access(filepnm, F_OK)) == 0) { mop->mo_ldd.ldd_flags = - SVTYPE_MDT | - SVTYPE_MGS; + LDD_F_SV_TYPE_MDT | + LDD_F_SV_TYPE_MGS; /* Old MDT's are always index 0 (pre CMD) */ mop->mo_ldd.ldd_svindex = 0; } else { /* The index may not be correct */ mop->mo_ldd.ldd_flags = - SVTYPE_OST | LDD_F_NEED_INDEX; + LDD_F_SV_TYPE_OST | LDD_F_NEED_INDEX; verrprint("OST with unknown index\n"); } } @@ -1286,7 +1286,7 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, break; } case 'G': - mop->mo_ldd.ldd_flags |= SVTYPE_MGS; + mop->mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGS; break; case 'h': usage(stdout); @@ -1348,19 +1348,19 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, break; } case 'M': - mop->mo_ldd.ldd_flags |= SVTYPE_MDT; + mop->mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MDT; break; case 'n': print_only++; break; case 'N': - mop->mo_ldd.ldd_flags &= ~SVTYPE_MGS; + mop->mo_ldd.ldd_flags &= ~LDD_F_SV_TYPE_MGS; break; case 'o': *mountopts = optarg; break; case 'O': - mop->mo_ldd.ldd_flags |= SVTYPE_OST; + mop->mo_ldd.ldd_flags |= LDD_F_SV_TYPE_OST; break; case 'p': rc = add_param(mop->mo_ldd.ldd_params, NULL, optarg); @@ -1593,7 +1593,7 @@ int main(int argc, char *const argv[]) if (IS_MDT(ldd) && !IS_MGS(ldd) && (mop.mo_mgs_failnodes == 0)) { verrprint("No management node specified, adding MGS to this " "MDT\n"); - ldd->ldd_flags |= SVTYPE_MGS; + ldd->ldd_flags |= LDD_F_SV_TYPE_MGS; } if (!IS_MGS(ldd) && (mop.mo_mgs_failnodes == 0)) { fatal();