]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
block: mark GFP_NOIO around sysfs ->store()
authorMing Lei <tom.leiming@gmail.com>
Mon, 13 Jan 2025 01:58:33 +0000 (09:58 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 13 Jan 2025 14:45:03 +0000 (07:45 -0700)
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>
block/blk-sysfs.c

index e828be777206bb818a09b7ce8901880b10ccfbde..e09b455874bfd632fff1a60bd3737e1bf9e6a76c 100644 (file)
@@ -681,6 +681,7 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
        struct queue_sysfs_entry *entry = to_queue(attr);
        struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
        struct request_queue *q = disk->queue;
+       unsigned int noio_flag;
        ssize_t res;
 
        if (!entry->store_limit && !entry->store)
@@ -711,7 +712,9 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
 
        mutex_lock(&q->sysfs_lock);
        blk_mq_freeze_queue(q);
+       noio_flag = memalloc_noio_save();
        res = entry->store(disk, page, length);
+       memalloc_noio_restore(noio_flag);
        blk_mq_unfreeze_queue(q);
        mutex_unlock(&q->sysfs_lock);
        return res;