From: James Simmons Date: Thu, 15 May 2014 16:04:03 +0000 (-0400) Subject: LU-4993 llite: Support 3.14 kernel changes to bio api X-Git-Tag: 2.5.60~70 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d6f26343824941793010785fd35a74924ad84225 LU-4993 llite: Support 3.14 kernel changes to bio api In the 3.14 kernel code base several data fields in struct bio were moved into a new structure called bvec_iter. This changed impacted the lustre loop device. This patch brings support of these changes to the loop device lustre uses. Change-Id: I7cc9565bbf56e87e4465a76b7b5b959b063c3971 Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/10337 Tested-by: Jenkins Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 970593c..e14184d 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1435,6 +1435,25 @@ vfs_unlink_3args, [ ]) # LC_VFS_UNLINK_3ARGS # +# LC_HAVE_BVEC_ITER +# +# 3.14 move some of its data in struct bio into the new +# struct bvec_iter +# +AC_DEFUN([LC_HAVE_BVEC_ITER], [ +LB_CHECK_COMPILE([if Linux kernel has struct bvec_iter], +have_bvec_iter, [ + #include +],[ + struct bvec_iter iter; + iter.bi_bvec_done = 0; +], [ + AC_DEFINE(HAVE_BVEC_ITER, 1, + [kernel has struct bvec_iter]) +]) +]) # LC_HAVE_BVEC_ITER + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -1551,6 +1570,9 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_VFS_RENAME_5ARGS LC_VFS_UNLINK_3ARGS + # 3.14 + LC_HAVE_BVEC_ITER + # AS_IF([test "x$enable_server" != xno], [ LC_FUNC_DEV_SET_RDONLY diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 55e3e6b..5c3bd7b 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -192,10 +192,15 @@ 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; - int i; +#ifdef HAVE_BVEC_ITER + struct bvec_iter iter; + struct bio_vec bvec; +#else + int iter; + struct bio_vec *bvec; +#endif int rw; obd_count page_count = 0; - struct bio_vec *bvec; struct bio *bio; ssize_t bytes; @@ -218,18 +223,30 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) for (bio = head; bio != NULL; bio = bio->bi_next) { LASSERT(rw == bio->bi_rw); - offset = (pgoff_t)(bio->bi_sector << 9) + lo->lo_offset; - bio_for_each_segment(bvec, bio, i) { - BUG_ON(bvec->bv_offset != 0); +#ifdef HAVE_BVEC_ITER + offset = (pgoff_t)(bio->bi_iter.bi_sector << 9) + lo->lo_offset; + bio_for_each_segment(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; + bio_for_each_segment(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; - } - LASSERT(page_count <= LLOOP_MAX_SEGMENTS); - } + pages[page_count] = bvec->bv_page; + offsets[page_count] = offset; + page_count++; + offset += bvec->bv_len; +#endif + } + LASSERT(page_count <= LLOOP_MAX_SEGMENTS); + } ll_stats_ops_tally(ll_i2sbi(inode), (rw == WRITE) ? LPROC_LL_BRW_WRITE : LPROC_LL_BRW_READ, @@ -310,12 +327,17 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req) rw = first->bi_rw; bio = &lo->lo_bio; while (*bio && (*bio)->bi_rw == rw) { - CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u \n", - (unsigned long long)(*bio)->bi_sector, (*bio)->bi_size, - page_count, (*bio)->bi_vcnt); - if (page_count + (*bio)->bi_vcnt > LLOOP_MAX_SEGMENTS) - break; - +#ifdef HAVE_BVEC_ITER + CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u \n", + (unsigned long long)(*bio)->bi_iter.bi_sector, + (*bio)->bi_iter.bi_size, page_count, (*bio)->bi_vcnt); +#else + CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u \n", + (unsigned long long)(*bio)->bi_sector, (*bio)->bi_size, + page_count, (*bio)->bi_vcnt); +#endif + if (page_count + (*bio)->bi_vcnt > LLOOP_MAX_SEGMENTS) + break; page_count += (*bio)->bi_vcnt; count++; @@ -345,8 +367,14 @@ loop_make_request(struct request_queue *q, struct bio *old_bio) if (!lo) goto err; - CDEBUG(D_INFO, "submit bio sector %llu size %u\n", - (unsigned long long)old_bio->bi_sector, old_bio->bi_size); +#ifdef HAVE_BVEC_ITER + CDEBUG(D_INFO, "submit bio sector %llu size %u\n", + (unsigned long long)old_bio->bi_iter.bi_sector, + old_bio->bi_iter.bi_size); +#else + CDEBUG(D_INFO, "submit bio sector %llu size %u\n", + (unsigned long long)old_bio->bi_sector, old_bio->bi_size); +#endif spin_lock_irq(&lo->lo_lock); inactive = (lo->lo_state != LLOOP_BOUND);