#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>
/* Caller must list_del and OBD_FREE each dentry from the list */
int class_dentry_readdir(struct obd_device *obd, struct dentry *dir,
struct vfsmount *inmnt,
- struct list_head *dentry_list){
+ cfs_list_t *dentry_list){
/* see mds_cleanup_pending */
struct lvfs_run_ctxt saved;
struct file *file;
CDEBUG(D_MGS, "OST index for %s is %u (%s)\n",
lustre_cfg_string(lcfg, 1), index,
lustre_cfg_string(lcfg, 2));
- set_bit(index, fsdb->fsdb_ost_index_map);
+ cfs_set_bit(index, fsdb->fsdb_ost_index_map);
}
/* Figure out mdt indicies */
}
rc = 0;
CDEBUG(D_MGS, "MDT index is %u\n", index);
- set_bit(index, fsdb->fsdb_mdt_index_map);
+ cfs_set_bit(index, fsdb->fsdb_mdt_index_map);
}
/* COMPAT_146 */
ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
name_create(&logname, fsdb->fsdb_name, "-client");
- down(&fsdb->fsdb_sem);
+ cfs_down(&fsdb->fsdb_sem);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
rc = llog_create(ctxt, &loghandle, NULL, logname);
if (rc)
rc = rc2;
out_pop:
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- up(&fsdb->fsdb_sem);
+ cfs_up(&fsdb->fsdb_sem);
name_destroy(&logname);
llog_ctxt_put(ctxt);
{
struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
- struct list_head *tmp;
+ cfs_list_t *tmp;
- list_for_each(tmp, &mgs->mgs_fs_db_list) {
- fsdb = list_entry(tmp, struct fs_db, fsdb_list);
+ cfs_list_for_each(tmp, &mgs->mgs_fs_db_list) {
+ fsdb = cfs_list_entry(tmp, struct fs_db, fsdb_list);
if (strcmp(fsdb->fsdb_name, fsname) == 0)
return fsdb;
}
RETURN(NULL);
strcpy(fsdb->fsdb_name, fsname);
- sema_init(&fsdb->fsdb_sem, 1);
+ cfs_sema_init(&fsdb->fsdb_sem, 1);
fsdb->fsdb_fl_udesc = 1;
if (strcmp(fsname, MGSSELF_NAME) == 0) {
lproc_mgs_add_live(obd, fsdb);
}
- list_add(&fsdb->fsdb_list, &mgs->mgs_fs_db_list);
+ cfs_list_add(&fsdb->fsdb_list, &mgs->mgs_fs_db_list);
RETURN(fsdb);
err:
static void mgs_free_fsdb(struct obd_device *obd, struct fs_db *fsdb)
{
/* wait for anyone with the sem */
- down(&fsdb->fsdb_sem);
+ cfs_down(&fsdb->fsdb_sem);
lproc_mgs_del_live(obd, fsdb);
- list_del(&fsdb->fsdb_list);
+ cfs_list_del(&fsdb->fsdb_list);
if (fsdb->fsdb_ost_index_map)
OBD_FREE(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
if (fsdb->fsdb_mdt_index_map)
{
struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
- struct list_head *tmp, *tmp2;
- down(&mgs->mgs_sem);
- list_for_each_safe(tmp, tmp2, &mgs->mgs_fs_db_list) {
- fsdb = list_entry(tmp, struct fs_db, fsdb_list);
+ cfs_list_t *tmp, *tmp2;
+ cfs_down(&mgs->mgs_sem);
+ cfs_list_for_each_safe(tmp, tmp2, &mgs->mgs_fs_db_list) {
+ fsdb = cfs_list_entry(tmp, struct fs_db, fsdb_list);
mgs_free_fsdb(obd, fsdb);
}
- up(&mgs->mgs_sem);
+ cfs_up(&mgs->mgs_sem);
return 0;
}
struct fs_db *fsdb;
int rc = 0;
- down(&mgs->mgs_sem);
+ cfs_down(&mgs->mgs_sem);
fsdb = mgs_find_fsdb(obd, name);
if (fsdb) {
- up(&mgs->mgs_sem);
+ cfs_up(&mgs->mgs_sem);
*dbh = fsdb;
return 0;
}
CDEBUG(D_MGS, "Creating new db\n");
fsdb = mgs_new_fsdb(obd, name);
- up(&mgs->mgs_sem);
+ cfs_up(&mgs->mgs_sem);
if (!fsdb)
return -ENOMEM;
else
RETURN(-EINVAL);
- if (test_bit(mti->mti_stripe_index, imap))
+ if (cfs_test_bit(mti->mti_stripe_index, imap))
RETURN(1);
RETURN(0);
}
{
int i;
for (i = 0; i < map_len * 8; i++)
- if (!test_bit(i, index_map)) {
+ if (!cfs_test_bit(i, index_map)) {
return i;
}
CERROR("max index %d exceeded.\n", i);
RETURN(-ERANGE);
}
- if (test_bit(mti->mti_stripe_index, imap)) {
+ if (cfs_test_bit(mti->mti_stripe_index, imap)) {
if ((mti->mti_flags & LDD_F_VIRGIN) &&
!(mti->mti_flags & LDD_F_WRITECONF)) {
LCONSOLE_ERROR_MSG(0x140, "Server %s requested index "
}
}
- set_bit(mti->mti_stripe_index, imap);
+ cfs_set_bit(mti->mti_stripe_index, imap);
fsdb->fsdb_flags &= ~FSDB_LOG_EMPTY;
server_make_name(mti->mti_flags, mti->mti_stripe_index,
mti->mti_fsname, mti->mti_svname);
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);
char *devname, char *comment)
{
struct mgs_obd *mgs = &obd->u.mgs;
- struct list_head dentry_list;
+ cfs_list_t dentry_list;
struct l_linux_dirent *dirent, *n;
char *fsname = mti->mti_fsname;
char *logname;
}
/* Could use fsdb index maps instead of directory listing */
- list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
- list_del(&dirent->lld_list);
+ cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
+ cfs_list_del(&dirent->lld_list);
/* don't write to sptlrpc rule log */
if (strncmp(fsname, dirent->lld_name, len) == 0 &&
strstr(dirent->lld_name, "-sptlrpc") == 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));
}
for (i = 0; i < INDEX_MAP_SIZE * 8; i++){
char *mdtname;
if (i != mti->mti_stripe_index &&
- test_bit(i, fsdb->fsdb_mdt_index_map)) {
+ cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
name_create_mdt(&mdtname, mti->mti_fsname, i);
rc = mgs_write_log_mdc_to_mdt(obd, fsdb, mti, mdtname);
name_destroy(&mdtname);
/* Add ost to all MDT lov defs */
for (i = 0; i < INDEX_MAP_SIZE * 8; i++){
- if (test_bit(i, fsdb->fsdb_mdt_index_map)) {
+ if (cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
char mdt_index[9];
name_create_mdt_and_lov(&logname, &lovname, fsdb, i);
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);
int i;
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
- if (!test_bit(i, fsdb->fsdb_mdt_index_map))
+ if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
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)
{
/* Modify mdtlov */
/* Add to all MDT logs for CMD */
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
- if (!test_bit(i, fsdb->fsdb_mdt_index_map))
+ if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
name_create_mdt(&logname, mti->mti_fsname, i);
rc = mgs_modify(obd, fsdb, mti, logname,
int i;
for (i = 0; i < INDEX_MAP_SIZE * 8; i++){
- if (!test_bit(i, fsdb->fsdb_mdt_index_map))
+ if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
name_destroy(&cname);
name_create_mdt_osc(&cname, mti->mti_svname,
goto active_err;
if (rc & LDD_F_SV_ALL) {
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
- if (!test_bit(i,
- fsdb->fsdb_mdt_index_map))
+ 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,
the failover list. Modify mti->params for rewriting back at
server_register_target(). */
- down(&fsdb->fsdb_sem);
+ cfs_down(&fsdb->fsdb_sem);
rc = mgs_write_log_add_failnid(obd, fsdb, mti);
- up(&fsdb->fsdb_sem);
+ cfs_up(&fsdb->fsdb_sem);
RETURN(rc);
#endif
}
int mgs_write_log_target(struct obd_device *obd,
- struct mgs_target_info *mti)
+ struct mgs_target_info *mti,
+ struct fs_db *fsdb)
{
- struct fs_db *fsdb;
int rc = -EINVAL;
char *buf, *params;
ENTRY;
}
}
- rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
- if (rc) {
- CERROR("Can't get db for %s\n", mti->mti_fsname);
- RETURN(rc);
- }
-
- down(&fsdb->fsdb_sem);
+ cfs_down(&fsdb->fsdb_sem);
if (mti->mti_flags &
(LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
OBD_FREE(buf, strlen(mti->mti_params) + 1);
out_up:
- up(&fsdb->fsdb_sem);
+ cfs_up(&fsdb->fsdb_sem);
RETURN(rc);
}
/* COMPAT_146 */
/* verify that we can handle the old config logs */
-int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti)
+int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti,
+ struct fs_db *fsdb)
{
- struct fs_db *fsdb;
int rc = 0;
ENTRY;
LCONSOLE_INFO("upgrading server %s from pre-1.6\n", mti->mti_svname);
server_mti_print("upgrade", mti);
- rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
- if (rc)
- RETURN(rc);
-
if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
LCONSOLE_ERROR_MSG(0x14a, "The old client log %s-client is "
"missing. Was tunefs.lustre successful?\n",
{
struct mgs_obd *mgs = &obd->u.mgs;
static struct fs_db *fsdb;
- struct list_head dentry_list;
+ cfs_list_t dentry_list;
struct l_linux_dirent *dirent, *n;
int rc, len = strlen(fsname);
+ char *suffix;
ENTRY;
/* Find all the logs in the CONFIGS directory */
RETURN(rc);
}
- down(&mgs->mgs_sem);
+ cfs_down(&mgs->mgs_sem);
/* Delete the fs db */
fsdb = mgs_find_fsdb(obd, fsname);
if (fsdb)
mgs_free_fsdb(obd, fsdb);
- list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
- list_del(&dirent->lld_list);
- if (strncmp(fsname, dirent->lld_name, len) == 0) {
- CDEBUG(D_MGS, "Removing log %s\n", dirent->lld_name);
- mgs_erase_log(obd, dirent->lld_name);
+ cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
+ cfs_list_del(&dirent->lld_list);
+ suffix = strrchr(dirent->lld_name, '-');
+ if (suffix != NULL) {
+ if ((len == suffix - dirent->lld_name) &&
+ (strncmp(fsname, dirent->lld_name, len) == 0)) {
+ CDEBUG(D_MGS, "Removing log %s\n",
+ dirent->lld_name);
+ mgs_erase_log(obd, dirent->lld_name);
+ }
}
OBD_FREE(dirent, sizeof(*dirent));
}
- up(&mgs->mgs_sem);
+ cfs_up(&mgs->mgs_sem);
RETURN(rc);
}
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;
- down(&fsdb->fsdb_sem);
- /* this is lctl conf_param's single param path, there is not
- need to loop through parameters */
+ cfs_down(&fsdb->fsdb_sem);
rc = mgs_write_log_param(obd, fsdb, mti, mti->mti_params);
- up(&fsdb->fsdb_sem);
+ cfs_up(&fsdb->fsdb_sem);
+ /*
+ * Revoke lock so everyone updates. Should be alright if
+ * someone was already reading while we were updating the logs,
+ * so we don't really need to hold the lock while we're
+ * writing (above).
+ */
+ mgs_revoke_lock(obd, fsdb);
out:
OBD_FREE_PTR(mti);
RETURN(rc);
}
}
- down(&fsdb->fsdb_sem);
+ cfs_down(&fsdb->fsdb_sem);
if (canceled_label != NULL) {
OBD_ALLOC_PTR(mti);
/* write pool def to all MDT logs */
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
- if (test_bit(i, fsdb->fsdb_mdt_index_map)) {
+ if (cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
name_create_mdt_and_lov(&logname, &lovname, fsdb, i);
if (canceled_label != NULL) {
cmd, fsname, poolname, ostname, label);
name_destroy(&logname);
- up(&fsdb->fsdb_sem);
+ cfs_up(&fsdb->fsdb_sem);
+ /* request for update */
+ mgs_revoke_lock(obd, fsdb);
EXIT;
out: