• Yu Kuai's avatar
    blk-mq: fix io hung due to missing commit_rqs · 77864ed6
    Yu Kuai authored
    commit 65fac0d5 upstream.
    
    Currently, in virtio_scsi, if 'bd->last' is not set to true while
    dispatching request, such io will stay in driver's queue, and driver
    will wait for block layer to dispatch more rqs. However, if block
    layer failed to dispatch more rq, it should trigger commit_rqs to
    inform driver.
    
    There is a problem in blk_mq_try_issue_list_directly() that commit_rqs
    won't be called:
    
    // assume that queue_depth is set to 1, list contains two rq
    blk_mq_try_issue_list_directly
     blk_mq_request_issue_directly
     // dispatch first rq
     // last is false
      __blk_mq_try_issue_directly
       blk_mq_get_dispatch_budget
       // succeed to get first budget
       __blk_mq_issue_directly
        scsi_queue_rq
         cmd->flags |= SCMD_LAST
          virtscsi_queuecommand
           kick = (sc->flags & SCMD_LAST) != 0
           // kick is false, first rq won't issue to disk
     queued++
    
     blk_mq_request_issue_directly
     // dispatch second rq
      __blk_mq_try_issue_d...
    77864ed6
blk-mq.c 101 KB