From: Chaitanya Kulkarni <kch@nvidia.com>
To: <mst@redhat.com>, <jasowang@redhat.com>, <pbonzini@redhat.com>,
<stefanha@redhat.com>
Cc: <virtualization@lists.linux-foundation.org>,
<linux-block@vger.kernel.org>,
Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH 1/4] virtio-blk: remove additional check in fast path
Date: Tue, 19 Apr 2022 21:10:50 -0700 [thread overview]
Message-ID: <20220420041053.7927-2-kch@nvidia.com> (raw)
In-Reply-To: <20220420041053.7927-1-kch@nvidia.com>
The function virtblk_setup_cmd() calls
virtblk_setup_discard_write_zeroes() once we process the block layer
request operation setup in the switch. Even though it saves duplicate
call for REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES it adds additional check
in the fast path that is redundent since we already have a switch case
for both REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES.
Move the call virtblk_setup_discard_write_zeroes() into switch case
label of REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES and avoid duplicate
branch in the fast path.
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
drivers/block/virtio_blk.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 6ccf15253dee..b77711e73422 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -223,10 +223,14 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
break;
case REQ_OP_DISCARD:
type = VIRTIO_BLK_T_DISCARD;
+ if (virtblk_setup_discard_write_zeroes(req, unmap))
+ return BLK_STS_RESOURCE;
break;
case REQ_OP_WRITE_ZEROES:
type = VIRTIO_BLK_T_WRITE_ZEROES;
unmap = !(req->cmd_flags & REQ_NOUNMAP);
+ if (virtblk_setup_discard_write_zeroes(req, unmap))
+ return BLK_STS_RESOURCE;
break;
case REQ_OP_DRV_IN:
type = VIRTIO_BLK_T_GET_ID;
@@ -239,11 +243,6 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
vbr->out_hdr.type = cpu_to_virtio32(vdev, type);
vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
- if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES) {
- if (virtblk_setup_discard_write_zeroes(req, unmap))
- return BLK_STS_RESOURCE;
- }
-
return 0;
}
--
2.29.0
next prev parent reply other threads:[~2022-04-20 4:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 4:10 [PATCH 0/4] virtio-blk: small cleanup Chaitanya Kulkarni
2022-04-20 4:10 ` Chaitanya Kulkarni [this message]
2022-04-20 14:54 ` [PATCH 1/4] virtio-blk: remove additional check in fast path Stefan Hajnoczi
2022-04-20 14:54 ` Stefan Hajnoczi
2022-04-21 21:51 ` Chaitanya Kulkarni
2022-04-20 4:10 ` [PATCH 2/4] virtio-blk: don't add a new line Chaitanya Kulkarni
2022-04-20 15:04 ` Stefan Hajnoczi
2022-04-20 15:04 ` Stefan Hajnoczi
2022-04-21 21:52 ` Chaitanya Kulkarni
2022-04-20 4:10 ` [PATCH 3/4] virtio-blk: avoid function call in the fast path Chaitanya Kulkarni
2022-04-20 15:16 ` Stefan Hajnoczi
2022-04-20 15:16 ` Stefan Hajnoczi
2022-04-21 21:55 ` Chaitanya Kulkarni
2022-04-20 4:10 ` [PATCH 4/4] virtio-blk: remove deprecated ida_simple_XXX() Chaitanya Kulkarni
2022-04-20 15:19 ` Stefan Hajnoczi
2022-04-20 15:19 ` Stefan Hajnoczi
2022-04-21 21:56 ` [PATCH 0/4] virtio-blk: small cleanup Chaitanya Kulkarni
2022-04-22 14:56 ` Stefan Hajnoczi
2022-04-22 14:56 ` Stefan Hajnoczi
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=20220420041053.7927-2-kch@nvidia.com \
--to=kch@nvidia.com \
--cc=jasowang@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.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.