Whamcloud - gitweb
LU-10560 osd: bio_integrity_enabled was removed 21/32621/3
authorLi Dongyang <dongyangli@ddn.com>
Tue, 5 Jun 2018 01:40:43 +0000 (11:40 +1000)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 14 Jun 2018 03:57:10 +0000 (03:57 +0000)
T10PI bio support patches used bio_integrity_enabled
which was no longer available in recent kernels.
Fix this so we can have server support back on 4.13+
kernels.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Change-Id: I32eeea244ad599c7af2d551b9b2b173e982d07d3
Reviewed-on: https://review.whamcloud.com/32621
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_internal.h

index 9cdceb8..399ce0a 100644 (file)
@@ -2823,6 +2823,23 @@ bi_status, [
 ]) # LC_BI_STATUS
 
 #
+# LC_BIO_INTEGRITY_ENABLED
+#
+# 4.13 removed bio_integrity_enabled
+#
+AC_DEFUN([LC_BIO_INTEGRITY_ENABLED], [
+LB_CHECK_COMPILE([if 'bio_integrity_enabled' exist],
+bio_integrity_enabled, [
+       #include <linux/bio.h>
+],[
+       bio_integrity_enabled(NULL);
+],[
+       AC_DEFINE(HAVE_BIO_INTEGRITY_ENABLED, 1,
+               ['bio_integrity_enabled' is available])
+])
+]) # LC_BIO_INTEGRITY_ENABLED
+
+#
 # LC_PAGEVEC_INIT_ONE_PARAM
 #
 # 4.14 pagevec_init takes one parameter
@@ -2840,6 +2857,24 @@ pagevec_init, [
 ]) # LC_PAGEVEC_INIT_ONE_PARAM
 
 #
+# LC_BI_BDEV
+#
+# 4.14 replaced bi_bdev to bi_disk
+#
+AC_DEFUN([LC_BI_BDEV], [
+LB_CHECK_COMPILE([if 'bi_bdev' exist],
+bi_bdev, [
+       #include <linux/blk_types.h>
+],[
+       ((struct bio *)0)->bi_bdev = NULL;
+],[
+       AC_DEFINE(HAVE_BI_BDEV, 1,
+               ['bi_bdev' is available])
+])
+]) # LC_BI_BDEV
+
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -3069,8 +3104,12 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_SUPER_SETUP_BDI_NAME
        LC_BI_STATUS
 
+       # 4.13
+       LC_BIO_INTEGRITY_ENABLED
+
        # 4.14
        LC_PAGEVEC_INIT_ONE_PARAM
+       LC_BI_BDEV
 
        #
        AS_IF([test "x$enable_server" != xno], [
index b7e6872..0e0e53d 100644 (file)
@@ -1371,3 +1371,37 @@ int osd_obj_spec_lookup(struct osd_thread_info *info, struct osd_device *osd,
 
        RETURN(rc);
 }
+
+#ifndef HAVE_BIO_INTEGRITY_ENABLED
+bool bio_integrity_enabled(struct bio *bio)
+{
+# ifdef HAVE_BI_BDEV
+       struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
+# else
+       struct blk_integrity *bi = blk_get_integrity(bio->bi_disk);
+# endif
+
+       if (bio_op(bio) != REQ_OP_READ && bio_op(bio) != REQ_OP_WRITE)
+               return false;
+
+       if (!bio_sectors(bio))
+               return false;
+
+        /* Already protected? */
+       if (bio_integrity(bio))
+               return false;
+
+       if (bi == NULL)
+               return false;
+
+       if (bio_data_dir(bio) == READ && bi->profile->verify_fn != NULL &&
+           (bi->flags & BLK_INTEGRITY_VERIFY))
+               return true;
+
+       if (bio_data_dir(bio) == WRITE && bi->profile->generate_fn != NULL &&
+           (bi->flags & BLK_INTEGRITY_GENERATE))
+               return true;
+
+       return false;
+}
+#endif
index 3ea8ccf..27189e0 100644 (file)
@@ -1337,7 +1337,11 @@ static inline struct buffer_head *__ldiskfs_bread(handle_t *handle,
        return bh;
 }
 
-#ifndef bio_set_dev
+#ifndef HAVE_BIO_INTEGRITY_ENABLED
+bool bio_integrity_enabled(struct bio *bio);
+#endif
+
+#ifdef HAVE_BI_BDEV
 # define bio_set_dev(bio, bdev) ((bio)->bi_bdev = bdev)
 # define bio_get_queue(bio)    bdev_get_queue((bio)->bi_bdev)
 #else