lkml.org 
[lkml]   [2021]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 2/6] nbd: make sure request completion won't concurrent
On Wed, Sep 15, 2021 at 05:20:06PM +0800, Yu Kuai wrote:
> commit cddce0116058 ("nbd: Aovid double completion of a request")
> try to fix that nbd_clear_que() and recv_work() can complete a
> request concurrently. However, the problem still exists:
>
> t1 t2 t3
>
> nbd_disconnect_and_put
> flush_workqueue
> recv_work
> blk_mq_complete_request
> blk_mq_complete_request_remote -> this is true
> WRITE_ONCE(rq->state, MQ_RQ_COMPLETE)
> blk_mq_raise_softirq
> blk_done_softirq
> blk_complete_reqs
> nbd_complete_rq
> blk_mq_end_request
> blk_mq_free_request
> WRITE_ONCE(rq->state, MQ_RQ_IDLE)
> nbd_clear_que
> blk_mq_tagset_busy_iter
> nbd_clear_req
> __blk_mq_free_request
> blk_mq_put_tag
> blk_mq_complete_request -> complete again
>
> There are three places where request can be completed in nbd:
> recv_work(), nbd_clear_que() and nbd_xmit_timeout(). Since they
> all hold cmd->lock before completing the request, it's easy to
> avoid the problem by setting and checking a cmd flag.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---

Reviewed-by: Ming Lei <ming.lei@redhat.com>

--
Ming

\
 
 \ /
  Last update: 2021-09-16 09:54    [W:0.076 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site