block: Change a rcu_read_{lock,unlock}_sched() pair into rcu_read_{lock,unlock}()

scsi_device_quiesce() uses synchronize_rcu() to guarantee that the
effect of blk_set_preempt_only() will be visible for percpu_ref_tryget()
calls that occur after the queue unfreeze by using the approach
explained in https://lwn.net/Articles/573497/. The rcu read lock and
unlock calls in blk_queue_enter() form a pair with the synchronize_rcu()
call in scsi_device_quiesce(). Both scsi_device_quiesce() and
blk_queue_enter() must either use regular RCU or RCU-sched.
Since neither the RCU-protected code in blk_queue_enter() nor
blk_queue_usage_counter_release() sleeps, regular RCU protection
is sufficient. Note: scsi_device_quiesce() does not have to be
modified since it already uses synchronize_rcu().

Reported-by: Tejun Heo <tj@kernel.org>
Fixes: 3a0a529971ec ("block, scsi: Make SCSI quiesce and resume work reliably")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Martin Steigerwald <martin@lichtvoll.de>
Cc: stable@vger.kernel.org # v4.15
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
Bart Van Assche 2018-03-19 11:46:13 -07:00 committed by azrim
parent 1673b690ef
commit c6bfb3e947
No known key found for this signature in database
GPG Key ID: 497F8FB059B45D1C

View File

@ -920,16 +920,16 @@ int blk_queue_enter(struct request_queue *q, unsigned int op)
{ {
while (true) { while (true) {
rcu_read_lock_sched(); rcu_read_lock();
if (__percpu_ref_tryget_live(&q->q_usage_counter)) { if (__percpu_ref_tryget_live(&q->q_usage_counter)) {
if (likely((op & REQ_PREEMPT) || if (likely((op & REQ_PREEMPT) ||
!blk_queue_preempt_only(q))) { !blk_queue_preempt_only(q))) {
rcu_read_unlock_sched(); rcu_read_unlock();
return 0; return 0;
} else } else
percpu_ref_put(&q->q_usage_counter); percpu_ref_put(&q->q_usage_counter);
} }
rcu_read_unlock_sched(); rcu_read_unlock();
if (op & REQ_NOWAIT) if (op & REQ_NOWAIT)
return -EBUSY; return -EBUSY;