From 5e5e4ae2be4bc377f0f896163ae59bf338c4250c Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Fri, 27 May 2016 21:40:26 +0900 Subject: [PATCH] LU-8210 osd-ldiskfs: fix setting pages PageUptodate state In our VM autotest sanity:156 test failed in rhel7 plataform for writecache disable and readcache enabled. After debugging this is because of we miss to set PageUptodate after reading bio finish, this will make read cache total unusable for rhel7, because osd_read_prep() will think pages always not uptodate and triger bio submitting for every reading request. Problems come from pages iterating, since bio_for_each_segment_all introduced, bio_for_each_segment will no longer work right for pages interating anymore, we should use new interface for rhel7. So this problems only exist for some specific Drivers: From Documentation/block/biodoc.txt ------------------------------- Drivers which can't process a large bio in one shot can use the bi_idx field to keep track of the next bio_vec entry to process.(e.g a 1MB bio_vec needs to be handled in max 128kB chunks for IDE) [TBD: Should preferably also have a bi_voffset and bi_vlen to avoid modifying bi_offset an len fields] ------------------------------- This might explain why intel autotest could not reproduce it but our clustered can always reproduce the problem. Signed-off-by: Wang Shilong Change-Id: I5d3de5bf5facbee8d9450c15b8ab7189d7f2fbfe Reviewed-on: http://review.whamcloud.com/20478 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Li Xi Reviewed-by: Alex Zhuravlev --- lustre/include/lustre_compat.h | 5 +++++ lustre/llite/lloop.c | 4 ++-- lustre/osd-ldiskfs/osd_io.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 4e9f3ac..d777993 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -39,6 +39,7 @@ #include #include +#include #include @@ -409,4 +410,8 @@ static inline void truncate_inode_pages_final(struct address_space *map) security_inode_init_security(inode, dir, name, value, len) #endif +#ifndef bio_for_each_segment_all /* since kernel version 3.9 */ +#define bio_for_each_segment_all(bv, bio, it) bio_for_each_segment(bv, bio, it) +#endif + #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 2a6813f..b8ae0b5 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -226,7 +226,7 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) #ifdef HAVE_BVEC_ITER offset = (pgoff_t)(bio->bi_iter.bi_sector << 9) + lo->lo_offset; - bio_for_each_segment(bvec, bio, iter) { + bio_for_each_segment_all(bvec, bio, iter) { BUG_ON(bvec.bv_offset != 0); BUG_ON(bvec.bv_len != PAGE_CACHE_SIZE); @@ -236,7 +236,7 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) offset += bvec.bv_len; #else offset = (pgoff_t)(bio->bi_sector << 9) + lo->lo_offset; - bio_for_each_segment(bvec, bio, iter) { + bio_for_each_segment_all(bvec, bio, iter) { BUG_ON(bvec->bv_offset != 0); BUG_ON(bvec->bv_len != PAGE_CACHE_SIZE); diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 5ef77b2..aaea2f0 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -179,7 +179,7 @@ static void dio_complete_routine(struct bio *bio, int error) /* the check is outside of the cycle for performance reason -bzzz */ if (!test_bit(__REQ_WRITE, &bio->bi_rw)) { - bio_for_each_segment(bvl, bio, iter) { + bio_for_each_segment_all(bvl, bio, iter) { if (likely(error == 0)) SetPageUptodate(bvl_to_page(bvl)); LASSERT(PageLocked(bvl_to_page(bvl))); -- 1.8.3.1