From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, nbd@other.debian.org,
ceph-devel@vger.kernel.org, virtualization@lists.linux.dev,
linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/2] loop: force GFP_NOIO for underlying file systems allocations
Date: Fri, 17 Jan 2025 19:56:48 +0800 [thread overview]
Message-ID: <Z4pFgIqB50gz-ODi@fedora> (raw)
In-Reply-To: <20250117074442.256705-2-hch@lst.de>
On Fri, Jan 17, 2025 at 08:44:07AM +0100, Christoph Hellwig wrote:
> File systems can and often do allocate memory in the read-write path.
> If these allocations are done with __GFP_IO or __GFP_FS set they can
> recurse into the file system or swap device on top of the loop device
> and cause deadlocks. Prevent this by forcing a noio scope over the
> calls into the file system.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/block/loop.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 1ec7417c7f00..71eccc5cfffb 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1905,6 +1905,15 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
> int ret = 0;
> struct mem_cgroup *old_memcg = NULL;
> const bool use_aio = cmd->use_aio;
> + unsigned int memflags;
> +
> + /*
> + * We're calling into file system which could do be doing memory
> + * allocations. Ensure the memory reclaim does not cause I/O,
> + * because that could end up in the user of this loop devices again and
> + * deadlock.
> + */
> + memflags = memalloc_noio_save();
If we call memalloc_noio_save() here, setting PF_MEMALLOC_NOIO can be removed
from loop_process_work().
Thanks,
Ming
WARNING: multiple messages have this Message-ID (diff)
From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, nbd@other.debian.org,
ceph-devel@vger.kernel.org, virtualization@lists.linux.dev,
linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/2] loop: force GFP_NOIO for underlying file systems allocations
Date: Fri, 17 Jan 2025 19:56:48 +0800 [thread overview]
Message-ID: <Z4pFgIqB50gz-ODi@fedora> (raw)
In-Reply-To: <20250117074442.256705-2-hch@lst.de>
On Fri, Jan 17, 2025 at 08:44:07AM +0100, Christoph Hellwig wrote:
> File systems can and often do allocate memory in the read-write path.
> If these allocations are done with __GFP_IO or __GFP_FS set they can
> recurse into the file system or swap device on top of the loop device
> and cause deadlocks. Prevent this by forcing a noio scope over the
> calls into the file system.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/block/loop.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 1ec7417c7f00..71eccc5cfffb 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1905,6 +1905,15 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
> int ret = 0;
> struct mem_cgroup *old_memcg = NULL;
> const bool use_aio = cmd->use_aio;
> + unsigned int memflags;
> +
> + /*
> + * We're calling into file system which could do be doing memory
> + * allocations. Ensure the memory reclaim does not cause I/O,
> + * because that could end up in the user of this loop devices again and
> + * deadlock.
> + */
> + memflags = memalloc_noio_save();
If we call memalloc_noio_save() here, setting PF_MEMALLOC_NOIO can be removed
from loop_process_work().
Thanks,
Ming
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-01-17 11:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 7:44 annotate noio context Christoph Hellwig
2025-01-17 7:44 ` Christoph Hellwig
2025-01-17 7:44 ` [PATCH 1/2] loop: force GFP_NOIO for underlying file systems allocations Christoph Hellwig
2025-01-17 7:44 ` Christoph Hellwig
2025-01-17 11:56 ` Ming Lei [this message]
2025-01-17 11:56 ` Ming Lei
2025-01-22 6:32 ` Christoph Hellwig
2025-01-22 6:32 ` Christoph Hellwig
2025-01-17 7:44 ` [PATCH 2/2] block: force noio scope in blk_mq_freeze_queue Christoph Hellwig
2025-01-17 7:44 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z4pFgIqB50gz-ODi@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=ceph-devel@vger.kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nbd@other.debian.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.