[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191226143934.GC3158@mit.edu>
Date: Thu, 26 Dec 2019 09:39:34 -0500
From: "Theodore Y. Ts'o" <tytso@....edu>
To: Naoto Kobayashi <naoto.kobayashi4c@...il.com>
Cc: adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org
Subject: Re: [PATCH] ext4: Prevent ext4_kvmalloc re-entring the filesystem
and deadlocking
On Thu, Dec 26, 2019 at 04:10:08PM +0900, Naoto Kobayashi wrote:
> Although __vmalloc() doesn't support GFP_NOFS[1],
> ext4_kvmalloc/kvzalloc caller may be under GFP_NOFS context
> (e.g. fs/ext4/resize.c::add_new_gdb). In such cases, the memory
> reclaim can re-entr the filesystem and potentially deadlock.
>
> To prevent the memory relcaim re-entring the filesystem,
> use memalloc_nofs_save/restore that gets __vmalloc() to drop
> __GFP_FS flag.
>
> [1] linux-tree/Documentation/core-api/gfp-mask-fs-io.rst
>
> Signed-off-by: Naoto Kobayashi <naoto.kobayashi4c@...il.com>
Good catch! However, we're not actually using ext4_kvzalloc()
anywhere, at least not any more. And also, all the users of
ext4_kvmalloc() are using GFP_NOFS (otherwise, they would have been
converted over to use the generic kvmalloc() helper function).
So... a cleaner fix would be to (a) delete ext4_kvmazalloc(), (b)
rename ext4_kvmalloc() to ext4_kvmalloc_nofs(), and drop its flags
argument, and then the calls memalloc_nfs_save/restore() to
ext4_kvmalloc_nofs() --- and so we won't need the
if (!(flags & __GFP_FS))
test.
Could you make those changes and resend the patch?
Thanks,
- Ted
Powered by blists - more mailing lists