#define D_MGS D_CONFIG
#include <obd.h>
-#include <obd_lov.h>
#include <lustre_param.h>
#include <lustre_sec.h>
#include <lustre_quota.h>
OBD_ALLOC_PTR(mml);
if (!mml)
GOTO(out_close, rc = -ENOMEM);
- strcpy(mml->mml_marker.cm_comment, comment);
- strcpy(mml->mml_marker.cm_tgtname, devname);
+ if (strlcpy(mml->mml_marker.cm_comment, comment,
+ sizeof(mml->mml_marker.cm_comment)) >=
+ sizeof(mml->mml_marker.cm_comment))
+ GOTO(out_free, rc = -E2BIG);
+ if (strlcpy(mml->mml_marker.cm_tgtname, devname,
+ sizeof(mml->mml_marker.cm_tgtname)) >=
+ sizeof(mml->mml_marker.cm_tgtname))
+ GOTO(out_free, rc = -E2BIG);
/* Modify mostly means cancel */
mml->mml_marker.cm_flags = flags;
mml->mml_marker.cm_canceltime = flags ? cfs_time_current_sec() : 0;
NULL);
if (!rc && !mml->mml_modified)
rc = 1;
+
+out_free:
OBD_FREE_PTR(mml);
out_close:
RETURN(0);
}
+/* This is only called during replace_nids */
static int only_mgs_is_running(struct obd_device *mgs_obd)
{
/* TDB: Is global variable with devices count exists? */
int num_devices = get_devices_count();
+ int num_exports = 0;
+ struct obd_export *exp;
+
+ spin_lock(&mgs_obd->obd_dev_lock);
+ list_for_each_entry(exp, &mgs_obd->obd_exports, exp_obd_chain) {
+ /* skip self export */
+ if (exp == mgs_obd->obd_self_export)
+ continue;
+ if (exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS)
+ continue;
+
+ ++num_exports;
+
+ CERROR("%s: node %s still connected during replace_nids "
+ "connect_flags:%llx\n",
+ mgs_obd->obd_name,
+ libcfs_nid2str(exp->exp_nid_stats->nid),
+ exp_connect_flags(exp));
+
+ }
+ spin_unlock(&mgs_obd->obd_dev_lock);
+
/* osd, MGS and MGC + self_export
- (wc -l /proc/fs/lustre/devices <= 2) && (num_exports <= 2) */
- return (num_devices <= 3) && (mgs_obd->obd_num_exports <= 2);
+ (wc -l /proc/fs/lustre/devices <= 2) && (non self exports == 0) */
+ return (num_devices <= 3) && (num_exports == 0);
}
static int name_create_mdt(char **logname, char *fsname, int i)
if (mgs_log_is_empty(env, mgs, logname)) {
struct llog_handle *llh = NULL;
rc = record_start_log(env, mgs, &llh, logname);
- record_end_log(env, &llh);
+ if (rc == 0)
+ record_end_log(env, &llh);
}
name_destroy(&logname);
if (rc)
/* Defaults. Can be changed later by lcfg config_param */
lovdesc->ld_default_stripe_count = 1;
lovdesc->ld_pattern = LOV_PATTERN_RAID0;
- lovdesc->ld_default_stripe_size = 1024 * 1024;
+ lovdesc->ld_default_stripe_size = LOV_DESC_STRIPE_SIZE_DEFAULT;
lovdesc->ld_default_stripe_offset = -1;
- lovdesc->ld_qos_maxage = QOS_DEFAULT_MAXAGE;
+ lovdesc->ld_qos_maxage = LOV_DESC_QOS_MAXAGE_DEFAULT;
sprintf((char*)lovdesc->ld_uuid.uuid, "%s_UUID", lovname);
/* can these be the same? */
uuid = (char *)lovdesc->ld_uuid.uuid;
failnodeuuid, cliname);
rc = record_add_uuid(env, llh, nid, failnodeuuid);
}
- if (failnodeuuid)
+ if (failnodeuuid) {
rc = record_add_conn(env, llh, cliname, failnodeuuid);
+ name_destroy(&failnodeuuid);
+ failnodeuuid = NULL;
+ }
}
- name_destroy(&failnodeuuid);
return rc;
}
GOTO(end, rc);
}
- /* 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);
+ /* All mdd., ost. and osd. params in proc */
+ if ((class_match_param(ptr, PARAM_MDD, NULL) == 0) ||
+ (class_match_param(ptr, PARAM_OST, NULL) == 0) ||
+ (class_match_param(ptr, PARAM_OSD, NULL) == 0)) {
+ CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4);
if (mgs_log_is_empty(env, mgs, mti->mti_svname))
- GOTO(end, rc = -ENODEV);
+ GOTO(end, rc = -ENODEV);
rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, mti->mti_svname,
&mgi->mgi_bufs, mti->mti_svname, ptr);
- GOTO(end, rc);
- }
+ GOTO(end, rc);
+ }
LCONSOLE_WARN("Ignoring unrecognized param '%s'\n", ptr);
rc2 = -ENOSYS;
RETURN(rc);
}
+/* list all logs for the given fs */
+int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs,
+ struct obd_ioctl_data *data)
+{
+ cfs_list_t list;
+ struct mgs_direntry *dirent, *n;
+ char *out, *suffix;
+ int l, remains, rc;
+
+ ENTRY;
+
+ /* Find all the logs in the CONFIGS directory */
+ rc = class_dentry_readdir(env, mgs, &list);
+ if (rc) {
+ CERROR("%s: can't read %s dir = %d\n",
+ mgs->mgs_obd->obd_name, MOUNT_CONFIGS_DIR, rc);
+ RETURN(rc);
+ }
+
+ out = data->ioc_bulk;
+ remains = data->ioc_inllen1;
+ cfs_list_for_each_entry_safe(dirent, n, &list, list) {
+ cfs_list_del(&dirent->list);
+ suffix = strrchr(dirent->name, '-');
+ if (suffix != NULL) {
+ l = snprintf(out, remains, "config log: $%s\n",
+ dirent->name);
+ out += l;
+ remains -= l;
+ }
+ mgs_direntry_free(dirent);
+ if (remains <= 0)
+ break;
+ }
+ RETURN(rc);
+}
+
/* from llog_swab */
static void print_lustre_cfg(struct lustre_cfg *lcfg)
{
if (rc == 0 && !mgs_parse_devname(devname, NULL, &index)) {
/* param related to llite isn't allowed to set by OST or MDT */
if (rc == 0 && strncmp(param, PARAM_LLITE,
- sizeof(PARAM_LLITE)) == 0)
+ sizeof(PARAM_LLITE) - 1) == 0)
RETURN(-EINVAL);
} else {
/* assume devname is the fsname */
return rc;
}
+int mgs_nodemap_cmd(const struct lu_env *env, struct mgs_device *mgs,
+ enum lcfg_command_type cmd, const char *nodemap_name,
+ const char *param)
+{
+ lnet_nid_t nid[2];
+ __u32 idmap[2];
+ bool bool_switch;
+ __u32 int_id;
+ int rc = 0;
+ ENTRY;
+
+ switch (cmd) {
+ case LCFG_NODEMAP_ADD:
+ rc = nodemap_add(nodemap_name);
+ break;
+ case LCFG_NODEMAP_DEL:
+ rc = nodemap_del(nodemap_name);
+ break;
+ case LCFG_NODEMAP_ADD_RANGE:
+ rc = nodemap_parse_range(param, nid);
+ if (rc != 0)
+ break;
+ rc = nodemap_add_range(nodemap_name, nid);
+ break;
+ case LCFG_NODEMAP_DEL_RANGE:
+ rc = nodemap_parse_range(param, nid);
+ if (rc != 0)
+ break;
+ rc = nodemap_del_range(nodemap_name, nid);
+ break;
+ case LCFG_NODEMAP_ADMIN:
+ bool_switch = simple_strtoul(param, NULL, 10);
+ rc = nodemap_set_allow_root(nodemap_name, bool_switch);
+ break;
+ case LCFG_NODEMAP_TRUSTED:
+ bool_switch = simple_strtoul(param, NULL, 10);
+ rc = nodemap_set_trust_client_ids(nodemap_name, bool_switch);
+ break;
+ case LCFG_NODEMAP_SQUASH_UID:
+ int_id = simple_strtoul(param, NULL, 10);
+ rc = nodemap_set_squash_uid(nodemap_name, int_id);
+ break;
+ case LCFG_NODEMAP_SQUASH_GID:
+ int_id = simple_strtoul(param, NULL, 10);
+ rc = nodemap_set_squash_gid(nodemap_name, int_id);
+ break;
+ case LCFG_NODEMAP_ADD_UIDMAP:
+ case LCFG_NODEMAP_ADD_GIDMAP:
+ rc = nodemap_parse_idmap(param, idmap);
+ if (rc != 0)
+ break;
+ if (cmd == LCFG_NODEMAP_ADD_UIDMAP)
+ rc = nodemap_add_idmap(nodemap_name, NODEMAP_UID,
+ idmap);
+ else
+ rc = nodemap_add_idmap(nodemap_name, NODEMAP_GID,
+ idmap);
+ break;
+ case LCFG_NODEMAP_DEL_UIDMAP:
+ case LCFG_NODEMAP_DEL_GIDMAP:
+ rc = nodemap_parse_idmap(param, idmap);
+ if (rc != 0)
+ break;
+ if (cmd == LCFG_NODEMAP_DEL_UIDMAP)
+ rc = nodemap_del_idmap(nodemap_name, NODEMAP_UID,
+ idmap);
+ else
+ rc = nodemap_del_idmap(nodemap_name, NODEMAP_GID,
+ idmap);
+ break;
+ default:
+ rc = -EINVAL;
+ }
+
+ RETURN(rc);
+}
+
int mgs_pool_cmd(const struct lu_env *env, struct mgs_device *mgs,
enum lcfg_command_type cmd, char *fsname,
char *poolname, char *ostname)