X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_compat.c;fp=lustre%2Fosd-ldiskfs%2Fosd_compat.c;h=0e0e53d544aed28d686ebc33279653e28d4f2d20;hp=b7e6872bd02a81042f998288435d5361f26c10b9;hb=eee33ef0f07f3f2f5953953416d5d505088ae9a9;hpb=a1caf1f6af959ac7a12acddabe58539f180b9c96 diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index b7e6872..0e0e53d 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -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