Skip to content

Commit

Permalink
dm: Refactor is_abnormal_io()
Browse files Browse the repository at this point in the history
Use a single switch-case to simplify is_abnormal_io() and make this
function more readable and easier to modify.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240704052816.623865-3-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
damien-lemoal authored and axboe committed Jul 5, 2024
1 parent f4d5dc3 commit ae7e965
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,20 +1598,18 @@ static void __send_abnormal_io(struct clone_info *ci, struct dm_target *ti,

static bool is_abnormal_io(struct bio *bio)
{
enum req_op op = bio_op(bio);

if (op != REQ_OP_READ && op != REQ_OP_WRITE && op != REQ_OP_FLUSH) {
switch (op) {
case REQ_OP_DISCARD:
case REQ_OP_SECURE_ERASE:
case REQ_OP_WRITE_ZEROES:
return true;
default:
break;
}
switch (bio_op(bio)) {
case REQ_OP_READ:
case REQ_OP_WRITE:
case REQ_OP_FLUSH:
return false;
case REQ_OP_DISCARD:
case REQ_OP_SECURE_ERASE:
case REQ_OP_WRITE_ZEROES:
return true;
default:
return false;
}

return false;
}

static blk_status_t __process_abnormal_io(struct clone_info *ci,
Expand Down

0 comments on commit ae7e965

Please sign in to comment.