Whamcloud - gitweb
b=21988 serialize mdt and obd state bit access
authorAlexander.Zarochentsev <Alexander.Zarochentsev@Sun.COM>
Tue, 2 Mar 2010 01:57:39 +0000 (17:57 -0800)
committerRobert Read <rread@sun.com>
Tue, 2 Mar 2010 01:57:39 +0000 (17:57 -0800)
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

lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h

index 63e7b90..ed96c2b 100644 (file)
@@ -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:
index aab9bd3..eb09101 100644 (file)
@@ -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;