Skip to content

Commit bae85c1

Browse files
bvanasscheaxboe
authored andcommitted
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: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9566256 commit bae85c1

3 files changed

Lines changed: 6 additions & 20 deletions

File tree

‎block/blk-core.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ EXPORT_SYMBOL_GPL(blk_set_queue_dying);
336336
*/
337337
void blk_cleanup_queue(struct request_queue *q)
338338
{
339+
WARN_ON_ONCE(blk_queue_registered(q));
340+
339341
/* mark @q DYING, no new request or merges will be allowed afterwards */
340342
mutex_lock(&q->sysfs_lock);
341343
blk_set_queue_dying(q);

‎block/blk-mq-sysfs.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr,
7474
if (!entry->show)
7575
return -EIO;
7676

77-
res = -ENOENT;
7877
mutex_lock(&q->sysfs_lock);
79-
if (!blk_queue_dying(q))
80-
res = entry->show(ctx, page);
78+
res = entry->show(ctx, page);
8179
mutex_unlock(&q->sysfs_lock);
8280
return res;
8381
}
@@ -97,10 +95,8 @@ static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr,
9795
if (!entry->store)
9896
return -EIO;
9997

100-
res = -ENOENT;
10198
mutex_lock(&q->sysfs_lock);
102-
if (!blk_queue_dying(q))
103-
res = entry->store(ctx, page, length);
99+
res = entry->store(ctx, page, length);
104100
mutex_unlock(&q->sysfs_lock);
105101
return res;
106102
}
@@ -120,10 +116,8 @@ static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj,
120116
if (!entry->show)
121117
return -EIO;
122118

123-
res = -ENOENT;
124119
mutex_lock(&q->sysfs_lock);
125-
if (!blk_queue_dying(q))
126-
res = entry->show(hctx, page);
120+
res = entry->show(hctx, page);
127121
mutex_unlock(&q->sysfs_lock);
128122
return res;
129123
}
@@ -144,10 +138,8 @@ static ssize_t blk_mq_hw_sysfs_store(struct kobject *kobj,
144138
if (!entry->store)
145139
return -EIO;
146140

147-
res = -ENOENT;
148141
mutex_lock(&q->sysfs_lock);
149-
if (!blk_queue_dying(q))
150-
res = entry->store(hctx, page, length);
142+
res = entry->store(hctx, page, length);
151143
mutex_unlock(&q->sysfs_lock);
152144
return res;
153145
}

‎block/blk-sysfs.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -801,10 +801,6 @@ queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
801801
if (!entry->show)
802802
return -EIO;
803803
mutex_lock(&q->sysfs_lock);
804-
if (blk_queue_dying(q)) {
805-
mutex_unlock(&q->sysfs_lock);
806-
return -ENOENT;
807-
}
808804
res = entry->show(q, page);
809805
mutex_unlock(&q->sysfs_lock);
810806
return res;
@@ -823,10 +819,6 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
823819

824820
q = container_of(kobj, struct request_queue, kobj);
825821
mutex_lock(&q->sysfs_lock);
826-
if (blk_queue_dying(q)) {
827-
mutex_unlock(&q->sysfs_lock);
828-
return -ENOENT;
829-
}
830822
res = entry->store(q, page, length);
831823
mutex_unlock(&q->sysfs_lock);
832824
return res;

0 commit comments

Comments
 (0)