The sysfs attribute nr_requests could be simultaneously updated from elevator switch/update or nr_hw_queue update code path. The update to nr_requests for each of those code path now runs holding q->elevator_ lock. So we should now protect access to sysfs attribute nr_requests using q->elevator_lock instead of q->sysfs_lock. Signed-off-by: Nilay Shroff <nilay@xxxxxxxxxxxxx> --- block/blk-sysfs.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 355dfb514712..37ac73468d4e 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -59,10 +59,11 @@ queue_var_store(unsigned long *var, const char *page, size_t count) static ssize_t queue_requests_show(struct gendisk *disk, char *page) { int ret; + struct request_queue *q = disk->queue; - mutex_lock(&disk->queue->sysfs_lock); - ret = queue_var_show(disk->queue->nr_requests, page); - mutex_unlock(&disk->queue->sysfs_lock); + mutex_lock(&q->elevator_lock); + ret = queue_var_show(q->nr_requests, page); + mutex_unlock(&q->elevator_lock); return ret; } @@ -75,8 +76,8 @@ queue_requests_store(struct gendisk *disk, const char *page, size_t count) unsigned int memflags; struct request_queue *q = disk->queue; - mutex_lock(&q->sysfs_lock); memflags = blk_mq_freeze_queue(q); + mutex_lock(&q->elevator_lock); if (!queue_is_mq(disk->queue)) { ret = -EINVAL; @@ -94,8 +95,9 @@ queue_requests_store(struct gendisk *disk, const char *page, size_t count) if (err) ret = err; out: + mutex_unlock(&q->elevator_lock); blk_mq_unfreeze_queue(q, memflags); - mutex_unlock(&q->sysfs_lock); + return ret; } -- 2.47.1