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);
/* max value for numeric network address */
#define MAX_NUMERIC_VALUE 0xffffffff
-
/* implication */
#define ergo(a, b) (!(a) || (b))
/* logical equivalence */
# 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.
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
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);
.br
20
.TP
-.BI conf_param " [-d] <obd>.<device|fsname>.<parameter>=<value>"
+.BI conf_param " [-d] <device|fsname>.<parameter>=<value>"
Set a permanent configuration parameter for any device via the MGS. This
command must be run on the MGS node.
.br
-.B -d <obd>.<device|fsname>.<param>
+.B -d <device|fsname>.<parameter>
Delete a parameter setting (use the default value at the next restart). A null value for <value> also deletes the parameter setting.
.br
.B Parameters:
.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.) <device> 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
/****************** 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 */
__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_* */
/*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);
return 0;
}
+/* Get the index from the obd name */
+int server_name2index(char *svname, __u32 *idx, char **endptr);
+
/****************** mount command *********************/
struct lov_desc *desc;
__u64 val;
int rc;
-
+
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
rc = lprocfs_write_u64_helper(buffer, count, &val);
struct lov_desc *desc;
__u64 val;
int rc;
-
+
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
rc = lprocfs_write_u64_helper(buffer, count, &val);
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);
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);
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)
{
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,
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;
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,
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;
}
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");
}
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 "
"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",
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 */
/* 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;
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);
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"
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 ++;
}
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,
}
/* 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);
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;
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,
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 ("<param>='\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)
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
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);
}
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",
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",
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 "
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++){
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);
}
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 "
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 "
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);
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 */
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);
/* 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);
}
#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);
#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);
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 <fsname>-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 */
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);
{
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.
/* 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);
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);
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"}
# 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\"!"
}
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
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)"
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
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)
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
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."
sleep 1
cleanup
}
-run_test 34a "umount with opened file should fail"
+run_test 34a "umount with opened file should be fail"
test_34b() {
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
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
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
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"
#
#
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)
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)
# 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
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))
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
[ -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
}
{"set_timeout", jt_lcfg_set_timeout, 0,
"usage: conf_param obd_timeout=<secs>\n"},
{"conf_param", jt_lcfg_mgsparam, 0,"set a permanent config parameter.\n"
- "usage: conf_param [-d] <obd>.<devname>.<param>=<val>\n"
+ "This command must be run on the MGS node\n"
+ "usage: conf_param [-d] <target.keyword=val>\n"
" -d Remove the permanent setting."},
{"local_param", jt_lcfg_param, 0, "set a temporary, local param\n"
"usage: local_param <target.keyword=val>\n"},
"usage: get_param [-n|-N|-F] <param_path1 param_path2 ...>\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."},
"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"},
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)
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 "
- "<obd>.<fsname|devname>.<param>.\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 "
- "<obd>.<fsname|devname>.<param>\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
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))
}
}
+ lustre_cfg_bufs_reset(&bufs, NULL);
if (del) {
char *ptr;
/* for delete, make it "<param>=\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;
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;
case 'R':
popt->recursive = 1;
break;
- case 'q':
- popt->show_path = 0;
- break;
default:
return -1;
}
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);
}
}
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
/* 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);
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)) {
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. */
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");
}
}
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);
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);
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();