Message ID | 20250129104525.0ae8421e@fangorn (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v2] scsi: use GFP_NOIO to avoid circular locking dependency | expand |
On Wed, Jan 29, 2025 at 10:45:25AM -0500, Rik van Riel wrote: > On Tue, 28 Jan 2025 21:35:18 -0800 > Christoph Hellwig <hch@infradead.org> wrote: > > > GFP_NOFS is never the right thing for block layer allocations. > > The right thing here is GFP_NOIO which is a superset of GFP_NOFS. > > Otherwise you could reproduce the same deadlock when using swap > > instead of a file system to reproduce basically the same deadlock. > > Duh, you are right of course! > > The fixed up patch with GFP_NOIO is below. Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Wed, 29 Jan 2025 10:45:25 -0500, Rik van Riel wrote: > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > Filesystems can write to disk from page reclaim with __GFP_FS > set. Marc found a case where scsi_realloc_sdev_budget_map > ends up in page reclaim with GFP_KERNEL, where it could try > to take filesystem locks again, leading to a deadlock. > > [...] Applied to 6.14/scsi-fixes, thanks! [1/1] scsi: use GFP_NOIO to avoid circular locking dependency https://git.kernel.org/mkp/scsi/c/5363ee9d110e
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index f2093982b3db..b0964b6dd646 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -245,7 +245,7 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev, } ret = sbitmap_init_node(&sdev->budget_map, scsi_device_max_queue_depth(sdev), - new_shift, GFP_KERNEL, + new_shift, GFP_NOIO, sdev->request_queue->node, false, true); if (!ret) sbitmap_resize(&sdev->budget_map, depth);