From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>,
luojiaxing <luojiaxing@huawei.com>
Subject: Re: [PATCH] blk-mq: avoid to iterate over stale request
Date: Tue, 7 Sep 2021 09:14:04 +0800 [thread overview]
Message-ID: <YTa83Domqx8vWhwE@T590> (raw)
In-Reply-To: <5bf71295-b729-2ec7-3913-afad3c5d2ef7@acm.org>
On Mon, Sep 06, 2021 at 03:44:08PM -0700, Bart Van Assche wrote:
> On 9/5/21 23:50, Ming Lei wrote:
> > - if (!rq || !refcount_inc_not_zero(&rq->ref))
> > + if (!rq || rq->tag != bitnr || !refcount_inc_not_zero(&rq->ref))
> > rq = NULL;
>
> Shouldn't the rq->tag != bitnr test happen after the refcount has been
> incremented since otherwise rq->tag can change after it has been read and
> before the refcount is incremented?
rq->tag can change too after its refcount is grabbed. If the rq is released
during the iterating, either SCMD_STATE_INFLIGHT is cleared or
refcount_inc_not_zero() fails. So this way works.
The use case for scsi_host_queue_ready() and scsi EH handling is a bit
special. For others, either the iterating needn't to be exact, or queue
is frozen.
Thanks,
Ming
next prev parent reply other threads:[~2021-09-07 1:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-06 6:50 [PATCH] blk-mq: avoid to iterate over stale request Ming Lei
2021-09-06 22:44 ` Bart Van Assche
2021-09-07 1:14 ` Ming Lei [this message]
2021-09-13 1:26 ` Ming Lei
2021-09-13 1:31 ` Jens Axboe
2021-12-14 18:41 ` Kashyap Desai
2021-12-15 3:36 ` Ming Lei
2021-12-15 7:30 ` Kashyap Desai
2021-12-15 8:02 ` Ming Lei
2021-12-15 8:45 ` Kashyap Desai
2021-12-15 12:56 ` Ming Lei
2021-12-16 11:55 ` Kashyap Desai
2021-12-16 12:50 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YTa83Domqx8vWhwE@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=luojiaxing@huawei.com \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox