Commit bae85c15 authored by Bart Van Assche's avatar Bart Van Assche Committed by Jens Axboe

block: Remove "dying" checks from sysfs callbacks

Block drivers must call del_gendisk() before blk_cleanup_queue().
del_gendisk() calls kobject_del() and kobject_del() waits until any
ongoing sysfs callback functions have finished. In other words, the
sysfs callback functions won't be called for a queue in the dying
state. Hence remove the "dying" checks from the sysfs callback
functions.

Cc: Christoph Hellwig <hch@infradead.org>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 95662565
...@@ -336,6 +336,8 @@ EXPORT_SYMBOL_GPL(blk_set_queue_dying); ...@@ -336,6 +336,8 @@ EXPORT_SYMBOL_GPL(blk_set_queue_dying);
*/ */
void blk_cleanup_queue(struct request_queue *q) void blk_cleanup_queue(struct request_queue *q)
{ {
WARN_ON_ONCE(blk_queue_registered(q));
/* mark @q DYING, no new request or merges will be allowed afterwards */ /* mark @q DYING, no new request or merges will be allowed afterwards */
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
blk_set_queue_dying(q); blk_set_queue_dying(q);
......
...@@ -74,10 +74,8 @@ static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr, ...@@ -74,10 +74,8 @@ static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr,
if (!entry->show) if (!entry->show)
return -EIO; return -EIO;
res = -ENOENT;
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
if (!blk_queue_dying(q)) res = entry->show(ctx, page);
res = entry->show(ctx, page);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
return res; return res;
} }
...@@ -97,10 +95,8 @@ static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr, ...@@ -97,10 +95,8 @@ static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr,
if (!entry->store) if (!entry->store)
return -EIO; return -EIO;
res = -ENOENT;
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
if (!blk_queue_dying(q)) res = entry->store(ctx, page, length);
res = entry->store(ctx, page, length);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
return res; return res;
} }
...@@ -120,10 +116,8 @@ static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj, ...@@ -120,10 +116,8 @@ static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj,
if (!entry->show) if (!entry->show)
return -EIO; return -EIO;
res = -ENOENT;
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
if (!blk_queue_dying(q)) res = entry->show(hctx, page);
res = entry->show(hctx, page);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
return res; return res;
} }
...@@ -144,10 +138,8 @@ static ssize_t blk_mq_hw_sysfs_store(struct kobject *kobj, ...@@ -144,10 +138,8 @@ static ssize_t blk_mq_hw_sysfs_store(struct kobject *kobj,
if (!entry->store) if (!entry->store)
return -EIO; return -EIO;
res = -ENOENT;
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
if (!blk_queue_dying(q)) res = entry->store(hctx, page, length);
res = entry->store(hctx, page, length);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
return res; return res;
} }
......
...@@ -801,10 +801,6 @@ queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page) ...@@ -801,10 +801,6 @@ queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
if (!entry->show) if (!entry->show)
return -EIO; return -EIO;
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
if (blk_queue_dying(q)) {
mutex_unlock(&q->sysfs_lock);
return -ENOENT;
}
res = entry->show(q, page); res = entry->show(q, page);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
return res; return res;
...@@ -823,10 +819,6 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr, ...@@ -823,10 +819,6 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
q = container_of(kobj, struct request_queue, kobj); q = container_of(kobj, struct request_queue, kobj);
mutex_lock(&q->sysfs_lock); mutex_lock(&q->sysfs_lock);
if (blk_queue_dying(q)) {
mutex_unlock(&q->sysfs_lock);
return -ENOENT;
}
res = entry->store(q, page, length); res = entry->store(q, page, length);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment