From b3bc81598ceb2b60358ca657d46fdd7136c84b07 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Fri, 9 Aug 2019 00:51:41 -0500 Subject: [PATCH] LU-12634 osd-ldiskfs: bi_phys_segments removed from struct bio Linux 5.3 removed the bi_phys_segments field in struct bio Use bio_segments() if bi_phys_segments is not available kernel-commit: 14ccb66b3f585b2bc21e7256c96090abed5a512c Test-Parameters: trivial Cray-bug-id: LUS-7689 Signed-off-by: Shaun Tancheff Change-Id: I87f2b1dc34f47a4eaa5ab5d6e55a903afc317011 Reviewed-on: https://review.whamcloud.com/35746 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: Alex Zhuravlev Reviewed-by: Patrick Farrell Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 25 +++++++++++++++++++++++++ lustre/osd-ldiskfs/osd_internal.h | 6 ++++++ lustre/osd-ldiskfs/osd_io.c | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 4950ea9..4115ad8 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2831,6 +2831,28 @@ EXTRA_KCFLAGS="$tmp_flags" ]) # LC_HAS_LINUX_SELINUX_ENABLED # +# LC_BIO_BI_PHYS_SEGMENTS +# +# kernel 5.3-rc1 commit 14ccb66b3f585b2bc21e7256c96090abed5a512c +# block: remove the bi_phys_segments field in struct bio +# +AC_DEFUN([LC_BIO_BI_PHYS_SEGMENTS], [ +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_CHECK_COMPILE([if struct bio has bi_phys_segments member], +bye_bio_bi_phys_segments, [ + #include +],[ + struct bio *bio = NULL; + bio->bi_phys_segments++; +],[ + AC_DEFINE(HAVE_BIO_BI_PHYS_SEGMENTS, 1, + [struct bio has bi_phys_segments member]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) # LC_BIO_BI_PHYS_SEGMENTS + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -3058,6 +3080,9 @@ AC_DEFUN([LC_PROG_LINUX], [ # 5.1 LC_HAS_LINUX_SELINUX_ENABLED + # 5.3 + LC_BIO_BI_PHYS_SEGMENTS + # kernel patch to extend integrity interface LC_BIO_INTEGRITY_PREP_FN diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index fc9ab44..c29e53d 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -1534,4 +1534,10 @@ static inline bool bio_integrity_prep_fn(struct bio *bio, } #endif +#ifdef HAVE_BIO_BI_PHYS_SEGMENTS +#define osd_bio_nr_segs(bio) ((bio)->bi_phys_segments) +#else +#define osd_bio_nr_segs(bio) bio_segments((bio)) +#endif /* HAVE_BIO_BI_PHYS_SEGMENTS */ + #endif /* _OSD_INTERNAL_H */ diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 913fac8..b0774e2 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -529,7 +529,7 @@ static int osd_do_bio(struct osd_device *osd, struct inode *inode, bi_size, bio->bi_vcnt, bio->bi_max_vecs, bio_sectors(bio), queue_max_sectors(q), - bio->bi_phys_segments, + osd_bio_nr_segs(bio), queue_max_segments(q)); rc = osd_bio_integrity_handle(osd, bio, iobuf, bio_start_page_idx, -- 1.8.3.1