diff options
Diffstat (limited to 'fs/bio-integrity.c')
| -rw-r--r-- | fs/bio-integrity.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c index c3e174b35fe6..19caf7c962ac 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c | |||
| @@ -107,7 +107,8 @@ void bio_integrity_free(struct bio *bio, struct bio_set *bs) | |||
| 107 | BUG_ON(bip == NULL); | 107 | BUG_ON(bip == NULL); |
| 108 | 108 | ||
| 109 | /* A cloned bio doesn't own the integrity metadata */ | 109 | /* A cloned bio doesn't own the integrity metadata */ |
| 110 | if (!bio_flagged(bio, BIO_CLONED) && bip->bip_buf != NULL) | 110 | if (!bio_flagged(bio, BIO_CLONED) && !bio_flagged(bio, BIO_FS_INTEGRITY) |
| 111 | && bip->bip_buf != NULL) | ||
| 111 | kfree(bip->bip_buf); | 112 | kfree(bip->bip_buf); |
| 112 | 113 | ||
| 113 | mempool_free(bip->bip_vec, bs->bvec_pools[bip->bip_pool]); | 114 | mempool_free(bip->bip_vec, bs->bvec_pools[bip->bip_pool]); |
| @@ -150,6 +151,24 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, | |||
| 150 | } | 151 | } |
| 151 | EXPORT_SYMBOL(bio_integrity_add_page); | 152 | EXPORT_SYMBOL(bio_integrity_add_page); |
| 152 | 153 | ||
| 154 | static int bdev_integrity_enabled(struct block_device *bdev, int rw) | ||
| 155 | { | ||
| 156 | struct blk_integrity *bi = bdev_get_integrity(bdev); | ||
| 157 | |||
| 158 | if (bi == NULL) | ||
| 159 | return 0; | ||
| 160 | |||
| 161 | if (rw == READ && bi->verify_fn != NULL && | ||
| 162 | (bi->flags & INTEGRITY_FLAG_READ)) | ||
| 163 | return 1; | ||
| 164 | |||
| 165 | if (rw == WRITE && bi->generate_fn != NULL && | ||
| 166 | (bi->flags & INTEGRITY_FLAG_WRITE)) | ||
| 167 | return 1; | ||
| 168 | |||
| 169 | return 0; | ||
| 170 | } | ||
| 171 | |||
| 153 | /** | 172 | /** |
| 154 | * bio_integrity_enabled - Check whether integrity can be passed | 173 | * bio_integrity_enabled - Check whether integrity can be passed |
| 155 | * @bio: bio to check | 174 | * @bio: bio to check |
| @@ -313,6 +332,14 @@ static void bio_integrity_generate(struct bio *bio) | |||
| 313 | } | 332 | } |
| 314 | } | 333 | } |
| 315 | 334 | ||
| 335 | static inline unsigned short blk_integrity_tuple_size(struct blk_integrity *bi) | ||
| 336 | { | ||
| 337 | if (bi) | ||
| 338 | return bi->tuple_size; | ||
| 339 | |||
| 340 | return 0; | ||
| 341 | } | ||
| 342 | |||
| 316 | /** | 343 | /** |
| 317 | * bio_integrity_prep - Prepare bio for integrity I/O | 344 | * bio_integrity_prep - Prepare bio for integrity I/O |
| 318 | * @bio: bio to prepare | 345 | * @bio: bio to prepare |
