File 0018-LU-15544-osd-ldiskfs-Update-bio_set_dev-and-BIO_MAX_.patch of Package lustre_2_15
From 7ab9cc7a1315f573addd4ee2853a2c1f3a13cdf5 Mon Sep 17 00:00:00 2001
From: Shaun Tancheff <shaun.tancheff@hpe.com>
Date: Fri, 11 Nov 2022 02:19:53 -0600
Subject: [PATCH 18/30] LU-15544 osd-ldiskfs: Update bio_set_dev and
BIO_MAX_VECS
Linux commit v5.11-rc5-9-g309dca309fc3
block: store a block_device pointer in struct bio
created bio_set_dev macro and
Linux commit v5.15-rc6-127-gcf6d6238cdd3
block: turn macro helpers into inline functions
change the macro to an inline function for bio_set_dev.
This change tests for bio_set_dev and provides one, if one
is not provided by the kernel.
Linux commit v5.12-rc1-20-ga8affc03a9b3
block: rename BIO_MAX_PAGES to BIO_MAX_VECS
This change provide a fallback for older kernels when
BIO_MAX_VECS is not defined.
Linux commit v5.11-rc4-8-g5857c9209ce5
mm: Mark anonymous struct field of 'struct vm_fault' as 'const'
Breaks and exisiting configure test for vm_fault.address
This changes the configure test for vm_fault.address so it does
not fail due to address being const
Test-Parameters: trivial
HPE-bug-id: LUS-10744
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I06d3bf60e32b969e1e635e378cbd1ee36293165c
---
lustre/autoconf/lustre-core.m4 | 37 +++++++++++++++++++++++++++++++++++--
lustre/osd-ldiskfs/osd_internal.h | 5 ++++-
lustre/osd-ldiskfs/osd_io.c | 11 ++++++++++-
3 files changed, 49 insertions(+), 4 deletions(-)
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1974,8 +1974,9 @@ LB_CHECK_COMPILE([if 'struct vm_fault' r
vm_fault_address, [
#include <linux/mm.h>
],[
- unsigned long vaddr = ((struct vm_fault *)0)->address;
- (void)vaddr;
+ struct vm_fault vmf = { 0 };
+ unsigned long addr = (unsigned long)vmf.address;
+ (void)addr;
],[
AC_DEFINE(HAVE_VM_FAULT_ADDRESS, 1,
[virtual_address has been replaced by address field])
@@ -2645,6 +2646,35 @@ EXTRA_KCFLAGS="$tmp_flags"
]) # LC_FSCRYPT_IS_NOKEY_NAME
#
+# LC_BIO_SET_DEV
+#
+# Linux: v5.11-rc5-9-g309dca309fc3
+# block: store a block_device pointer in struct bio
+# created bio_set_dev macro
+# Linux: v5.15-rc6-127-gcf6d6238cdd3
+# block: turn macro helpers into inline functions
+# created inline function(s).
+#
+# Only provide a bio_set_dev it is is not proveded by the kernel
+#
+AC_DEFUN([LC_BIO_SET_DEV], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+ LB_CHECK_COMPILE([if 'bio_set_dev' is available],
+ [bio_set_dev], [
+ #include <linux/bio.h>
+ ],[
+ struct bio *bio = NULL;
+ struct block_device *bdev = NULL;
+
+ bio_set_dev(bio, bdev);
+ ],[
+ AC_DEFINE(HAVE_BIO_SET_DEV, 1, ['bio_set_dev' is available])
+ ])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_BIO_SET_DEV
+
+#
# LC_HAVE_USER_NAMESPACE_ARG
#
# kernel 5.12 commit 549c7297717c32ee53f156cd949e055e601f67bb
@@ -3034,6 +3064,9 @@ AC_DEFUN([LC_PROG_LINUX], [
# 5.10
LC_HAVE_ITER_FILE_SPLICE_WRITE
+ # 5.11
+ LC_BIO_SET_DEV
+
# 5.12
LC_HAVE_USER_NAMESPACE_ARG
--- a/lustre/osd-ldiskfs/osd_internal.h
+++ b/lustre/osd-ldiskfs/osd_internal.h
@@ -1502,7 +1502,10 @@ bool bio_integrity_enabled(struct bio *b
# define bio_get_dev(bio) ((bio)->bi_bdev)
# define bio_get_disk(bio) (bio_get_dev(bio)->bd_disk)
# define bio_get_queue(bio) bdev_get_queue(bio_get_dev(bio))
-# define bio_set_dev(bio, bdev) (bio_get_dev(bio) = (bdev))
+
+# ifndef HAVE_BIO_SET_DEV
+# define bio_set_dev(bio, bdev) (bio_get_dev(bio) = (bdev))
+# endif
#else
# define bio_get_disk(bio) ((bio)->bi_disk)
# define bio_get_queue(bio) (bio_get_disk(bio)->queue)
--- a/lustre/osd-ldiskfs/osd_io.c
+++ b/lustre/osd-ldiskfs/osd_io.c
@@ -483,6 +483,14 @@ static void osd_mark_page_io_done(struct
}
}
+/*
+ * Linux v5.12-rc1-20-ga8affc03a9b3
+ * block: rename BIO_MAX_PAGES to BIO_MAX_VECS
+ */
+#ifndef BIO_MAX_VECS
+#define BIO_MAX_VECS BIO_MAX_PAGES
+#endif
+
static int osd_do_bio(struct osd_device *osd, struct inode *inode,
struct osd_iobuf *iobuf, sector_t start_blocks,
sector_t count)
@@ -604,7 +612,8 @@ static int osd_do_bio(struct osd_device
bio_start_page_idx = page_idx;
/* allocate new bio */
- bio = bio_alloc(GFP_NOIO, min(BIO_MAX_PAGES,
+ bio = bio_alloc(GFP_NOIO, min_t(unsigned short,
+ BIO_MAX_VECS,
(block_idx_end - block_idx +
blocks_left_page - 1)));
if (bio == NULL) {