From fdd231b394699ae0fa53b387b3ab436c9e201b91 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sun, 14 Jul 2019 06:33:35 -0500 Subject: [PATCH] LU-12400 osd-ldiskfs: support multi-page bvec Mutli-page bvec support to enable bio_for_each_segment_all needs users to supply bvec_iter_all as an iterator Abstract the old (int) and new (bvec_iter_all) iterator types Linux-commit: 6dc4f100c175dd0511ae8674786e7c9006cdfbfa Test-Parameters: trivial Cray-bug-id: LUS-7600 Signed-off-by: Shaun Tancheff Change-Id: I5a6decae9a4d470e268e20e86c29623b98e97205 Reviewed-on: https://review.whamcloud.com/35498 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons --- config/lustre-build-ldiskfs.m4 | 23 +++++++++++++++++++++++ lustre/osd-ldiskfs/osd_internal.h | 8 +++++++- lustre/osd-ldiskfs/osd_io.c | 14 ++++++++------ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/config/lustre-build-ldiskfs.m4 b/config/lustre-build-ldiskfs.m4 index e1c64a2..8c295b5 100644 --- a/config/lustre-build-ldiskfs.m4 +++ b/config/lustre-build-ldiskfs.m4 @@ -261,6 +261,28 @@ AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [ ]) # LDISKFS_AC_PATCH_PROGRAM # +# LB_HAVE_BVEC_ITER_ALL +# +# kernel 5.1 commit 6dc4f100c175dd0511ae8674786e7c9006cdfbfa +# block: allow bio_for_each_segment_all() to iterate over multi-page bvec +# +AC_DEFUN([LB_HAVE_BVEC_ITER_ALL], [ +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_CHECK_COMPILE([if bvec_iter_all exists for multi-page bvec iternation], +ext4fs_dirhash, [ + #include +],[ + struct bvec_iter_all iter; + (void)iter; +],[ + AC_DEFINE(HAVE_BVEC_ITER_ALL, 1, + [if bvec_iter_all exists for multi-page bvec iternation]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) # LB_HAVE_BVEC_ITER_ALL + +# # LB_CONFIG_LDISKFS # AC_DEFUN([LB_CONFIG_LDISKFS], [ @@ -309,6 +331,7 @@ AS_IF([test x$enable_ldiskfs != xno],[ LB_EXT4_HAVE_INFO_DQUOT LB_EXT4_HAVE_I_CRYPT_INFO LB_LDISKFS_IGET_HAS_FLAGS_ARG + LB_HAVE_BVEC_ITER_ALL AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs]) AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs]) AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs]) diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index dba072a..8b62608 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -689,6 +689,12 @@ struct osd_thread_info { extern int ldiskfs_pdo; +#ifdef HAVE_BVEC_ITER_ALL +#define DECLARE_BVEC_ITER_ALL(iter) struct bvec_iter_all iter +#else +#define DECLARE_BVEC_ITER_ALL(iter) int iter +#endif + #ifndef HAVE_VFS_SETXATTR #define osd_setxattr(dentry, inode, name, buf, len, flag) \ ((inode)->i_op->setxattr(dentry, name, buf, len, flag)) @@ -915,7 +921,7 @@ static inline struct buffer_head *osd_ldiskfs_append(handle_t *handle, ldiskfs_journal_start(inode, type, nblocks) # define osd_transaction_size(dev) \ (osd_journal(dev)->j_max_transaction_buffers / 2) -#else +#else /* ! defined LDISKFS_HT_MISC */ # define LDISKFS_HT_MISC 0 # define osd_journal_start_sb(sb, type, nblock) \ ldiskfs_journal_start_sb(sb, nblock) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index f140e2e..913fac8 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -164,7 +164,6 @@ static void dio_complete_routine(struct bio *bio, int error) { #endif struct osd_iobuf *iobuf = bio->bi_private; - int iter; struct bio_vec *bvl; /* CAVEAT EMPTOR: possibly in IRQ context @@ -191,7 +190,9 @@ static void dio_complete_routine(struct bio *bio, int error) /* the check is outside of the cycle for performance reason -bzzz */ if (!bio_data_dir(bio)) { - bio_for_each_segment_all(bvl, bio, iter) { + DECLARE_BVEC_ITER_ALL(iter_all); + + bio_for_each_segment_all(bvl, bio, iter_all) { if (likely(error == 0)) SetPageUptodate(bvl_to_page(bvl)); LASSERT(PageLocked(bvl_to_page(bvl))); @@ -279,11 +280,11 @@ static int can_be_merged(struct bio *bio, sector_t sector) static void bio_integrity_fault_inject(struct bio *bio) { struct bio_vec *bvec; - int i; + DECLARE_BVEC_ITER_ALL(iter_all); void *kaddr; char *addr; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, iter_all) { struct page *page = bvec->bv_page; kaddr = kmap(page); @@ -329,12 +330,13 @@ static int osd_bio_integrity_compare(struct bio *bio, struct block_device *bdev, bip->bip_vec->bv_offset; struct bio_vec *bv; sector_t sector = bio_start_sector(bio); - unsigned int i, sectors, total; + unsigned int sectors, total; + DECLARE_BVEC_ITER_ALL(iter_all); __u16 *expected_guard; int rc; total = 0; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, iter_all) { lnb = iobuf->dr_lnbs[index]; expected_guard = lnb->lnb_guards; sectors = bv->bv_len / sector_size; -- 1.8.3.1