Whamcloud - gitweb
Branch: HEAD
authorwangdi <wangdi>
Wed, 4 Mar 2009 20:36:17 +0000 (20:36 +0000)
committerwangdi <wangdi>
Wed, 4 Mar 2009 20:36:17 +0000 (20:36 +0000)
b=18609
llog_ctxt_master access should be controlled by refcount, because it is
shared by multi llog group.
i=Huanghua,Shadow

lustre/include/lustre_log.h
lustre/obdclass/llog_obd.c
lustre/obdfilter/filter.c
lustre/tests/replay-single.sh

index 34ca742..eddaeef 100644 (file)
@@ -292,6 +292,10 @@ struct llog_commit_master {
          */
         atomic_t                   lcm_count;
         /**
          */
         atomic_t                   lcm_count;
         /**
+         * The refcount for lcm
+         */
+         atomic_t                 lcm_refcount;
+        /**
          * Thread control structure. Used for control commit thread.
          */
         struct ptlrpcd_ctl         lcm_pc;
          * Thread control structure. Used for control commit thread.
          */
         struct ptlrpcd_ctl         lcm_pc;
@@ -309,6 +313,23 @@ struct llog_commit_master {
         char                       lcm_name[LCM_NAME_SIZE];
 };
 
         char                       lcm_name[LCM_NAME_SIZE];
 };
 
+static inline struct llog_commit_master 
+*lcm_get(struct llog_commit_master *lcm)
+{
+        LASSERT(atomic_read(&lcm->lcm_refcount) > 0);
+        atomic_inc(&lcm->lcm_refcount);
+        return lcm;
+}
+
+static inline void 
+lcm_put(struct llog_commit_master *lcm)
+{
+        if (!atomic_dec_and_test(&lcm->lcm_refcount)) {
+                return ;
+        }
+        OBD_FREE_PTR(lcm);     
+}
+
 struct llog_canceld_ctxt {
         /**
          * Llog context this llcd is attached to. Used for accessing
 struct llog_canceld_ctxt {
         /**
          * Llog context this llcd is attached to. Used for accessing
index ca20d5d..2178f9e 100644 (file)
@@ -91,7 +91,10 @@ int __llog_ctxt_put(struct llog_ctxt *ctxt)
         }
         olg->olg_ctxts[ctxt->loc_idx] = NULL;
         spin_unlock(&olg->olg_lock);
         }
         olg->olg_ctxts[ctxt->loc_idx] = NULL;
         spin_unlock(&olg->olg_lock);
-
+        
+        if (ctxt->loc_lcm)
+                lcm_put(ctxt->loc_lcm);
+       
         obd = ctxt->loc_obd;
         spin_lock(&obd->obd_dev_lock);
         spin_unlock(&obd->obd_dev_lock); /* sync with llog ctxt user thread */
         obd = ctxt->loc_obd;
         spin_lock(&obd->obd_dev_lock);
         spin_unlock(&obd->obd_dev_lock); /* sync with llog ctxt user thread */
index f53a23c..d309c91 100644 (file)
@@ -2327,7 +2327,7 @@ filter_default_olg_init(struct obd_device *obd, struct obd_llog_group *olg,
                        LLOG_MDS_OST_REPL_CTXT);
                 GOTO(cleanup_olg, rc = -ENODEV);
         }
                        LLOG_MDS_OST_REPL_CTXT);
                 GOTO(cleanup_olg, rc = -ENODEV);
         }
-        ctxt->loc_lcm = filter->fo_lcm;
+        ctxt->loc_lcm = lcm_get(filter->fo_lcm);
         ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb;
         llog_ctxt_put(ctxt);
 
         ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb;
         llog_ctxt_put(ctxt);
 
@@ -2366,7 +2366,7 @@ filter_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
                 RETURN(-ENODEV);
         }
         ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb;
                 RETURN(-ENODEV);
         }
         ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb;
-        ctxt->loc_lcm = filter->fo_lcm;
+        ctxt->loc_lcm = lcm_get(filter->fo_lcm);
         llog_ctxt_put(ctxt);
         RETURN(rc);
 }
         llog_ctxt_put(ctxt);
         RETURN(rc);
 }
@@ -2401,8 +2401,10 @@ static int filter_llog_finish(struct obd_device *obd, int count)
         }
 
         if (filter->fo_lcm) {
         }
 
         if (filter->fo_lcm) {
+                mutex_down(&ctxt->loc_sem);
                 llog_recov_thread_fini(filter->fo_lcm, obd->obd_force);
                 filter->fo_lcm = NULL;
                 llog_recov_thread_fini(filter->fo_lcm, obd->obd_force);
                 filter->fo_lcm = NULL;
+                mutex_up(&ctxt->loc_sem);
         }
         RETURN(filter_olg_fini(&obd->obd_olg));
 }
         }
         RETURN(filter_olg_fini(&obd->obd_olg));
 }
index 5b618e0..1cfac66 100755 (executable)
@@ -1459,8 +1459,8 @@ run_test 60 "test llog post recovery init vs llog unlink"
 #test race  llog recovery thread vs llog cleanup
 test_61a() {   # was test_61
     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
 #test race  llog recovery thread vs llog cleanup
 test_61a() {   # was test_61
     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
-
-    mkdir $DIR/$tdir
+    
+    mkdir -p $DIR/$tdir
     createmany -o $DIR/$tdir/$tfile-%d 800
     replay_barrier ost1 
 #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221 
     createmany -o $DIR/$tdir/$tfile-%d 800
     replay_barrier ost1 
 #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221