Skip to content

Commit 7dfdbc7

Browse files
KAGA-KOKOaxboe
authored andcommitted
block: Protect queue flag changes with the queue lock
Since the queue flags may be changed concurrently from multiple contexts after a queue becomes visible in sysfs, make these changes safe by protecting these with the queue lock. Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Cc: Ming Lei <ming.lei@redhat.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8814ce8 commit 7dfdbc7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎block/blk-mq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,7 +2997,7 @@ EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);
29972997
static bool blk_poll_stats_enable(struct request_queue *q)
29982998
{
29992999
if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags) ||
3000-
test_and_set_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags))
3000+
blk_queue_flag_test_and_set(QUEUE_FLAG_POLL_STATS, q))
30013001
return true;
30023002
blk_stat_add_callback(q, q->poll_cb);
30033003
return false;

‎block/blk-stat.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void blk_stat_add_callback(struct request_queue *q,
152152

153153
spin_lock(&q->stats->lock);
154154
list_add_tail_rcu(&cb->list, &q->stats->callbacks);
155-
queue_flag_set(QUEUE_FLAG_STATS, q);
155+
blk_queue_flag_set(QUEUE_FLAG_STATS, q);
156156
spin_unlock(&q->stats->lock);
157157
}
158158
EXPORT_SYMBOL_GPL(blk_stat_add_callback);
@@ -163,7 +163,7 @@ void blk_stat_remove_callback(struct request_queue *q,
163163
spin_lock(&q->stats->lock);
164164
list_del_rcu(&cb->list);
165165
if (list_empty(&q->stats->callbacks) && !q->stats->enable_accounting)
166-
queue_flag_clear(QUEUE_FLAG_STATS, q);
166+
blk_queue_flag_clear(QUEUE_FLAG_STATS, q);
167167
spin_unlock(&q->stats->lock);
168168

169169
del_timer_sync(&cb->timer);
@@ -191,7 +191,7 @@ void blk_stat_enable_accounting(struct request_queue *q)
191191
{
192192
spin_lock(&q->stats->lock);
193193
q->stats->enable_accounting = true;
194-
queue_flag_set(QUEUE_FLAG_STATS, q);
194+
blk_queue_flag_set(QUEUE_FLAG_STATS, q);
195195
spin_unlock(&q->stats->lock);
196196
}
197197

0 commit comments

Comments
 (0)