Skip to content

Commit 7c0be4e

Browse files
ming1axboe
authored andcommitted
block: mark GFP_NOIO around sysfs ->store()
sysfs ->store is called with queue freezed, meantime we have several ->store() callbacks(update_nr_requests, wbt, scheduler) to allocate memory with GFP_KERNEL which may run into direct reclaim code path, then potential deadlock can be caused. Fix the issue by marking NOIO around sysfs ->store() Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: stable@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20250113015833.698458-1-ming.lei@redhat.com Link: https://lore.kernel.org/linux-block/Z4RkemI9f6N5zoEF@fedora/T/#mc774c65eeca5c024d29695f9ac6152b87763f305 Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9752b55 commit 7c0be4e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/blk-sysfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
681681
struct queue_sysfs_entry *entry = to_queue(attr);
682682
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
683683
struct request_queue *q = disk->queue;
684+
unsigned int noio_flag;
684685
ssize_t res;
685686

686687
if (!entry->store_limit && !entry->store)
@@ -711,7 +712,9 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
711712

712713
mutex_lock(&q->sysfs_lock);
713714
blk_mq_freeze_queue(q);
715+
noio_flag = memalloc_noio_save();
714716
res = entry->store(disk, page, length);
717+
memalloc_noio_restore(noio_flag);
715718
blk_mq_unfreeze_queue(q);
716719
mutex_unlock(&q->sysfs_lock);
717720
return res;

0 commit comments

Comments
 (0)