@@ -447,43 +447,30 @@ static int bulk_req_safe_read(
447
447
return n ;
448
448
}
449
449
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 )
452
451
{
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 );
481
456
}
457
+ blk_mq_end_request (io_req -> req , io_req -> error );
458
+ kfree (io_req );
482
459
}
483
460
484
461
static irqreturn_t ubd_intr (int irq , void * dev )
485
462
{
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 );
487
474
return IRQ_HANDLED ;
488
475
}
489
476
0 commit comments