#define EXPORT_SYMTAB
#endif
#define DEBUG_SUBSYSTEM S_MGS
-#define D_MGS D_CONFIG /*|D_WARNING*/
+#define D_MGS D_CONFIG
#ifdef __KERNEL__
#include <linux/module.h>
int rc, rc2;
ENTRY;
- CDEBUG(D_MGS, "modify %s/%s/%s\n", logname, devname, comment);
+ CDEBUG(D_MGS, "modify %s/%s/%s fl=%x\n", logname, devname, comment,
+ flags);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
mgs_modify(obd, fsdb, mti, dirent->lld_name, devname,
comment, CM_SKIP);
/* Write the new one */
- rc = mgs_write_log_direct(obd, fsdb, dirent->lld_name,
- lcfg, devname, comment);
- if (rc)
- CERROR("err %d writing log %s\n", rc,
- dirent->lld_name);
+ if (lcfg) {
+ rc = mgs_write_log_direct(obd, fsdb,
+ dirent->lld_name,
+ lcfg, devname,
+ comment);
+ if (rc)
+ CERROR("err %d writing log %s\n", rc,
+ dirent->lld_name);
+ }
}
OBD_FREE(dirent, sizeof(*dirent));
}
RETURN(rc);
}
+static __inline__ int mgs_param_empty(char *ptr)
+{
+ char *tmp;
+
+ if ((tmp = strchr(ptr, '=')) && (*(++tmp) == '\0'))
+ return 1;
+ return 0;
+}
+
+static int mgs_write_log_failnid_internal(struct obd_device *obd,
+ struct fs_db *fsdb,
+ struct mgs_target_info *mti,
+ char *logname, char *cliname)
+{
+ int rc;
+ struct llog_handle *llh = NULL;
+
+ if (mgs_param_empty(mti->mti_params)) {
+ /* Remove _all_ failnids */
+ rc = mgs_modify(obd, fsdb, mti, logname,
+ mti->mti_svname, "add failnid", CM_SKIP);
+ return rc;
+ }
+
+ /* Otherwise failover nids are additive */
+ rc = record_start_log(obd, &llh, logname);
+ if (!rc) {
+ /* FIXME this should be a single journal transaction */
+ rc = record_marker(obd, llh, fsdb, CM_START,
+ mti->mti_svname, "add failnid");
+ rc = mgs_write_log_failnids(obd, mti, llh, cliname);
+ rc = record_marker(obd, llh, fsdb, CM_END,
+ mti->mti_svname, "add failnid");
+ rc = record_end_log(obd, &llh);
+ }
+
+ return rc;
+}
+
+
/* Add additional failnids to an existing log.
The mdc/osc must have been added to logs first */
/* tcp nids must be in dotted-quad ascii -
struct mgs_target_info *mti)
{
char *logname, *cliname;
- struct llog_handle *llh = NULL;
int rc;
ENTRY;
- /* FIXME how do we delete a failnid? Currently --writeconf is the
- only way. Maybe make --erase-params pass a flag to really
- erase all params from logs - except it can't erase the failnids
- given when a target first registers, since they aren't processed
- as params... */
+ /* FIXME we currently can't erase the failnids
+ * given when a target first registers, since they aren't part of
+ * an "add uuid" stanza */
/* Verify that we know about this target */
if (mgs_log_is_empty(obd, mti->mti_svname)) {
RETURN(-EINVAL);
}
- /* Add failover nids to client log */
+ /* Add failover nids to the client log */
name_create(&logname, mti->mti_fsname, "-client");
- rc = record_start_log(obd, &llh, logname);
- if (!rc) {
- /* FIXME this fn should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,
- "add failnid");
- rc = mgs_write_log_failnids(obd, mti, llh, cliname);
- rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname,
- "add failnid");
- rc = record_end_log(obd, &llh);
- }
+ rc = mgs_write_log_failnid_internal(obd, fsdb, mti, logname, cliname);
name_destroy(&logname);
name_destroy(&cliname);
continue;
name_create_mdt(&logname, mti->mti_fsname, i);
name_create_mdt_osc(&cliname, mti->mti_svname, fsdb, i);
-
- rc = record_start_log(obd, &llh, logname);
- if (!rc) {
- rc = record_marker(obd, llh, fsdb, CM_START,
- mti->mti_svname,
- "add failnid");
- rc = mgs_write_log_failnids(obd, mti, llh,
- cliname);
- rc = record_marker(obd, llh, fsdb, CM_END,
- mti->mti_svname,
- "add failnid");
- rc = record_end_log(obd, &llh);
- }
+ rc = mgs_write_log_failnid_internal(obd, fsdb, mti,
+ logname, cliname);
name_destroy(&cliname);
name_destroy(&logname);
}
char comment[MTI_NAME_MAXLEN];
char *tmp;
struct lustre_cfg *lcfg;
- int rc;
+ int rc, del;
/* Erase any old settings of this same parameter */
memcpy(comment, ptr, MTI_NAME_MAXLEN);
*tmp = 0;
/* FIXME we should skip settings that are the same as old values */
rc = mgs_modify(obd, fsdb, mti, logname, tgtname, comment, CM_SKIP);
- LCONSOLE_INFO("%sing parameter %s.%s in log %s\n", rc ?
+ del = mgs_param_empty(ptr);
+
+ LCONSOLE_INFO("%sing parameter %s.%s in log %s\n", del ? "Disabl" : rc ?
"Sett" : "Modify", tgtname, comment, logname);
+ if (del)
+ return rc;
lustre_cfg_bufs_reset(bufs, tgtname);
lustre_cfg_bufs_set_string(bufs, 1, ptr);
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
char *tmp;
+ char sep;
int cmd, val;
int rc;
else
return -EINVAL;
+ /* separate the value */
val = simple_strtoul(tmp, NULL, 0);
- CDEBUG(D_MGS, "global %s = %d\n", ptr, val);
+ if (*tmp == '\0')
+ CDEBUG(D_MGS, "global '%s' removed\n", sys);
+ else
+ CDEBUG(D_MGS, "global '%s' val=%d\n", sys, val);
lustre_cfg_bufs_reset(&bufs, NULL);
lustre_cfg_bufs_set_string(&bufs, 1, sys);
lcfg = lustre_cfg_new(cmd, &bufs);
lcfg->lcfg_num = val;
+ /* truncate the comment to the parameter name */
+ ptr = tmp - 1;
+ sep = *ptr;
+ *ptr = '\0';
/* modify all servers and clients */
- rc = mgs_write_log_direct_all(obd, fsdb, mti, lcfg, mti->mti_fsname,
- ptr);
+ rc = mgs_write_log_direct_all(obd, fsdb, mti,
+ *tmp == '\0' ? NULL : lcfg,
+ mti->mti_fsname, sys);
+ *ptr = sep;
lustre_cfg_free(lcfg);
return rc;
}
/* obsolete old one */
mgs_modify(obd, fsdb, mti, logname, mti->mti_svname, comment, CM_SKIP);
- /* write the new one */
- rc = mgs_write_log_direct(obd, fsdb, logname, lcfg,
- mti->mti_svname, comment);
- if (rc)
- CERROR("err %d writing log %s\n", rc, logname);
-
+ if (!mgs_param_empty(param)) {
+ /* write the new one */
+ rc = mgs_write_log_direct(obd, fsdb, logname, lcfg,
+ mti->mti_svname, comment);
+ if (rc)
+ CERROR("err %d writing log %s\n", rc, logname);
+ }
out:
name_destroy(&logname);
out_lcfg:
char *param)
{
char *copy;
- int rc, copy_size;
+ int rc, copy_size, del;
ENTRY;
#ifndef HAVE_GSS
return -ENOMEM;
memcpy(copy, param, copy_size);
- rc = mgs_srpc_set_param_mem(fsdb, mti->mti_svname, param);
- if (rc)
- goto out_free;
+ del = mgs_param_empty(param);
+ if (!del) {
+ rc = mgs_srpc_set_param_mem(fsdb, mti->mti_svname, param);
+ if (rc)
+ goto out_free;
+ }
/* previous steps guaranteed the syntax is correct */
rc = mgs_srpc_set_param_disk(obd, fsdb, mti, copy);
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.
+ */
static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb,
struct mgs_target_info *mti, char *ptr)
{
EXIT;
}
-/* Set a permanent (config log) param for a target or fs */
+/* Set a permanent (config log) param for a target or fs
+ * \param lcfg buf0 may contain the device (testfs-MDT0000) name
+ * buf1 contains the single parameter
+ */
int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
{
struct fs_db *fsdb;
strncpy(fsname, devname, MTI_NAME_MAXLEN);
}
fsname[MTI_NAME_MAXLEN - 1] = 0;
- CDEBUG(D_MGS, "setparam on fs %s device %s\n", fsname, devname);
+ CDEBUG(D_MGS, "setparam fs='%s' device='%s'\n", fsname, devname);
rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
if (rc)
mti->mti_flags = rc | LDD_F_PARAM;
cfs_down(&fsdb->fsdb_sem);
- /* this is lctl conf_param's single param path, there is not
- need to loop through parameters */
rc = mgs_write_log_param(obd, fsdb, mti, mti->mti_params);
cfs_up(&fsdb->fsdb_sem);