All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naoto Kobayashi <naoto.kobayashi4c@gmail.com>
To: "Theodore Y. Ts'o" <tytso@mit.edu>
Cc: adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Prevent ext4_kvmalloc re-entring the filesystem and deadlocking
Date: Wed, 8 Jan 2020 17:11:13 +0900	[thread overview]
Message-ID: <b16c5913-2dd5-5d62-1eea-cda96ec2d973@gmail.com> (raw)
In-Reply-To: <20191226143934.GC3158@mit.edu>

On 2019/12/26 23:39, Theodore Y. Ts'o wrote:
> 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@gmail.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
> 

Thank you for the review! I made the changes you suggested and resent
the patch.

  [PATCH v2 0/3] ext4: Prevent memory reclaim from re-entering the filesystem and deadlocking
  https://marc.info/?l=linux-ext4&m=157743393000807&w=2

Would you review the patch?

Thanks,

                                       - Naoto

      reply	other threads:[~2020-01-08  8:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26  7:10 [PATCH] ext4: Prevent ext4_kvmalloc re-entring the filesystem and deadlocking Naoto Kobayashi
2019-12-26 14:39 ` Theodore Y. Ts'o
2020-01-08  8:11   ` Naoto Kobayashi [this message]

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=b16c5913-2dd5-5d62-1eea-cda96ec2d973@gmail.com \
    --to=naoto.kobayashi4c@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.