From: Dmitry Fomichev <dmitry.fomichev@wdc.com> To: Jens Axboe <axboe@kernel.dk>, Damien Le Moal <damien.lemoal@opensource.wdc.com>, Stefan Hajnoczi <stefanha@gmail.com>, Hannes Reinecke <hare@suse.de>, Sam Li <faithilikerun@gmail.com> Cc: linux-block@vger.kernel.org, virtio-dev@lists.oasis-open.org, Dmitry Fomichev <dmitry.fomichev@wdc.com> Subject: [PATCH 1/3] virtio-blk: use a helper to handle request queuing errors Date: Sun, 18 Sep 2022 22:29:19 -0400 [thread overview] Message-ID: <20220919022921.946344-2-dmitry.fomichev@wdc.com> (raw) In-Reply-To: <20220919022921.946344-1-dmitry.fomichev@wdc.com> Define a new helper function, virtblk_fail_to_queue(), to clean up the error handling code in virtio_queue_rq(). Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> --- drivers/block/virtio_blk.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 30255fcaf181..9a6aa94a212c 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -311,6 +311,19 @@ static void virtio_commit_rqs(struct blk_mq_hw_ctx *hctx) virtqueue_notify(vq->vq); } +static blk_status_t virtblk_fail_to_queue(struct request *req, int rc) +{ + virtblk_cleanup_cmd(req); + switch (rc) { + case -ENOSPC: + return BLK_STS_DEV_RESOURCE; + case -ENOMEM: + return BLK_STS_RESOURCE; + default: + return BLK_STS_IOERR; + } +} + static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx, struct virtio_blk *vblk, struct request *req, @@ -325,10 +338,8 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx, blk_mq_start_request(req); vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr); - if (unlikely(vbr->sg_table.nents < 0)) { - virtblk_cleanup_cmd(req); - return BLK_STS_RESOURCE; - } + if (unlikely(vbr->sg_table.nents < 0)) + return virtblk_fail_to_queue(req, -ENOMEM); return BLK_STS_OK; } @@ -360,15 +371,7 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx, blk_mq_stop_hw_queue(hctx); spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags); virtblk_unmap_data(req, vbr); - virtblk_cleanup_cmd(req); - switch (err) { - case -ENOSPC: - return BLK_STS_DEV_RESOURCE; - case -ENOMEM: - return BLK_STS_RESOURCE; - default: - return BLK_STS_IOERR; - } + return virtblk_fail_to_queue(req, err); } if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq)) -- 2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Fomichev <dmitry.fomichev@wdc.com> To: Jens Axboe <axboe@kernel.dk>, Damien Le Moal <damien.lemoal@opensource.wdc.com>, Stefan Hajnoczi <stefanha@gmail.com>, Hannes Reinecke <hare@suse.de>, Sam Li <faithilikerun@gmail.com> Cc: linux-block@vger.kernel.org, virtio-dev@lists.oasis-open.org, Dmitry Fomichev <dmitry.fomichev@wdc.com> Subject: [virtio-dev] [PATCH 1/3] virtio-blk: use a helper to handle request queuing errors Date: Sun, 18 Sep 2022 22:29:19 -0400 [thread overview] Message-ID: <20220919022921.946344-2-dmitry.fomichev@wdc.com> (raw) In-Reply-To: <20220919022921.946344-1-dmitry.fomichev@wdc.com> Define a new helper function, virtblk_fail_to_queue(), to clean up the error handling code in virtio_queue_rq(). Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> --- drivers/block/virtio_blk.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 30255fcaf181..9a6aa94a212c 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -311,6 +311,19 @@ static void virtio_commit_rqs(struct blk_mq_hw_ctx *hctx) virtqueue_notify(vq->vq); } +static blk_status_t virtblk_fail_to_queue(struct request *req, int rc) +{ + virtblk_cleanup_cmd(req); + switch (rc) { + case -ENOSPC: + return BLK_STS_DEV_RESOURCE; + case -ENOMEM: + return BLK_STS_RESOURCE; + default: + return BLK_STS_IOERR; + } +} + static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx, struct virtio_blk *vblk, struct request *req, @@ -325,10 +338,8 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx, blk_mq_start_request(req); vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr); - if (unlikely(vbr->sg_table.nents < 0)) { - virtblk_cleanup_cmd(req); - return BLK_STS_RESOURCE; - } + if (unlikely(vbr->sg_table.nents < 0)) + return virtblk_fail_to_queue(req, -ENOMEM); return BLK_STS_OK; } @@ -360,15 +371,7 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx, blk_mq_stop_hw_queue(hctx); spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags); virtblk_unmap_data(req, vbr); - virtblk_cleanup_cmd(req); - switch (err) { - case -ENOSPC: - return BLK_STS_DEV_RESOURCE; - case -ENOMEM: - return BLK_STS_RESOURCE; - default: - return BLK_STS_IOERR; - } + return virtblk_fail_to_queue(req, err); } if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq)) -- 2.34.1 --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
next prev parent reply other threads:[~2022-09-19 2:29 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-19 2:29 [PATCH 0/3] virtio-blk: support zoned block devices Dmitry Fomichev 2022-09-19 2:29 ` [virtio-dev] " Dmitry Fomichev 2022-09-19 2:29 ` Dmitry Fomichev [this message] 2022-09-19 2:29 ` [virtio-dev] [PATCH 1/3] virtio-blk: use a helper to handle request queuing errors Dmitry Fomichev 2022-09-19 2:29 ` [PATCH 2/3] virtio-blk: add a placeholder for secure erase config Dmitry Fomichev 2022-09-19 2:29 ` [virtio-dev] " Dmitry Fomichev 2022-09-19 2:29 ` [PATCH 3/3] virtio-blk: add support for zoned block devices Dmitry Fomichev 2022-09-19 2:29 ` [virtio-dev] " Dmitry Fomichev 2022-09-19 13:41 ` Pankaj Raghav 2022-09-19 23:59 ` Damien Le Moal 2022-09-20 1:51 ` Dmitry Fomichev 2022-09-20 1:51 ` [virtio-dev] " Dmitry Fomichev 2022-09-20 8:04 ` Pankaj Raghav 2022-09-20 7:43 ` [PATCH 0/3] virtio-blk: support " Christoph Hellwig 2022-09-20 10:41 ` Stefan Hajnoczi 2022-09-21 2:33 ` Dmitry Fomichev 2022-09-21 2:33 ` [virtio-dev] " Dmitry Fomichev
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=20220919022921.946344-2-dmitry.fomichev@wdc.com \ --to=dmitry.fomichev@wdc.com \ --cc=axboe@kernel.dk \ --cc=damien.lemoal@opensource.wdc.com \ --cc=faithilikerun@gmail.com \ --cc=hare@suse.de \ --cc=linux-block@vger.kernel.org \ --cc=stefanha@gmail.com \ --cc=virtio-dev@lists.oasis-open.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: linkBe 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.