All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "ming.lei@redhat.com" <ming.lei@redhat.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"jthumshirn@suse.de" <jthumshirn@suse.de>,
	"hch@lst.de" <hch@lst.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"oleksandr@natalenko.name" <oleksandr@natalenko.name>,
	"hare@suse.com" <hare@suse.com>,
	"mcgrof@kernel.org" <mcgrof@kernel.org>
Subject: Re: [PATCH v7 9/9] block, scsi: Make SCSI quiesce and resume work reliably
Date: Tue, 10 Oct 2017 17:16:58 +0000	[thread overview]
Message-ID: <1507655817.2815.46.camel@wdc.com> (raw)
In-Reply-To: <20171010105626.GB18664@ming.t460p>

T24gVHVlLCAyMDE3LTEwLTEwIGF0IDE4OjU2ICswODAwLCBNaW5nIExlaSB3cm90ZToNCj4gT24g
TW9uLCBPY3QgMDksIDIwMTcgYXQgMDQ6MTQ6MDBQTSAtMDcwMCwgQmFydCBWYW4gQXNzY2hlIHdy
b3RlOg0KPiA+IFsgLi4uIF0NCj4gPiAgaW50DQo+ID4gIHNjc2lfZGV2aWNlX3F1aWVzY2Uoc3Ry
dWN0IHNjc2lfZGV2aWNlICpzZGV2KQ0KPiA+ICB7DQo+ID4gKwlzdHJ1Y3QgcmVxdWVzdF9xdWV1
ZSAqcSA9IHNkZXYtPnJlcXVlc3RfcXVldWU7DQo+ID4gIAlpbnQgZXJyOw0KPiA+ICANCj4gPiAr
CS8qIElmIHRoZSBTQ1NJIGRldmljZSBhbHJlYWR5IGhhcyBiZWVuIHF1aWVzY2VkLCBkbyBub3Ro
aW5nLiAqLw0KPiA+ICsJaWYgKGJsa19zZXRfcHJlZW1wdF9vbmx5KHEpKQ0KPiA+ICsJCXJldHVy
biAwOw0KPiANCj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0cyBhbmQgYnkgdW5sb2NraW5n
IHRoYXQgbXV0ZXggYWZ0ZXIgU1BJDQpEVg0KaGFzIGZpbmlzaGVkLiBJIHRoaW5rIHRoYXQgd2ls
bCByZXN1bHQgaW4gY29kZSB0aGF0IGlzIGVhc2llciB0byByZXZpZXcNCnRoYW4gdGhlIGFwcHJv
YWNoIHlvdSBwcm9wb3NlZC4NCg0KPiA+ICsJYmxrX21xX2ZyZWV6ZV9xdWV1ZShxKTsNCj4gPiAr
CWJsa19tcV91bmZyZWV6ZV9xdWV1ZShxKTsNCj4gDQo+IFRoaXMgd2F5IGlzbid0IHNhZmUgdG9v
LCBiZWNhdXNlIHF1ZXVlIG1heSBoYXMgYmVlbiBmcm96ZW4gYmVmb3JlDQo+IHNjc2lfZGV2aWNl
X3F1aWVzY2UoKSBpcyBydW4sIHRoZW4gdGhlcmUgaXNuJ3Qgc3luY2hyb25pemVfcmN1KCkNCj4g
aW1wbGljYXRlZCBpbiBibGtfbXFfZnJlZXplX3F1ZXVlKCkuDQoNCkl0J3MgdmVyeSB1bmxpa2Vs
eSB0aGF0IHRoaXMgd2lsbCBjYXVzZSB0cm91YmxlIGluIHByYWN0aWNlLiBBbnl3YXksIHRoZQ0K
cHJldmlvdXMgdmVyc2lvbiBvZiB0aGlzIGNvZGUgZGlkIG5vdCBzaG93IHRoaXMgcmFjZSBzbyBJ
IHdpbGwgY2hhbmdlIHRoaXMNCmNvZGUgZnJhZ21lbnQgYmFjayB0byB3aGF0IEkgaGFkIGluIHRo
ZSBwcmV2aW91cyB2ZXJzaW9uLg0KDQpCYXJ0Lg==

WARNING: multiple messages have this Message-ID (diff)
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "ming.lei@redhat.com" <ming.lei@redhat.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"jthumshirn@suse.de" <jthumshirn@suse.de>,
	"hch@lst.de" <hch@lst.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"oleksandr@natalenko.name" <oleksandr@natalenko.name>,
	"hare@suse.com" <hare@suse.com>,
	"mcgrof@kernel.org" <mcgrof@kernel.org>
Subject: Re: [PATCH v7 9/9] block, scsi: Make SCSI quiesce and resume work reliably
Date: Tue, 10 Oct 2017 17:16:58 +0000	[thread overview]
Message-ID: <1507655817.2815.46.camel@wdc.com> (raw)
In-Reply-To: <20171010105626.GB18664@ming.t460p>

On Tue, 2017-10-10 at 18:56 +0800, Ming Lei wrote:
> On Mon, Oct 09, 2017 at 04:14:00PM -0700, Bart Van Assche wrote:
> > [ ... ]
> >  int
> >  scsi_device_quiesce(struct scsi_device *sdev)
> >  {
> > +	struct request_queue *q = sdev->request_queue;
> >  	int err;
> >  
> > +	/* If the SCSI device already has been quiesced, do nothing. */
> > +	if (blk_set_preempt_only(q))
> > +		return 0;
> 
> This way isn't safe:
> 
> 1) suppose path1 sets the flag, and blk_mq_freeze_queue() isn't
> finished, or even not started;
> 
> 2) path2 sees the flag set at the exact time, and returns immediately,
> and unfortunately SCSI QUIESCE isn't respected in this context.

That comment applies to concurrent invocations of scsi_device_quiesce() only.
I think concurrent calls of scsi_device_quiesce() can only occur when power
management suspends or
hibernates a system that is equipped with a parallel
port and on which SCSI parallel domain validation occurs. I think that's a
very unlikely combination. And if we have to
address this, I propose to
disable power management during SCSI parallel domain validation, e.g. by
locking pm_mutex before SPI DV starts and by unlocking that mutex after SPI
DV
has finished. I think that will result in code that is easier to review
than the approach you proposed.

> > +	blk_mq_freeze_queue(q);
> > +	blk_mq_unfreeze_queue(q);
> 
> This way isn't safe too, because queue may has been frozen before
> scsi_device_quiesce() is run, then there isn't synchronize_rcu()
> implicated in blk_mq_freeze_queue().

It's very unlikely that this will cause trouble in practice. Anyway, the
previous version of this code did not show this race so I will change this
code fragment back to what I had in the previous version.

Bart.

  reply	other threads:[~2017-10-10 17:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09 23:13 [PATCH v7 0/9] Hello Jens, Bart Van Assche
2017-10-09 23:13 ` [PATCH v7 1/9] md: Rename md_notifier into md_reboot_notifier Bart Van Assche
2017-10-10  7:20   ` Johannes Thumshirn
2017-10-10  7:20     ` Johannes Thumshirn
2017-10-09 23:13 ` [PATCH v7 2/9] md: Introduce md_stop_all_writes() Bart Van Assche
2017-10-10  7:21   ` Johannes Thumshirn
2017-10-10  7:21     ` Johannes Thumshirn
2017-10-09 23:13 ` [PATCH v7 3/9] md: Neither resync nor reshape while the system is frozen Bart Van Assche
2017-10-09 23:13 ` [PATCH v7 4/9] block: Make q_usage_counter also track legacy requests Bart Van Assche
2017-10-10  7:22   ` Johannes Thumshirn
2017-10-10  7:22     ` Johannes Thumshirn
2017-10-09 23:13 ` [PATCH v7 5/9] block: Introduce blk_get_request_flags() Bart Van Assche
2017-10-09 23:13 ` [PATCH v7 6/9] block: Introduce BLK_MQ_REQ_PREEMPT Bart Van Assche
2017-10-09 23:13 ` [PATCH v7 7/9] ide, scsi: Tell the block layer at request allocation time about preempt requests Bart Van Assche
2017-10-09 23:13 ` [PATCH v7 8/9] block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag Bart Van Assche
2017-10-09 23:14 ` [PATCH v7 9/9] block, scsi: Make SCSI quiesce and resume work reliably Bart Van Assche
2017-10-10  7:57   ` Martin Steigerwald
2017-10-10  7:57     ` Martin Steigerwald
2017-10-10 15:27     ` Bart Van Assche
2017-10-10 15:27       ` Bart Van Assche
2017-10-12 19:53       ` Martin Steigerwald
2017-10-12 19:53         ` Martin Steigerwald
2017-10-10 10:56   ` Ming Lei
2017-10-10 17:16     ` Bart Van Assche [this message]
2017-10-10 17:16       ` Bart Van Assche
2017-10-17  4:19   ` [block, scsi] f246f66ae5: WARNING:at_block/blk-core.c:#blk_queue_enter kernel test robot
2017-10-17  4:19     ` kernel test robot
2017-10-17  4:19     ` kernel test robot
2017-10-10  0:00 ` [PATCH v7 0/9] Hello Jens, Bart Van Assche
2017-10-10  0:00   ` Bart Van Assche

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=1507655817.2815.46.camel@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mcgrof@kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=oleksandr@natalenko.name \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.