diff options
| author | Bart Van Assche <bart.vanassche@wdc.com> | 2018-03-07 20:10:05 -0500 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2018-03-08 16:13:48 -0500 |
| commit | 7dfdbc7367f6f789715cab2cb484b78ab45e9f3e (patch) | |
| tree | 12bb8fc5fe749d47d9948f2a2b502a021fe9dd1d /block | |
| parent | 8814ce8a0f680599a837af18aefdec774e5c7b97 (diff) | |
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>
Diffstat (limited to 'block')
| -rw-r--r-- | block/blk-mq.c | 2 | ||||
| -rw-r--r-- | block/blk-stat.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index a86899022683..f5c7dbcb954f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
| @@ -2997,7 +2997,7 @@ EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues); | |||
| 2997 | static bool blk_poll_stats_enable(struct request_queue *q) | 2997 | static bool blk_poll_stats_enable(struct request_queue *q) |
| 2998 | { | 2998 | { |
| 2999 | if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags) || | 2999 | 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)) |
| 3001 | return true; | 3001 | return true; |
| 3002 | blk_stat_add_callback(q, q->poll_cb); | 3002 | blk_stat_add_callback(q, q->poll_cb); |
| 3003 | return false; | 3003 | return false; |
diff --git a/block/blk-stat.c b/block/blk-stat.c index b664aa6df725..bd365a95fcf8 100644 --- a/block/blk-stat.c +++ b/block/blk-stat.c | |||
| @@ -152,7 +152,7 @@ void blk_stat_add_callback(struct request_queue *q, | |||
| 152 | 152 | ||
| 153 | spin_lock(&q->stats->lock); | 153 | spin_lock(&q->stats->lock); |
| 154 | list_add_tail_rcu(&cb->list, &q->stats->callbacks); | 154 | 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); |
| 156 | spin_unlock(&q->stats->lock); | 156 | spin_unlock(&q->stats->lock); |
| 157 | } | 157 | } |
| 158 | EXPORT_SYMBOL_GPL(blk_stat_add_callback); | 158 | EXPORT_SYMBOL_GPL(blk_stat_add_callback); |
| @@ -163,7 +163,7 @@ void blk_stat_remove_callback(struct request_queue *q, | |||
| 163 | spin_lock(&q->stats->lock); | 163 | spin_lock(&q->stats->lock); |
| 164 | list_del_rcu(&cb->list); | 164 | list_del_rcu(&cb->list); |
| 165 | if (list_empty(&q->stats->callbacks) && !q->stats->enable_accounting) | 165 | 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); |
| 167 | spin_unlock(&q->stats->lock); | 167 | spin_unlock(&q->stats->lock); |
| 168 | 168 | ||
| 169 | del_timer_sync(&cb->timer); | 169 | del_timer_sync(&cb->timer); |
| @@ -191,7 +191,7 @@ void blk_stat_enable_accounting(struct request_queue *q) | |||
| 191 | { | 191 | { |
| 192 | spin_lock(&q->stats->lock); | 192 | spin_lock(&q->stats->lock); |
| 193 | q->stats->enable_accounting = true; | 193 | q->stats->enable_accounting = true; |
| 194 | queue_flag_set(QUEUE_FLAG_STATS, q); | 194 | blk_queue_flag_set(QUEUE_FLAG_STATS, q); |
| 195 | spin_unlock(&q->stats->lock); | 195 | spin_unlock(&q->stats->lock); |
| 196 | } | 196 | } |
| 197 | 197 | ||
