aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/bio-integrity.c31
-rw-r--r--include/linux/blkdev.h43
2 files changed, 31 insertions, 43 deletions
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index c3e174b35fe6..ba4ada08564a 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -150,6 +150,29 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
150} 150}
151EXPORT_SYMBOL(bio_integrity_add_page); 151EXPORT_SYMBOL(bio_integrity_add_page);
152 152
153static struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
154{
155 return bdev->bd_disk->integrity;
156}
157
158static int bdev_integrity_enabled(struct block_device *bdev, int rw)
159{
160 struct blk_integrity *bi = bdev_get_integrity(bdev);
161
162 if (bi == NULL)
163 return 0;
164
165 if (rw == READ && bi->verify_fn != NULL &&
166 (bi->flags & INTEGRITY_FLAG_READ))
167 return 1;
168
169 if (rw == WRITE && bi->generate_fn != NULL &&
170 (bi->flags & INTEGRITY_FLAG_WRITE))
171 return 1;
172
173 return 0;
174}
175
153/** 176/**
154 * bio_integrity_enabled - Check whether integrity can be passed 177 * bio_integrity_enabled - Check whether integrity can be passed
155 * @bio: bio to check 178 * @bio: bio to check
@@ -313,6 +336,14 @@ static void bio_integrity_generate(struct bio *bio)
313 } 336 }
314} 337}
315 338
339static inline unsigned short blk_integrity_tuple_size(struct blk_integrity *bi)
340{
341 if (bi)
342 return bi->tuple_size;
343
344 return 0;
345}
346
316/** 347/**
317 * bio_integrity_prep - Prepare bio for integrity I/O 348 * bio_integrity_prep - Prepare bio for integrity I/O
318 * @bio: bio to prepare 349 * @bio: bio to prepare
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e34999d14c16..e23b838825bd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1004,47 +1004,6 @@ extern int blk_integrity_compare(struct block_device *, struct block_device *);
1004extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); 1004extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *);
1005extern int blk_rq_count_integrity_sg(struct request *); 1005extern int blk_rq_count_integrity_sg(struct request *);
1006 1006
1007static inline unsigned short blk_integrity_tuple_size(struct blk_integrity *bi)
1008{
1009 if (bi)
1010 return bi->tuple_size;
1011
1012 return 0;
1013}
1014
1015static inline struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
1016{
1017 return bdev->bd_disk->integrity;
1018}
1019
1020static inline unsigned int bdev_get_tag_size(struct block_device *bdev)
1021{
1022 struct blk_integrity *bi = bdev_get_integrity(bdev);
1023
1024 if (bi)
1025 return bi->tag_size;
1026
1027 return 0;
1028}
1029
1030static inline int bdev_integrity_enabled(struct block_device *bdev, int rw)
1031{
1032 struct blk_integrity *bi = bdev_get_integrity(bdev);
1033
1034 if (bi == NULL)
1035 return 0;
1036
1037 if (rw == READ && bi->verify_fn != NULL &&
1038 (bi->flags & INTEGRITY_FLAG_READ))
1039 return 1;
1040
1041 if (rw == WRITE && bi->generate_fn != NULL &&
1042 (bi->flags & INTEGRITY_FLAG_WRITE))
1043 return 1;
1044
1045 return 0;
1046}
1047
1048static inline int blk_integrity_rq(struct request *rq) 1007static inline int blk_integrity_rq(struct request *rq)
1049{ 1008{
1050 if (rq->bio == NULL) 1009 if (rq->bio == NULL)
@@ -1058,8 +1017,6 @@ static inline int blk_integrity_rq(struct request *rq)
1058#define blk_integrity_rq(rq) (0) 1017#define blk_integrity_rq(rq) (0)
1059#define blk_rq_count_integrity_sg(a) (0) 1018#define blk_rq_count_integrity_sg(a) (0)
1060#define blk_rq_map_integrity_sg(a, b) (0) 1019#define blk_rq_map_integrity_sg(a, b) (0)
1061#define bdev_get_integrity(a) (0)
1062#define bdev_get_tag_size(a) (0)
1063#define blk_integrity_compare(a, b) (0) 1020#define blk_integrity_compare(a, b) (0)
1064#define blk_integrity_register(a, b) (0) 1021#define blk_integrity_register(a, b) (0)
1065#define blk_integrity_unregister(a) do { } while (0); 1022#define blk_integrity_unregister(a) do { } while (0);