mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 03:27:30 -04:00
block: switch on bio operation in bio_integrity_prep
Use a single switch to perform read and write specific checks and exit early for other operations instead of having two checks using different predicates. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20240626045950.189758-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
dac18fabba
commit
df3c485e0e
@@ -435,9 +435,6 @@ bool bio_integrity_prep(struct bio *bio)
|
|||||||
if (!bi)
|
if (!bi)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (bio_op(bio) != REQ_OP_READ && bio_op(bio) != REQ_OP_WRITE)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!bio_sectors(bio))
|
if (!bio_sectors(bio))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -445,10 +442,12 @@ bool bio_integrity_prep(struct bio *bio)
|
|||||||
if (bio_integrity(bio))
|
if (bio_integrity(bio))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (bio_data_dir(bio) == READ) {
|
switch (bio_op(bio)) {
|
||||||
|
case REQ_OP_READ:
|
||||||
if (bi->flags & BLK_INTEGRITY_NOVERIFY)
|
if (bi->flags & BLK_INTEGRITY_NOVERIFY)
|
||||||
return true;
|
return true;
|
||||||
} else {
|
break;
|
||||||
|
case REQ_OP_WRITE:
|
||||||
if (bi->flags & BLK_INTEGRITY_NOGENERATE)
|
if (bi->flags & BLK_INTEGRITY_NOGENERATE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -459,6 +458,9 @@ bool bio_integrity_prep(struct bio *bio)
|
|||||||
*/
|
*/
|
||||||
if (bi->csum_type == BLK_INTEGRITY_CSUM_NONE)
|
if (bi->csum_type == BLK_INTEGRITY_CSUM_NONE)
|
||||||
gfp |= __GFP_ZERO;
|
gfp |= __GFP_ZERO;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate kernel buffer for protection data */
|
/* Allocate kernel buffer for protection data */
|
||||||
|
|||||||
Reference in New Issue
Block a user