Skip to content

Commit 5db755f

Browse files
Christoph Hellwigaxboe
authored andcommitted
ubd: refactor the interrupt handler
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 <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Acked-By: Anton Ivanov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 83a7eef commit 5db755f

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

arch/um/drivers/ubd_kern.c

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -447,43 +447,30 @@ static int bulk_req_safe_read(
447447
return n;
448448
}
449449

450-
/* Called without dev->lock held, and only in interrupt context. */
451-
static void ubd_handler(void)
450+
static void ubd_end_request(struct io_thread_req *io_req)
452451
{
453-
int n;
454-
int count;
455-
456-
while(1){
457-
n = bulk_req_safe_read(
458-
thread_fd,
459-
irq_req_buffer,
460-
&irq_remainder,
461-
&irq_remainder_size,
462-
UBD_REQ_BUFFER_SIZE
463-
);
464-
if (n < 0) {
465-
if(n == -EAGAIN)
466-
break;
467-
printk(KERN_ERR "spurious interrupt in ubd_handler, "
468-
"err = %d\n", -n);
469-
return;
470-
}
471-
for (count = 0; count < n/sizeof(struct io_thread_req *); count++) {
472-
struct io_thread_req *io_req = (*irq_req_buffer)[count];
473-
474-
if ((io_req->error == BLK_STS_NOTSUPP) && (req_op(io_req->req) == REQ_OP_DISCARD)) {
475-
blk_queue_max_discard_sectors(io_req->req->q, 0);
476-
blk_queue_max_write_zeroes_sectors(io_req->req->q, 0);
477-
}
478-
blk_mq_end_request(io_req->req, io_req->error);
479-
kfree(io_req);
480-
}
452+
if (io_req->error == BLK_STS_NOTSUPP &&
453+
req_op(io_req->req) == REQ_OP_DISCARD) {
454+
blk_queue_max_discard_sectors(io_req->req->q, 0);
455+
blk_queue_max_write_zeroes_sectors(io_req->req->q, 0);
481456
}
457+
blk_mq_end_request(io_req->req, io_req->error);
458+
kfree(io_req);
482459
}
483460

484461
static irqreturn_t ubd_intr(int irq, void *dev)
485462
{
486-
ubd_handler();
463+
int len, i;
464+
465+
while ((len = bulk_req_safe_read(thread_fd, irq_req_buffer,
466+
&irq_remainder, &irq_remainder_size,
467+
UBD_REQ_BUFFER_SIZE)) >= 0) {
468+
for (i = 0; i < len / sizeof(struct io_thread_req *); i++)
469+
ubd_end_request((*irq_req_buffer)[i]);
470+
}
471+
472+
if (len < 0 && len != -EAGAIN)
473+
pr_err("spurious interrupt in %s, err = %d\n", __func__, len);
487474
return IRQ_HANDLED;
488475
}
489476

0 commit comments

Comments
 (0)