Whamcloud - gitweb
LU-15262 osd: bio_integrity_prep_fn return value processing 46/45646/3
authorAlexey Lyashkov <alexey.lyashkov@hpe.com>
Mon, 22 Nov 2021 13:32:23 +0000 (16:32 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 23 Dec 2021 07:16:35 +0000 (07:16 +0000)
There is osd_bio_integrity_handle() fn in lustre/osd-ldiskfs/osd_io.c
It checks the returned code of bio_integrity_prep_fn() but between
mainstream Linux 4.12 and 4.13 kernel integrity API has changed and
in 4.13+ (as well as for any RHEL8 including first beta)

bio_integrity_prep() returns boolean true on success.

HPe-bug-id: LUS-10443
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Change-Id: I973aa8ccae024157ad863d26afc7b1264a5c7149
Reviewed-on: https://review.whamcloud.com/45646
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/osd-ldiskfs/osd_internal.h

index daece66..a36ff43 100644 (file)
@@ -1353,6 +1353,28 @@ bio_integrity_prep_fn, [
 ])
 ]) # LC_BIO_INTEGRITY_PREP_FN
 
+# LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
+#
+# 13 kernel integrity API has changed and in 4.13+
+# (as well as in rhel 8.4) bio_integrity_prep() returns boolean true
+# on success.
+#
+AC_DEFUN([LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL], [
+LB_CHECK_COMPILE([if 'bio_integrity_prep_fn' returns bool],
+bio_integrity_prep, [
+       #include <linux/bio.h>
+       #include <linux/typecheck.h>
+],[
+       #pragma GCC diagnostic warning "-Werror"
+       typedef bool (*bio_integrity_prep_type)(struct bio *bio) ;
+
+       typecheck_fn(bio_integrity_prep_type, bio_integrity_prep);
+],[
+       AC_DEFINE(HAVE_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL, 1,
+               [bio_integrity_prep_fn returns bool])
+])
+]) # LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
+
 #
 # LC_HAVE_BI_OPF
 #
@@ -2583,6 +2605,7 @@ AC_DEFUN([LC_PROG_LINUX], [
 
        # 4.13
        LC_BIO_INTEGRITY_ENABLED
+       LC_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
        LC_HAVE_GET_INODE_USAGE
 
        # 4.14
index 705d8b0..0c67dc4 100644 (file)
@@ -1627,11 +1627,18 @@ static inline int osd_get_integrity_profile(struct osd_device *osd,
        return 0;
 }
 
-static inline bool bio_integrity_prep_fn(struct bio *bio,
+static inline int bio_integrity_prep_fn(struct bio *bio,
                                         integrity_gen_fn *generate_fn,
                                         integrity_vrfy_fn *verify_fn)
 {
+#ifdef HAVE_BIO_INTEGRITY_PREP_FN_RETURNS_BOOL
+       if (bio_integrity_prep(bio))
+               return 0;
+       else
+               return -EIO;
+#else
        return bio_integrity_prep(bio);
+#endif
 }
 #endif