block: Change a rcu_read_{lock,unlock}_sched() pair into rcu_read_{lock,unlock}()
Subsystems (2)
PATCH v2 1/1 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().
---
Changes between v1 and v2:
- Explained in the interaction between scsi_device_quiesce() and blk_queue_enter() in the patch description.
block/blk-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-core.c +2 -2
@@ -917,7 +917,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)bool success = false;int ret; -rcu_read_lock_sched (); +rcu_read_lock ();if (percpu_ref_tryget_live (&q->q_usage_counter)) {/* * The code that sets the PREEMPT_ONLY flag is
@@ -930,7 +930,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)percpu_ref_put (&q->q_usage_counter); } } -rcu_read_unlock_sched (); +rcu_read_unlock ();if (success)return 0 ;
Signature · 1 line
2.16.2
Quoted 11 lines · Bart Van Assche
scsi_device_quiesce()usessynchronize_rcu()to guarantee that the effect ofblk_set_preempt_only()will be visible forpercpu_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 inblk_queue_enter()form a pair with thesynchronize_rcu()call inscsi_device_quiesce(). Bothscsi_device_quiesce()andblk_queue_enter()must either use regular RCU or RCU-sched. Since neither the RCU-protected code inblk_queue_enter()norblk_queue_usage_counter_release()sleeps, regular RCU protection is sufficient. Note:scsi_device_quiesce()does not have to be modified since it already usessynchronize_rcu().
Applied, thanks.
Signature · 1 line
Jens Axboe