Skip to content

Commit df3c485

Browse files
Christoph Hellwigaxboe
authored andcommitted
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 <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dac18fa commit df3c485

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

block/bio-integrity.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,20 +435,19 @@ bool bio_integrity_prep(struct bio *bio)
435435
if (!bi)
436436
return true;
437437

438-
if (bio_op(bio) != REQ_OP_READ && bio_op(bio) != REQ_OP_WRITE)
439-
return true;
440-
441438
if (!bio_sectors(bio))
442439
return true;
443440

444441
/* Already protected? */
445442
if (bio_integrity(bio))
446443
return true;
447444

448-
if (bio_data_dir(bio) == READ) {
445+
switch (bio_op(bio)) {
446+
case REQ_OP_READ:
449447
if (bi->flags & BLK_INTEGRITY_NOVERIFY)
450448
return true;
451-
} else {
449+
break;
450+
case REQ_OP_WRITE:
452451
if (bi->flags & BLK_INTEGRITY_NOGENERATE)
453452
return true;
454453

@@ -459,6 +458,9 @@ bool bio_integrity_prep(struct bio *bio)
459458
*/
460459
if (bi->csum_type == BLK_INTEGRITY_CSUM_NONE)
461460
gfp |= __GFP_ZERO;
461+
break;
462+
default:
463+
return true;
462464
}
463465

464466
/* Allocate kernel buffer for protection data */

0 commit comments

Comments
 (0)