X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmgs%2Fmgs_llog.c;h=820acba1824b7f24d1d75aeebf9f401f5317dc87;hp=3bfd6a87813e922578577b441a9012f9d7c88ab2;hb=a8daf3e7b31a44f0b76a406661d59075f11c5bbe;hpb=5bb4d552208b350d6dd7996d75db7e63ec61d898 diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 3bfd6a8..820acba 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -46,7 +46,6 @@ #define D_MGS D_CONFIG #include -#include #include #include #include @@ -696,11 +695,11 @@ static int mgs_modify(const struct lu_env *env, struct mgs_device *mgs, if (strlcpy(mml->mml_marker.cm_comment, comment, sizeof(mml->mml_marker.cm_comment)) >= sizeof(mml->mml_marker.cm_comment)) - GOTO(out_close, rc = -E2BIG); + 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_close, rc = -E2BIG); + 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; @@ -709,6 +708,8 @@ static int mgs_modify(const struct lu_env *env, struct mgs_device *mgs, NULL); if (!rc && !mml->mml_modified) rc = 1; + +out_free: OBD_FREE_PTR(mml); out_close: @@ -1169,13 +1170,36 @@ static int mgs_parse_devname(char *devname, char *fsname, __u32 *index) 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) @@ -1852,9 +1876,9 @@ static int mgs_write_log_lov(const struct lu_env *env, struct mgs_device *mgs, /* 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; @@ -1921,11 +1945,13 @@ static int mgs_write_log_failnids(const struct lu_env *env, 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; } @@ -3487,17 +3513,18 @@ static int mgs_write_log_param(const struct lu_env *env, 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; @@ -3789,7 +3816,7 @@ int mgs_setparam(const struct lu_env *env, struct mgs_device *mgs, 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 */ @@ -3887,6 +3914,83 @@ out: 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)