Whamcloud - gitweb
LU-5461 mdc: don't add to page cache upon failure 50/11450/7
authorLai Siyao <lai.siyao@intel.com>
Thu, 14 Aug 2014 13:22:50 +0000 (21:22 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 17 Dec 2014 18:06:41 +0000 (18:06 +0000)
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 <lai.siyao@intel.com>
Change-Id: Icbb55c0ecc4b88913b08ac8998c2673ec15b18ea
Reviewed-on: http://review.whamcloud.com/11450
Tested-by: Jenkins
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdc/mdc_request.c
lustre/tests/sanity.sh

index 7fb41ec..d655f9c 100644 (file)
@@ -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++) {
index d7c9ad3..5e9f63a 100644 (file)
@@ -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