# 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>
/* Internal mgs setup */
mgs_init_fsdb_list(obd);
- sema_init(&mgs->mgs_sem, 1);
+ cfs_sema_init(&mgs->mgs_sem, 1);
/* Setup proc */
lprocfs_mgs_init_vars(&lvars);
- if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0)
+ if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
lproc_mgs_setup(obd);
+ rc = lprocfs_alloc_md_stats(obd, LPROC_MGS_LAST);
+ if (rc)
+ GOTO(err_llog, rc);
+ }
/* Start the service threads */
mgs->mgs_service =
RETURN(0);
}
-static void mgs_revoke_lock(struct obd_device *obd, char *fsname,
- struct lustre_handle *lockh)
+void mgs_revoke_lock(struct obd_device *obd, struct fs_db *fsdb)
{
- int lockrc;
+ struct lustre_handle lockh;
+ int lockrc;
+
+ LASSERT(fsdb->fsdb_name[0] != '\0');
+
+ if (cfs_test_and_set_bit(1, &fsdb->fsdb_revoking_lock) == 0) {
+ lockrc = mgs_get_cfg_lock(obd, fsdb->fsdb_name, &lockh);
+ /* clear the bit before lock put */
+ cfs_clear_bit(1, &fsdb->fsdb_revoking_lock);
- if (fsname[0]) {
- lockrc = mgs_get_cfg_lock(obd, fsname, lockh);
if (lockrc != ELDLM_OK)
- CERROR("lock error %d for fs %s\n", lockrc,
- fsname);
+ CERROR("lock error %d for fs %s\n",
+ lockrc, fsdb->fsdb_name);
else
- mgs_put_cfg_lock(lockh);
+ mgs_put_cfg_lock(&lockh);
}
}
static int mgs_handle_target_reg(struct ptlrpc_request *req)
{
struct obd_device *obd = req->rq_export->exp_obd;
- struct lustre_handle lockh;
struct mgs_target_info *mti, *rep_mti;
- int rc = 0, lockrc;
+ struct fs_db *fsdb;
+ int rc = 0;
ENTRY;
mgs_counter_incr(req->rq_export, LPROC_MGS_TARGET_REG);
GOTO(out_nolock, rc);
}
- /* Revoke the config lock to make sure nobody is reading. */
- /* Although actually I think it should be alright if
- someone was reading while we were updating the logs - if we
- revoke at the end they will just update from where they left off. */
- lockrc = mgs_get_cfg_lock(obd, mti->mti_fsname, &lockh);
- if (lockrc != ELDLM_OK) {
- LCONSOLE_ERROR_MSG(0x13d, "%s: Can't signal other nodes to "
- "update their configuration (%d). Updating "
- "local logs anyhow; you might have to "
- "manually restart other nodes to get the "
- "latest configuration.\n",
- obd->obd_name, lockrc);
- }
-
OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_PAUSE_TARGET_REG, 10);
- /* Log writing contention is handled by the fsdb_sem */
-
if (mti->mti_flags & LDD_F_WRITECONF) {
if (mti->mti_flags & LDD_F_SV_TYPE_MDT &&
mti->mti_stripe_index == 0) {
mti->mti_flags &= ~LDD_F_UPGRADE14;
}
+ rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+ if (rc) {
+ CERROR("Can't get db for %s: %d\n", mti->mti_fsname, rc);
+ GOTO(out_nolock, rc);
+ }
+
+ /*
+ * Log writing contention is handled by the fsdb_sem.
+ *
+ * It should be alright if someone was reading while we were
+ * updating the logs - if we revoke at the end they will just update
+ * from where they left off.
+ */
+
/* COMPAT_146 */
if (mti->mti_flags & LDD_F_UPGRADE14) {
- rc = mgs_upgrade_sv_14(obd, mti);
+ rc = mgs_upgrade_sv_14(obd, mti, fsdb);
if (rc) {
CERROR("Can't upgrade from 1.4 (%d)\n", rc);
GOTO(out, rc);
/* create or update the target log
and update the client/mdt logs */
- rc = mgs_write_log_target(obd, mti);
+ rc = mgs_write_log_target(obd, mti, fsdb);
if (rc) {
CERROR("Failed to write %s log (%d)\n",
mti->mti_svname, rc);
}
out:
- /* done with log update */
- if (lockrc == ELDLM_OK)
- mgs_put_cfg_lock(&lockh);
+ mgs_revoke_lock(obd, fsdb);
+
out_nolock:
CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname,
mti->mti_stripe_index, rc);
{
struct obd_device *obd = req->rq_export->exp_obd;
struct mgs_send_param *msp, *rep_msp;
- struct lustre_handle lockh;
int rc;
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
RETURN(rc);
}
- /* request for update */
- mgs_revoke_lock(obd, fsname, &lockh);
-
lustre_cfg_free(lcfg);
rc = req_capsule_server_pack(&req->rq_pill);
if (rc)
return rc;
- down(&fsdb->fsdb_sem);
+ cfs_down(&fsdb->fsdb_sem);
if (sptlrpc_rule_set_choose(&fsdb->fsdb_srpc_gen,
LUSTRE_SP_MGC, LUSTRE_SP_MGS,
req->rq_peer.nid,
/* by defualt allow any flavors */
flvr.sf_rpc = SPTLRPC_FLVR_ANY;
}
- up(&fsdb->fsdb_sem);
+ cfs_up(&fsdb->fsdb_sem);
- spin_lock(&exp->exp_lock);
+ cfs_spin_lock(&exp->exp_lock);
exp->exp_sp_peer = req->rq_sp_from;
exp->exp_flvr = flvr;
rc = -EACCES;
}
- spin_unlock(&exp->exp_lock);
+ cfs_spin_unlock(&exp->exp_lock);
} else {
if (exp->exp_sp_peer != req->rq_sp_from) {
CERROR("RPC source %s doesn't match %s\n",
static inline int mgs_init_export(struct obd_export *exp)
{
- spin_lock(&exp->exp_lock);
+ cfs_spin_lock(&exp->exp_lock);
exp->exp_connecting = 1;
- spin_unlock(&exp->exp_lock);
+ cfs_spin_unlock(&exp->exp_lock);
return ldlm_init_export(exp);
}
struct obd_ioctl_data *data)
{
int rc;
- struct lustre_handle lockh;
struct lustre_cfg *lcfg = NULL;
struct llog_rec_hdr rec;
char *fsname = NULL;
if (lcfg == NULL)
GOTO(out_pool, rc = -ENOMEM);
- if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
+ if (cfs_copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
GOTO(out_pool, rc = -EFAULT);
if (lcfg->lcfg_bufcount < 2) {
GOTO(out_pool, rc);
}
- /* request for update */
- mgs_revoke_lock(obd, fsname, &lockh);
-
out_pool:
if (lcfg != NULL)
OBD_FREE(lcfg, data->ioc_plen1);
switch (cmd) {
case OBD_IOC_PARAM: {
- struct lustre_handle lockh;
struct lustre_cfg *lcfg;
struct llog_rec_hdr rec;
char fsname[MTI_NAME_MAXLEN];
OBD_ALLOC(lcfg, data->ioc_plen1);
if (lcfg == NULL)
RETURN(-ENOMEM);
- if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
+ if (cfs_copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
GOTO(out_free, rc = -EFAULT);
if (lcfg->lcfg_bufcount < 1)
CERROR("setparam err %d\n", rc);
GOTO(out_free, rc);
}
-
- /* 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, fsname, &lockh);
-
out_free:
OBD_FREE(lcfg, data->ioc_plen1);
RETURN(rc);