From f6a03ab0fea13ea658cf08a582581682eb15b71c Mon Sep 17 00:00:00 2001 From: wangdi Date: Wed, 4 Mar 2009 20:36:17 +0000 Subject: [PATCH] Branch: HEAD 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 | 21 +++++++++++++++++++++ lustre/obdclass/llog_obd.c | 5 ++++- lustre/obdfilter/filter.c | 6 ++++-- lustre/tests/replay-single.sh | 4 ++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 34ca742..eddaeef 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -292,6 +292,10 @@ struct llog_commit_master { */ 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; @@ -309,6 +313,23 @@ struct llog_commit_master { 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 diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index ca20d5d..2178f9e 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -91,7 +91,10 @@ int __llog_ctxt_put(struct llog_ctxt *ctxt) } 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 */ diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index f53a23c..d309c91 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -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); } - 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); @@ -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; - ctxt->loc_lcm = filter->fo_lcm; + ctxt->loc_lcm = lcm_get(filter->fo_lcm); 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) { + mutex_down(&ctxt->loc_sem); 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)); } diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 5b618e0..1cfac660 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -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 - - mkdir $DIR/$tdir + + mkdir -p $DIR/$tdir createmany -o $DIR/$tdir/$tfile-%d 800 replay_barrier ost1 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221 -- 1.8.3.1