]) # 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
]) # 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
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], [
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