diff options
Diffstat (limited to 'fs/bio-integrity.c')
-rw-r--r-- | fs/bio-integrity.c | 31 |
1 files changed, 31 insertions, 0 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 | } |
151 | EXPORT_SYMBOL(bio_integrity_add_page); | 151 | EXPORT_SYMBOL(bio_integrity_add_page); |
152 | 152 | ||
153 | static struct blk_integrity *bdev_get_integrity(struct block_device *bdev) | ||
154 | { | ||
155 | return bdev->bd_disk->integrity; | ||
156 | } | ||
157 | |||
158 | static 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 | ||
339 | static 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 |