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