From 2263a10d97fda295e2282aea9c9ccdb2c48e7c56 Mon Sep 17 00:00:00 2001 From: jxiong Date: Thu, 6 Aug 2009 02:53:46 +0000 Subject: [PATCH] b=19928 r=eric.mei,rread Fixed the deadlock problem of simultaneous truncate --- lustre/lov/lov_lock.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lustre/lov/lov_lock.c b/lustre/lov/lov_lock.c index eb17fe7..58433c4 100644 --- a/lustre/lov/lov_lock.c +++ b/lustre/lov/lov_lock.c @@ -290,10 +290,7 @@ static int lov_lock_sub_init(const struct lu_env *env, { int result = 0; int i; - int j; int nr; - int stripe; - int start_stripe; obd_off start; obd_off end; obd_off file_start; @@ -309,14 +306,12 @@ static int lov_lock_sub_init(const struct lu_env *env, file_start = cl_offset(lov2cl(loo), parent->cll_descr.cld_start); file_end = cl_offset(lov2cl(loo), parent->cll_descr.cld_end + 1) - 1; - start_stripe = lov_stripe_number(r0->lo_lsm, file_start); for (i = 0, nr = 0; i < r0->lo_nr; i++) { /* * XXX for wide striping smarter algorithm is desirable, * breaking out of the loop, early. */ - stripe = (start_stripe + i) % r0->lo_nr; - if (lov_stripe_intersects(r0->lo_lsm, stripe, + if (lov_stripe_intersects(r0->lo_lsm, i, file_start, file_end, &start, &end)) nr++; } @@ -333,23 +328,22 @@ static int lov_lock_sub_init(const struct lu_env *env, * create sub-locks. At this moment, no other thread can access * top-lock. */ - for (j = 0, nr = 0; j < i; ++j) { - stripe = (start_stripe + j) % r0->lo_nr; - if (lov_stripe_intersects(r0->lo_lsm, stripe, + for (i = 0, nr = 0; i < r0->lo_nr; ++i) { + if (lov_stripe_intersects(r0->lo_lsm, i, file_start, file_end, &start, &end)) { struct cl_lock_descr *descr; descr = &lck->lls_sub[nr].sub_descr; LASSERT(descr->cld_obj == NULL); - descr->cld_obj = lovsub2cl(r0->lo_sub[stripe]); + descr->cld_obj = lovsub2cl(r0->lo_sub[i]); descr->cld_start = cl_index(descr->cld_obj, start); descr->cld_end = cl_index(descr->cld_obj, end); descr->cld_mode = parent->cll_descr.cld_mode; descr->cld_gid = parent->cll_descr.cld_gid; /* XXX has no effect */ lck->lls_sub[nr].sub_got = *descr; - lck->lls_sub[nr].sub_stripe = stripe; + lck->lls_sub[nr].sub_stripe = i; nr++; } } @@ -622,7 +616,7 @@ static int lov_lock_enqueue(const struct lu_env *env, lov_sublock_unlock(env, sub, closure, subenv); } result = lov_subresult(result, rc); - if (result < 0) + if (result != 0) break; } cl_lock_closure_fini(closure); -- 1.8.3.1