linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
	linux-block <linux-block@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	Suganath Prabu Subramani  <suganath-prabu.subramani@broadcom.com>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Subject: Re: +AFs-PATCH+AF0- blk-mq: Set request mapping to NULL in blk+AF8-mq+AF8-put+AF8-driver+AF8-tag
Date: Thu, 6 Dec 2018 08:33:24 +0800	[thread overview]
Message-ID: <20181206003323.GB3015@ming.t460p> (raw)
In-Reply-To: <ce2cdcee7e8d8e21cc8398a882b9d6e3@mail.gmail.com>

On Tue, Dec 04, 2018 at 11:48:48PM +0530, Kashyap Desai wrote:
> > -----Original Message-----
> > From: Bart Van Assche [mailto:bvanassche@acm.org]
> > Sent: Tuesday, December 4, 2018 10:45 PM
> > To: Kashyap Desai; linux-block; Jens Axboe; Ming Lei; linux-scsi
> > Cc: Suganath Prabu Subramani; Sreekanth Reddy; Sathya Prakash Veerichetty
> > Subject: Re: [PATCH] blk-mq: Set request mapping to NULL in
> > blk_mq_put_driver_tag
> >
> > On Tue, 2018-12-04 at 22:17 +0530, Kashyap Desai wrote:
> > > + Linux-scsi
> > >
> > > > > diff --git a/block/blk-mq.h b/block/blk-mq.h
> > > > > index 9497b47..57432be 100644
> > > > > --- a/block/blk-mq.h
> > > > > +++ b/block/blk-mq.h
> > > > > @@ -175,6 +175,7 @@ static inline bool
> > > > > blk_mq_get_dispatch_budget(struct blk_mq_hw_ctx *hctx)
> > > > >   static inline void __blk_mq_put_driver_tag(struct blk_mq_hw_ctx
> > *hctx,
> > > > >                          struct request *rq)
> > > > >   {
> > > > > +    hctx->tags->rqs[rq->tag] = NULL;
> > > > >       blk_mq_put_tag(hctx, hctx->tags, rq->mq_ctx, rq->tag);
> > > > >       rq->tag = -1;
> > > >
> > > > No SCSI driver should call scsi_host_find_tag() after a request has
> > > > finished. The above patch introduces yet another race and hence can't
> > > > be
> > > > a proper fix.
> > >
> > > Bart, many scsi drivers use scsi_host_find_tag() to traverse max tag_id
> > > to
> > > find out pending IO in firmware.
> > > One of the use case is -  HBA firmware recovery.  In case of firmware
> > > recovery, driver may require to traverse the list and return back
> > > pending
> > > scsi command to SML for retry.
> > > I quickly grep the scsi code and found that snic_scsi, qla4xxx, fnic,
> > > mpt3sas are using API scsi_host_find_tag for the same purpose.
> > >
> > > Without this patch, we hit very basic kernel panic due to page fault.
> > > This
> > > is not an issue in non-mq code path. Non-mq path use
> > > blk_map_queue_find_tag() and that particular API does not provide stale
> > > requests.
> >
> > As I wrote before, your patch doesn't fix the race you described but only
> > makes the race window smaller.
> Hi Bart,
> 
> Let me explain the issue. It is not a race, but very straight issue.  Let's
> say we have one scsi_device /dev/sda and total IO submitted + completed are
> some number 100.
> All the 100 IO is *completed*.   Now, As part of Firmware recovery, driver
> tries to find our outstanding IOs using scsi_host_find_tag().

If the 'tag' passed to scsi_host_find_tag() is valid, I think there
shouldn't have such issue.

If you want to find outstanding IOs, maybe you can try blk_mq_queue_tag_busy_iter()
or blk_mq_tagset_busy_iter(), because you may not know if the passed 'tag' to
scsi_host_find_tag() is valid or not.


Thanks,
Ming

  parent reply	other threads:[~2018-12-06  0:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 10:00 [PATCH] blk-mq: Set request mapping to NULL in blk_mq_put_driver_tag Kashyap Desai
2018-12-04 11:35 ` Ming Lei
2018-12-04 16:51   ` Kashyap Desai
2018-12-04 14:48 ` Bart Van Assche
2018-12-04 16:47   ` Kashyap Desai
2018-12-04 17:14     ` Bart Van Assche
2018-12-04 18:18       ` +AFs-PATCH+AF0- blk-mq: Set request mapping to NULL in blk+AF8-mq+AF8-put+AF8-driver+AF8-tag Kashyap Desai
2018-12-04 19:35         ` Bart Van Assche
2018-12-06  0:33         ` Ming Lei [this message]
2018-12-06  5:45           ` Kashyap Desai
2018-12-06 15:22             ` Jens Axboe
2018-12-07  7:16               ` Kashyap Desai
2018-12-07 10:20             ` Ming Lei
2018-12-07 10:34               ` Kashyap Desai
2018-12-11 15:06               ` Kashyap Desai
2018-12-14  6:22               ` Kashyap Desai

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=20181206003323.GB3015@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=kashyap.desai@broadcom.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.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;
as well as URLs for NNTP newsgroup(s).