Skip to contentSkip to conversation

two small integrity cleanups

PATCH New Christoph Hellwig 3 participants 5 messages Aug 9, 2017

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 bio-integrity: move the bio integrity profile check earlier in bio_integrity_prep

This makes the code more obvious, and moves the most likely branch first in the function.

---
 block/bio-integrity.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
block/bio-integrity.c +3 -3
index 9b1ea478577b..fafd19c540b0 100644
@@ -246,6 +246,9 @@ bool bio_integrity_prep(struct bio *bio)
 	blk_status_t status;
 
 	bi = bdev_get_integrity(bio->bi_bdev);
+	if (!bi)
+		return true;
+
 	q = bdev_get_queue(bio->bi_bdev);
 	if (bio_op(bio) != REQ_OP_READ && bio_op(bio) != REQ_OP_WRITE)
 		return true;
@@ -257,9 +260,6 @@ bool bio_integrity_prep(struct bio *bio)
 	if (bio_integrity(bio))
 		return true;
 
-	if (bi == NULL)
-		return true;
-
 	if (bio_data_dir(bio) == READ) {
 		if (!bi->profile->verify_fn ||
 		    !(bi->flags & BLK_INTEGRITY_VERIFY))
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/2 dm-crypt: don't mess with BIP_BLOCK_INTEGRITY

In reply to Christoph Hellwig

This flag is never set right after calling bio_integrity_alloc, so don't clear it and confuse the reader.

---
 drivers/md/dm-crypt.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/md/dm-crypt.c +0 -3
index cdf6b1e12460..73c2e270cda6 100644
@@ -933,9 +933,6 @@ static int dm_crypt_integrity_io_alloc(struct dm_crypt_io *io, struct bio *bio)
 	bip->bip_iter.bi_size = tag_len;
 	bip->bip_iter.bi_sector = io->cc->start + io->sector;
 
-	/* We own the metadata, do not let bio_free to release it */
-	bip->bip_flags &= ~BIP_BLOCK_INTEGRITY;
-
 	ret = bio_integrity_add_page(bio, virt_to_page(io->integrity_metadata),
 				     tag_len, offset_in_page(io->integrity_metadata));
 	if (unlikely(ret != tag_len))
Signature · 1 line
2.11.0