From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, dm-devel@lists.linux.dev,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Ming Lei <ming.lei@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 2/5] dm: Refactor is_abnormal_io()
Date: Thu, 4 Jul 2024 08:39:29 +0900 [thread overview]
Message-ID: <20240703233932.545228-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20240703233932.545228-1-dlemoal@kernel.org>
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>
---
drivers/md/dm.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 7d107ae06e1a..0d80caccbd9e 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -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,
--
2.45.2
next prev parent reply other threads:[~2024-07-03 23:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 23:39 [PATCH 0/5] Remove zone reset all emulation Damien Le Moal
2024-07-03 23:39 ` [PATCH 1/5] null_blk: Introduce the zone_full parameter Damien Le Moal
2024-07-04 5:13 ` Christoph Hellwig
2024-07-03 23:39 ` Damien Le Moal [this message]
2024-07-04 5:13 ` [PATCH 2/5] dm: Refactor is_abnormal_io() Christoph Hellwig
2024-07-03 23:39 ` [PATCH 3/5] dm: handle REQ_OP_ZONE_RESET_ALL Damien Le Moal
2024-07-04 5:17 ` Christoph Hellwig
2024-07-03 23:39 ` [PATCH 4/5] block: Remove REQ_OP_ZONE_RESET_ALL emulation Damien Le Moal
2024-07-04 0:07 ` Ed Tsai (蔡宗軒)
2024-07-04 1:14 ` Damien Le Moal
2024-07-04 5:21 ` Christoph Hellwig
2024-07-03 23:39 ` [PATCH 5/5] block: Remove blk_alloc_zone_bitmap() Damien Le Moal
2024-07-04 5:22 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240703233932.545228-3-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=dm-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=jasowang@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=mpatocka@redhat.com \
--cc=mst@redhat.com \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.