• Ming Lei's avatar
    blk-mq: grab .q_usage_counter when queuing request from plug code path · e87eb301
    Ming Lei authored
    Just like aio/io_uring, we need to grab 2 refcount for queuing one
    request, one is for submission, another is for completion.
    
    If the request isn't queued from plug code path, the refcount grabbed
    in generic_make_request() serves for submission. In theroy, this
    refcount should have been released after the sumission(async run queue)
    is done. blk_freeze_queue() works with blk_sync_queue() together
    for avoiding race between cleanup queue and IO submission, given async
    run queue activities are canceled because hctx->run_work is scheduled with
    the refcount held, so it is fine to not hold the refcount when
    running the run queue work function for dispatch IO.
    
    However, if request is staggered into plug list, and finally queued
    from plug code path, the refcount in submission side is actually missed.
    And we may start to run queue after queue is removed because the queue's
    kobject refcount isn't guaranteed to be grabbed in flushing plug list
    con...
    e87eb301
blk-mq-sched.c 13.5 KB