Whamcloud - gitweb
LU-12634 osd-ldiskfs: bi_phys_segments removed from struct bio 46/35746/3
authorShaun Tancheff <stancheff@cray.com>
Fri, 9 Aug 2019 05:51:41 +0000 (00:51 -0500)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Sep 2019 23:04:19 +0000 (23:04 +0000)
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 <stancheff@cray.com>
Change-Id: I87f2b1dc34f47a4eaa5ab5d6e55a903afc317011
Reviewed-on: https://review.whamcloud.com/35746
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

index 4950ea9..4115ad8 100644 (file)
@@ -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 <linux/bio.h>
+],[
+       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
 
index fc9ab44..c29e53d 100644 (file)
@@ -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 */
index 913fac8..b0774e2 100644 (file)
@@ -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,