public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* two small integrity cleanups
@ 2017-08-09 15:48 Christoph Hellwig
  2017-08-09 15:48 ` [PATCH 1/2] bio-integrity: move the bio integrity profile check earlier in bio_integrity_prep Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-09 15:48 UTC (permalink / raw)
  To: axboe; +Cc: mpatocka, gmazyland, martin.petersen, linux-block, dm-devel

Found these while coming up with the fixes just sent.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] bio-integrity: move the bio integrity profile check earlier in bio_integrity_prep
  2017-08-09 15:48 two small integrity cleanups Christoph Hellwig
@ 2017-08-09 15:48 ` Christoph Hellwig
  2017-08-09 15:48 ` [PATCH 2/2] dm-crypt: don't mess with BIP_BLOCK_INTEGRITY Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-09 15:48 UTC (permalink / raw)
  To: axboe; +Cc: mpatocka, gmazyland, martin.petersen, linux-block, dm-devel

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio-integrity.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 9b1ea478577b..fafd19c540b0 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -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))
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] dm-crypt: don't mess with BIP_BLOCK_INTEGRITY
  2017-08-09 15:48 two small integrity cleanups Christoph Hellwig
  2017-08-09 15:48 ` [PATCH 1/2] bio-integrity: move the bio integrity profile check earlier in bio_integrity_prep Christoph Hellwig
@ 2017-08-09 15:48 ` Christoph Hellwig
  2017-08-09 16:00 ` two small integrity cleanups Jens Axboe
  2017-08-09 16:22 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-09 15:48 UTC (permalink / raw)
  To: axboe; +Cc: mpatocka, gmazyland, martin.petersen, linux-block, dm-devel

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm-crypt.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index cdf6b1e12460..73c2e270cda6 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -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))
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: two small integrity cleanups
  2017-08-09 15:48 two small integrity cleanups Christoph Hellwig
  2017-08-09 15:48 ` [PATCH 1/2] bio-integrity: move the bio integrity profile check earlier in bio_integrity_prep Christoph Hellwig
  2017-08-09 15:48 ` [PATCH 2/2] dm-crypt: don't mess with BIP_BLOCK_INTEGRITY Christoph Hellwig
@ 2017-08-09 16:00 ` Jens Axboe
  2017-08-09 16:22 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2017-08-09 16:00 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: mpatocka, gmazyland, martin.petersen, linux-block, dm-devel

On 08/09/2017 09:48 AM, Christoph Hellwig wrote:
> Found these while coming up with the fixes just sent.

Added for 4.14.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: two small integrity cleanups
  2017-08-09 15:48 two small integrity cleanups Christoph Hellwig
                   ` (2 preceding siblings ...)
  2017-08-09 16:00 ` two small integrity cleanups Jens Axboe
@ 2017-08-09 16:22 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-08-09 16:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, mpatocka, gmazyland, martin.petersen, linux-block,
	dm-devel


Christoph,

> Found these while coming up with the fixes just sent.

Also OK.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-09 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-09 15:48 two small integrity cleanups Christoph Hellwig
2017-08-09 15:48 ` [PATCH 1/2] bio-integrity: move the bio integrity profile check earlier in bio_integrity_prep Christoph Hellwig
2017-08-09 15:48 ` [PATCH 2/2] dm-crypt: don't mess with BIP_BLOCK_INTEGRITY Christoph Hellwig
2017-08-09 16:00 ` two small integrity cleanups Jens Axboe
2017-08-09 16:22 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox