From: zhanghc Date: Mon, 24 Aug 2009 03:19:15 +0000 (+0000) Subject: b=20183 X-Git-Tag: v1_8_2_01~1^2~156 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=9e78ca7f374bb4f4c48242e504c7ceab8f4a90b5;p=fs%2Flustre-release.git b=20183 fix a race in lov_update_create_set between lov_create and osc_interpret_create/handle_async_create/cb_create_update i=alexey.lyashkov@sun.com i=andrew.perepechko@sun.com --- diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 2245d62..7df674e 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -82,6 +82,7 @@ struct lov_request_set { struct lov_lock_handles *set_lockh; struct list_head set_list; cfs_waitq_t set_waitq; + spinlock_t set_lock; }; diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index f7522b9..84b3579 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -60,6 +60,7 @@ static void lov_init_set(struct lov_request_set *set) CFS_INIT_LIST_HEAD(&set->set_list); atomic_set(&set->set_refcount, 1); cfs_waitq_init(&set->set_waitq); + spin_lock_init(&set->set_lock); } static void lov_finish_set(struct lov_request_set *set) @@ -686,9 +687,6 @@ int lov_update_create_set(struct lov_request_set *set, struct lov_obd *lov = &set->set_exp->exp_obd->u.lov; ENTRY; - req->rq_stripe = set->set_success; - loi = lsm->lsm_oinfo[req->rq_stripe]; - if (rc && lov->lov_tgts[req->rq_idx] && lov->lov_tgts[req->rq_idx]->ltd_active) { CERROR("error creating fid "LPX64" sub-object" @@ -700,14 +698,18 @@ int lov_update_create_set(struct lov_request_set *set, rc = -EIO; } } - lov_update_set(set, req, rc); - if (rc) + + spin_lock(&set->set_lock); + req->rq_stripe = set->set_success; + loi = lsm->lsm_oinfo[req->rq_stripe]; + if (rc) { + lov_update_set(set, req, rc); + spin_unlock(&set->set_lock); RETURN(rc); + } loi->loi_id = req->rq_oi.oi_oa->o_id; loi->loi_ost_idx = req->rq_idx; - CDEBUG(D_INODE, "objid "LPX64" has subobj "LPX64"/"LPU64" at idx %d\n", - lsm->lsm_object_id, loi->loi_id, loi->loi_id, req->rq_idx); loi_init(loi); if (oti && set->set_cookies) @@ -715,6 +717,12 @@ int lov_update_create_set(struct lov_request_set *set, if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCOOKIE) set->set_cookie_sent++; + lov_update_set(set, req, rc); + spin_unlock(&set->set_lock); + + CDEBUG(D_INODE, "objid "LPX64" has subobj "LPX64"/"LPU64" at idx %d\n", + lsm->lsm_object_id, loi->loi_id, loi->loi_id, req->rq_idx); + RETURN(0); }