From: hongchao.zhang Date: Sun, 13 Jun 2010 05:42:11 +0000 (+0800) Subject: b=22309 get and validate lock before issuing readahead X-Git-Tag: v1_8_3_55~18 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=bbd603ba1c168372880cbe423486ce7cc29407a9;p=fs%2Flustre-release.git b=22309 get and validate lock before issuing readahead in ll_read_ahead_page, get and check the validation of the ldlm lock to protect the readahead before issuing the actual read request i=johann@sun.com i=yong.fan@sun.com --- diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 32ac789..688fa37 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -1509,23 +1509,26 @@ static int ll_read_ahead_page(struct obd_export *exp, struct obd_io_group *oig, if (Page_Uptodate(page)) GOTO(unlock_page, rc = 0); + if (!lustre_handle_is_used(&lockh)) { + start = ((loff_t)index) << CFS_PAGE_SHIFT; + end = start + CFS_PAGE_SIZE - 1; + rc = obd_get_lock(exp, + ll_i2info(mapping->host)->lli_smd, + &llap->llap_cookie, OBD_BRW_READ, + start, end, &lockh, OBD_FAST_LOCK); + /* Is the lock being cancelling? */ + if (rc <= 0) + GOTO(unlock_page, rc = 0); + } + + llap->llap_lockh_granted = lockh; + rc = ll_issue_page_read(exp, llap, oig, 1); if (rc == 0) { LL_CDEBUG_PAGE(D_READA | D_PAGE, page, "started read-ahead\n"); rc = 1; - - if (!lustre_handle_is_used(&lockh)) { - start = ((loff_t)index) << CFS_PAGE_SHIFT; - end = start + CFS_PAGE_SIZE - 1; - rc = obd_get_lock(exp, - ll_i2info(mapping->host)->lli_smd, - &llap->llap_cookie, OBD_BRW_READ, - start, end, &lockh, OBD_FAST_LOCK); - LASSERT(rc); - } - - llap->llap_lockh_granted = lockh; } else { + llap->llap_lockh_granted.cookie = 0; unlock_page: if (lustre_handle_is_used(&lockh)) ldlm_lock_decref(&lockh, LCK_PR);