From: James Simmons Date: Tue, 21 Jun 2016 14:30:07 +0000 (-0400) Subject: LU-8056 lloop: fix bio_for_each_segment_all for newer kernels X-Git-Tag: 2.8.56~94 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=87c5e1cd7f45b336d40028af986bf09d2e4922b3 LU-8056 lloop: fix bio_for_each_segment_all for newer kernels Lustre patch http://review.whamcloud.com/20478 back ported bio_for_each_segment_all from newer kernels but support for newer kernels was done incorrectly. Update the code to work with newer kernels. Change-Id: I6a926320f80113169a13d2319190721c83d58b1d Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/20619 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Wang Shilong Reviewed-by: Li Dongyang Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index d777993..c45dc63 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -411,7 +411,12 @@ static inline void truncate_inode_pages_final(struct address_space *map) #endif #ifndef bio_for_each_segment_all /* since kernel version 3.9 */ +#ifdef HAVE_BVEC_ITER +#define bio_for_each_segment_all(bv, bio, it) \ + for (it = 0, bv = (bio)->bi_io_vec; it < (bio)->bi_vcnt; it++, bv++) +#else #define bio_for_each_segment_all(bv, bio, it) bio_for_each_segment(bv, bio, it) #endif +#endif #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 475185a..be6a112 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -193,13 +193,8 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) struct cl_object *obj = ll_i2info(inode)->lli_clob; pgoff_t offset; int ret; -#ifdef HAVE_BVEC_ITER - struct bvec_iter iter; - struct bio_vec bvec; -#else int iter; struct bio_vec *bvec; -#endif int rw; size_t page_count = 0; struct bio *bio; @@ -226,16 +221,9 @@ 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_all(bvec, bio, iter) { - BUG_ON(bvec.bv_offset != 0); - BUG_ON(bvec.bv_len != PAGE_CACHE_SIZE); - - pages[page_count] = bvec.bv_page; - offsets[page_count] = offset; - page_count++; - offset += bvec.bv_len; #else offset = (pgoff_t)(bio->bi_sector << 9) + lo->lo_offset; +#endif bio_for_each_segment_all(bvec, bio, iter) { BUG_ON(bvec->bv_offset != 0); BUG_ON(bvec->bv_len != PAGE_CACHE_SIZE); @@ -244,7 +232,6 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) offsets[page_count] = offset; page_count++; offset += bvec->bv_len; -#endif } LASSERT(page_count <= LLOOP_MAX_SEGMENTS); }