From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Richard Weinberger" <richard@nod.at>,
"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
"Johannes Berg" <johannes@sipsolutions.net>,
"Josef Bacik" <josef@toxicpanda.com>,
"Ilya Dryomov" <idryomov@gmail.com>,
"Dongsheng Yang" <dongsheng.yang@easystack.cn>,
"Roger Pau Monné" <roger.pau@citrix.com>,
linux-um@lists.infradead.org, linux-block@vger.kernel.org,
nbd@other.debian.org, ceph-devel@vger.kernel.org,
xen-devel@lists.xenproject.org, linux-scsi@vger.kernel.org
Subject: [PATCH 01/14] ubd: refactor the interrupt handler
Date: Fri, 31 May 2024 09:47:56 +0200 [thread overview]
Message-ID: <20240531074837.1648501-2-hch@lst.de> (raw)
In-Reply-To: <20240531074837.1648501-1-hch@lst.de>
Instead of a separate handler function that leaves no work in the
interrupt hanler itself, split out a per-request end I/O helper and
clean up the coding style and variable naming while we're at it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/um/drivers/ubd_kern.c | 49 ++++++++++++++------------------------
1 file changed, 18 insertions(+), 31 deletions(-)
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index ef805eaa9e013d..0c9542d58c01b7 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -447,43 +447,30 @@ static int bulk_req_safe_read(
return n;
}
-/* Called without dev->lock held, and only in interrupt context. */
-static void ubd_handler(void)
+static void ubd_end_request(struct io_thread_req *io_req)
{
- int n;
- int count;
-
- while(1){
- n = bulk_req_safe_read(
- thread_fd,
- irq_req_buffer,
- &irq_remainder,
- &irq_remainder_size,
- UBD_REQ_BUFFER_SIZE
- );
- if (n < 0) {
- if(n == -EAGAIN)
- break;
- printk(KERN_ERR "spurious interrupt in ubd_handler, "
- "err = %d\n", -n);
- return;
- }
- for (count = 0; count < n/sizeof(struct io_thread_req *); count++) {
- struct io_thread_req *io_req = (*irq_req_buffer)[count];
-
- if ((io_req->error == BLK_STS_NOTSUPP) && (req_op(io_req->req) == REQ_OP_DISCARD)) {
- blk_queue_max_discard_sectors(io_req->req->q, 0);
- blk_queue_max_write_zeroes_sectors(io_req->req->q, 0);
- }
- blk_mq_end_request(io_req->req, io_req->error);
- kfree(io_req);
- }
+ if (io_req->error == BLK_STS_NOTSUPP &&
+ req_op(io_req->req) == REQ_OP_DISCARD) {
+ blk_queue_max_discard_sectors(io_req->req->q, 0);
+ blk_queue_max_write_zeroes_sectors(io_req->req->q, 0);
}
+ blk_mq_end_request(io_req->req, io_req->error);
+ kfree(io_req);
}
static irqreturn_t ubd_intr(int irq, void *dev)
{
- ubd_handler();
+ int len, i;
+
+ while ((len = bulk_req_safe_read(thread_fd, irq_req_buffer,
+ &irq_remainder, &irq_remainder_size,
+ UBD_REQ_BUFFER_SIZE)) >= 0) {
+ for (i = 0; i < len / sizeof(struct io_thread_req *); i++)
+ ubd_end_request((*irq_req_buffer)[i]);
+ }
+
+ if (len < 0 && len != -EAGAIN)
+ pr_err("spurious interrupt in %s, err = %d\n", __func__, len);
return IRQ_HANDLED;
}
--
2.43.0
next prev parent reply other threads:[~2024-05-31 7:48 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 7:47 convert the SCSI ULDs to the atomic queue limits API v2 Christoph Hellwig
2024-05-31 7:47 ` Christoph Hellwig [this message]
2024-06-14 1:35 ` [PATCH 01/14] ubd: refactor the interrupt handler Martin K. Petersen
2024-06-14 7:28 ` Anton Ivanov
2024-05-31 7:47 ` [PATCH 02/14] ubd: untagle discard vs write zeroes not support handling Christoph Hellwig
2024-06-14 1:36 ` Martin K. Petersen
2024-06-14 7:29 ` Anton Ivanov
2024-05-31 7:47 ` [PATCH 03/14] rbd: increase io_opt again Christoph Hellwig
2024-05-31 9:08 ` Ilya Dryomov
2024-06-14 1:36 ` Martin K. Petersen
2024-05-31 7:47 ` [PATCH 04/14] block: take io_opt and io_min into account for max_sectors Christoph Hellwig
2024-05-31 9:11 ` Ilya Dryomov
2024-06-14 1:40 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 05/14] sd: simplify the ZBC case in provisioning_mode_store Christoph Hellwig
2024-06-14 1:41 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 06/14] sd: add a sd_disable_discard helper Christoph Hellwig
2024-06-14 1:41 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 07/14] sd: add a sd_disable_write_same helper Christoph Hellwig
2024-06-14 1:42 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 08/14] sd: simplify the disable case in sd_config_discard Christoph Hellwig
2024-06-14 1:43 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 09/14] sd: factor out a sd_discard_mode helper Christoph Hellwig
2024-06-14 1:43 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 10/14] sd: cleanup zoned queue limits initialization Christoph Hellwig
2024-06-14 1:44 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 11/14] sd: convert to the atomic queue limits API Christoph Hellwig
2024-05-31 11:34 ` John Garry
2024-06-14 1:47 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 12/14] sr: " Christoph Hellwig
2024-06-14 1:48 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 13/14] block: remove unused " Christoph Hellwig
2024-05-31 11:12 ` John Garry
[not found] ` <CGME20240531140203epcas5p1fed913b6729b684e0916dfd62787be13@epcas5p1.samsung.com>
2024-05-31 13:55 ` Nitesh Shetty
2024-06-14 1:48 ` Martin K. Petersen
2024-05-31 7:48 ` [PATCH 14/14] block: add special APIs for run-time disabling of discard and friends Christoph Hellwig
[not found] ` <CGME20240531110559epcas5p1f41d7d904ed46260837c38a57fa32d86@epcas5p1.samsung.com>
2024-05-31 10:58 ` Nitesh Shetty
2024-05-31 11:12 ` John Garry
2024-06-14 1:49 ` Martin K. Petersen
2024-05-31 11:29 ` convert the SCSI ULDs to the atomic queue limits API v2 John Garry
2024-05-31 12:07 ` Martin K. Petersen
2024-05-31 12:23 ` Christoph Hellwig
2024-06-14 16:23 ` Jens Axboe
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=20240531074837.1648501-2-hch@lst.de \
--to=hch@lst.de \
--cc=anton.ivanov@cambridgegreys.com \
--cc=axboe@kernel.dk \
--cc=ceph-devel@vger.kernel.org \
--cc=dongsheng.yang@easystack.cn \
--cc=idryomov@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=nbd@other.debian.org \
--cc=richard@nod.at \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).