From: Lai Siyao Date: Thu, 14 Aug 2014 13:22:50 +0000 (+0800) Subject: LU-5461 mdc: don't add to page cache upon failure X-Git-Tag: 2.6.92~52 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=2e1472489481ddef9956db8008d63a78c7c84289 LU-5461 mdc: don't add to page cache upon failure Reading directory pages may fail on MDS, in this case client should not cache a non-up-to-date directory page, because it will cause a later read on the same page fail. Add sanity 242 for this. Signed-off-by: Lai Siyao Change-Id: Icbb55c0ecc4b88913b08ac8998c2673ec15b18ea Reviewed-on: http://review.whamcloud.com/11450 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 7fb41ec..d655f9c 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1352,6 +1352,14 @@ struct readpage_param { struct md_callback *rp_cb; }; +#ifndef HAVE_DELETE_FROM_PAGE_CACHE +static inline void delete_from_page_cache(struct page *page) +{ + remove_from_page_cache(page); + page_cache_release(page); +} +#endif + /** * Read pages from server. * @@ -1401,7 +1409,10 @@ static int mdc_read_page_remote(void *data, struct page *page0) rc = mdc_getpage(rp->rp_exp, fid, rp->rp_off, op_data->op_capa1, page_pool, npages, &req); - if (rc == 0) { + if (rc < 0) { + /* page0 is special, which was added into page cache early */ + delete_from_page_cache(page0); + } else { int lu_pgs; rd_pgs = (req->rq_bulk->bd_nob_transferred + @@ -1416,8 +1427,8 @@ static int mdc_read_page_remote(void *data, struct page *page0) SetPageUptodate(page0); } - unlock_page(page0); + ptlrpc_req_finished(req); CDEBUG(D_CACHE, "read %d/%d pages\n", rd_pgs, npages); for (i = 1; i < npages; i++) { diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d7c9ad3..5e9f63a 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -12762,6 +12762,19 @@ test_241() { } run_test 241 "bio vs dio" +test_242() { + mkdir -p $DIR/$tdir + touch $DIR/$tdir/$tfile + + #define OBD_FAIL_MDS_READPAGE_PACK 0x105 + do_facet mds1 lctl set_param fail_loc=0x105 + /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail" + + do_facet mds1 lctl set_param fail_loc=0 + /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed" +} +run_test 242 "mdt_readpage failure should not cause directory unreadable" + cleanup_test_300() { trap 0 umask $SAVE_UMASK