Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ming Lei and committed by
Jens Axboe
7c0be4ea 9752b550

+3
+3
block/blk-sysfs.c
··· 681 681 struct queue_sysfs_entry *entry = to_queue(attr); 682 682 struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj); 683 683 struct request_queue *q = disk->queue; 684 + unsigned int noio_flag; 684 685 ssize_t res; 685 686 686 687 if (!entry->store_limit && !entry->store) ··· 712 711 713 712 mutex_lock(&q->sysfs_lock); 714 713 blk_mq_freeze_queue(q); 714 + noio_flag = memalloc_noio_save(); 715 715 res = entry->store(disk, page, length); 716 + memalloc_noio_restore(noio_flag); 716 717 blk_mq_unfreeze_queue(q); 717 718 mutex_unlock(&q->sysfs_lock); 718 719 return res;