From c58dde165dafe1b3ac3bf40e70cc0c42c4a4d5cf Mon Sep 17 00:00:00 2001 From: shadow Date: Mon, 10 Aug 2009 09:32:29 +0000 Subject: [PATCH] correctly handle get_lock vs lock cancel race Branch b1_8 b=20162 i=gree i=panda --- lustre/osc/osc_request.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index f72b082..4d3bf69 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2799,9 +2799,14 @@ static int osc_get_lock(struct obd_export *exp, struct lov_stripe_md *lsm, struct osc_async_page *oap = *res; spin_lock(&oap->oap_lock); lock = oap->oap_ldlm_lock; - LDLM_LOCK_GET(lock); + if (likely(lock)) + LDLM_LOCK_GET(lock); spin_unlock(&oap->oap_lock); } + /* lock can be NULL in case race obd_get_lock vs lock cancel + * so we should be don't try match this */ + if (unlikely(!lock)) + return 0; rc = ldlm_lock_fast_match(lock, rw, start, end, lockh); if (release == 1 && rc == 1) -- 1.8.3.1