#include <obd_class.h>
#include <lprocfs_status.h>
+#include <lustre_ioctl.h>
#include <lustre_param.h>
#include "mgs_internal.h"
ENTRY;
+ CFS_FAIL_TIMEOUT(OBD_FAIL_MGS_CONNECT_NET, cfs_fail_val);
rc = tgt_connect(tsi);
if (rc)
RETURN(rc);
lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL);
lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, msp->mgs_param);
lcfg = lustre_cfg_new(LCFG_PARAM, &mgi->mgi_bufs);
+ if (lcfg == NULL)
+ RETURN(-ENOMEM);
rc = mgs_setparam(tsi->tsi_env, exp2mgs_dev(tsi->tsi_exp), lcfg,
mgi->mgi_fsname);
{
ENTRY;
- if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
- LDLM_FL_BLOCK_CONV))) {
+ if (!(flags & LDLM_FL_BLOCKED_MASK)) {
struct fs_db *fsdb;
/* l_ast_data is used as a marker to avoid cancel ldlm lock
logname = req_capsule_client_get(tsi->tsi_pill, &RMF_NAME);
if (logname) {
char *ptr = strchr(logname, '-');
- int len = (int)(ptr - logname);
+ int len = (ptr != NULL) ? (int)(ptr - logname) : 0;
if (ptr == NULL || len >= sizeof(mgi->mgi_fsname)) {
- LCONSOLE_WARN("%s: non-config logname received: %s\n",
- tgt_name(tsi->tsi_tgt), logname);
+ if (strcmp(logname, PARAMS_FILENAME) != 0)
+ LCONSOLE_WARN("%s: non-config logname "
+ "received: %s\n",
+ tgt_name(tsi->tsi_tgt),
+ logname);
/* not error, this can be llog test name */
} else {
strncpy(mgi->mgi_fsname, logname, len);
/* init mgs_export_data for fsc */
spin_lock_init(&data->med_lock);
- CFS_INIT_LIST_HEAD(&data->med_clients);
+ INIT_LIST_HEAD(&data->med_clients);
spin_lock(&exp->exp_lock);
exp->exp_connecting = 1;
lnet_nid_t nid;
const char *nodemap_name = NULL;
const char *nidstr = NULL;
+ const char *client_idstr = NULL;
+ const char *idtype_str = NULL;
char *param = NULL;
+ char fs_idstr[16];
int rc = 0;
+ __u32 client_id;
+ __u32 fs_id;
__u32 cmd;
+ int idtype;
ENTRY;
cmd = lcfg->lcfg_command;
switch (cmd) {
+ case LCFG_NODEMAP_ACTIVATE:
+ if (lcfg->lcfg_bufcount != 2)
+ GOTO(out_lcfg, rc = -EINVAL);
+ param = lustre_cfg_string(lcfg, 1);
+ if (strcmp(param, "1") == 0)
+ nodemap_activate(1);
+ else
+ nodemap_activate(0);
+ break;
case LCFG_NODEMAP_ADD:
case LCFG_NODEMAP_DEL:
if (lcfg->lcfg_bufcount != 2)
strlen(nodemap->nm_name)) != 0)
GOTO(out_lcfg, rc = -EFAULT);
break;
+ case LCFG_NODEMAP_TEST_ID:
+ if (lcfg->lcfg_bufcount != 4)
+ GOTO(out_lcfg, rc = -EINVAL);
+ nidstr = lustre_cfg_string(lcfg, 1);
+ idtype_str = lustre_cfg_string(lcfg, 2);
+ client_idstr = lustre_cfg_string(lcfg, 3);
+
+ nid = libcfs_str2nid(nidstr);
+ nodemap = nodemap_classify_nid(nid);
+ client_id = simple_strtoul(client_idstr, NULL, 10);
+
+ if (strcmp(idtype_str, "uid") == 0)
+ idtype = NODEMAP_UID;
+ else
+ idtype = NODEMAP_GID;
+
+ fs_id = nodemap_map_id(nodemap, idtype, NODEMAP_CLIENT_TO_FS,
+ client_id);
+
+ if (data->ioc_plen1 < sizeof(fs_idstr))
+ GOTO(out_lcfg, rc = -EINVAL);
+
+ snprintf(fs_idstr, sizeof(fs_idstr), "%u", fs_id);
+ if (copy_to_user(data->ioc_pbuf1, fs_idstr,
+ sizeof(fs_idstr)) != 0)
+ GOTO(out_lcfg, rc = -EINVAL);
+ break;
case LCFG_NODEMAP_ADD_RANGE:
case LCFG_NODEMAP_DEL_RANGE:
+ case LCFG_NODEMAP_ADD_UIDMAP:
+ case LCFG_NODEMAP_DEL_UIDMAP:
+ case LCFG_NODEMAP_ADD_GIDMAP:
+ case LCFG_NODEMAP_DEL_GIDMAP:
if (lcfg->lcfg_bufcount != 3)
GOTO(out_lcfg, rc = -EINVAL);
nodemap_name = lustre_cfg_string(lcfg, 1);
param = lustre_cfg_string(lcfg, 3);
rc = mgs_nodemap_cmd(env, mgs, cmd, nodemap_name, param);
break;
-
default:
rc = -ENOTTY;
}
struct obd_device *obd;
struct lustre_mount_info *lmi;
struct llog_ctxt *ctxt;
+ struct fs_db *fsdb = NULL;
int rc;
ENTRY;
GOTO(err_llog, rc);
}
+ /* Setup params fsdb and log, so that other servers can make a local
+ * copy successfully when they are mounted. See LU-4783 */
+ rc = mgs_params_fsdb_setup(env, mgs, fsdb);
+ if (rc)
+ /* params fsdb and log can be setup later */
+ CERROR("%s: %s fsdb and log setup failed: rc = %d\n",
+ obd->obd_name, PARAMS_FILENAME, rc);
+
ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
"mgs_ldlm_client", &obd->obd_ldlm_client);
lu_site_purge(env, mgs2lu_dev(mgs)->ld_site, ~0);
RETURN(0);
err_lproc:
+ mgs_params_fsdb_cleanup(env, mgs);
lproc_mgs_cleanup(mgs);
err_llog:
ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
obd_disconnect(mgs->mgs_bottom_exp);
err_lmi:
if (lmi)
- server_put_mount(lustre_cfg_string(lcfg, 0));
+ server_put_mount(lustre_cfg_string(lcfg, 0), true);
RETURN(rc);
}
obd_zombie_barrier();
tgt_fini(env, &mgs->mgs_lut);
+ mgs_params_fsdb_cleanup(env, mgs);
mgs_cleanup_fsdb_list(mgs);
lproc_mgs_cleanup(mgs);
LASSERT(mgs->mgs_bottom_exp);
obd_disconnect(mgs->mgs_bottom_exp);
- server_put_mount(obd->obd_name);
+ server_put_mount(obd->obd_name, true);
RETURN(NULL);
}
static int __init mgs_init(void)
{
- struct lprocfs_static_vars lvars;
-
- lprocfs_mgs_init_vars(&lvars);
- return class_register_type(&mgs_obd_device_ops, NULL, NULL,
-#ifndef HAVE_ONLY_PROCFS_SEQ
- lvars.module_vars,
-#endif
- LUSTRE_MGS_NAME, &mgs_device_type);
+ return class_register_type(&mgs_obd_device_ops, NULL, true, NULL,
+ LUSTRE_MGS_NAME, &mgs_device_type);
}
static void /*__exit*/ mgs_exit(void)