From: Alexander.Zarochentsev Date: Tue, 2 Mar 2010 01:57:39 +0000 (-0800) Subject: b=21988 serialize mdt and obd state bit access X-Git-Tag: 1.10.0.38~15 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=4fb0d6f5a7cc4ac4a14a3710cd9795f87c41f49f;ds=sidebyside b=21988 serialize mdt and obd state bit access Use atomic bit functions to access mdt state in mdt_allow_cli(). Otherwise bit updates can be lost in case of concurrent modifications. Protect obd_no_conn = 0 by the obd_task_processing_lock spinlock as in the rest of the code excluding setup. i=tappro i=robert.read --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 63e7b90..ed96c2b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -5217,15 +5217,23 @@ static int mdt_destroy_export(struct obd_export *exp) static void mdt_allow_cli(struct mdt_device *m, unsigned int flag) { if (flag & CONFIG_LOG) - m->mdt_fl_cfglog = 1; + cfs_set_bit(MDT_FL_CFGLOG, &m->mdt_state); /* also notify active event */ if (flag & CONFIG_SYNC) - m->mdt_fl_synced = 1; + cfs_set_bit(MDT_FL_SYNCED, &m->mdt_state); - if (m->mdt_fl_cfglog && m->mdt_fl_synced) + if (cfs_test_bit(MDT_FL_CFGLOG, &m->mdt_state) && + cfs_test_bit(MDT_FL_SYNCED, &m->mdt_state)) { + struct obd_device *obd = m->mdt_md_dev.md_lu_dev.ld_obd; + /* Open for clients */ - m->mdt_md_dev.md_lu_dev.ld_obd->obd_no_conn = 0; + if (obd->obd_no_conn) { + cfs_spin_lock_bh(&obd->obd_processing_task_lock); + obd->obd_no_conn = 0; + cfs_spin_unlock_bh(&obd->obd_processing_task_lock); + } + } } static int mdt_upcall(const struct lu_env *env, struct md_device *md, @@ -5255,7 +5263,7 @@ static int mdt_upcall(const struct lu_env *env, struct md_device *md, break; case MD_LOV_CONFIG: /* Check that MDT is not yet configured */ - LASSERT(!m->mdt_fl_cfglog); + LASSERT(!cfs_test_bit(MDT_FL_CFGLOG, &m->mdt_state)); break; #ifdef HAVE_QUOTA_SUPPORT case MD_LOV_QUOTA: diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index aab9bd3..eb09101 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -91,6 +91,10 @@ struct mdt_file_data { struct mdt_object *mfd_object; /* point to opened object */ }; +/* mdt state flag bits */ +#define MDT_FL_CFGLOG 0 +#define MDT_FL_SYNCED 1 + struct mdt_device { /* super-class */ struct md_device mdt_md_dev; @@ -123,8 +127,7 @@ struct mdt_device { mo_cos :1; } mdt_opts; /* mdt state flags */ - __u32 mdt_fl_cfglog:1, - mdt_fl_synced:1; + unsigned long mdt_state; /* lock to protect IOepoch */ cfs_spinlock_t mdt_ioepoch_lock; __u64 mdt_ioepoch;