All of lore.kernel.org
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: linux-fsdevel@vger.kernel.org
Subject: How to handle an kmalloc failure in evict_inode()?
Date: Mon, 04 Aug 2014 19:41:01 -0400	[thread overview]
Message-ID: <nsx8un3akmq.fsf@closure.thunk.org> (raw)


I've been trying to figure out the best way to handle potential memory
allocation failures in evict_inode(), since there doesn't seem to be any
way to reflect errors back up to the caller, or to delay the inode
eviction until more memory might be available.

There doesn't seem to be a good solution; right now, in ext4, we mark
the file system as being inconsistent, thus triggering a remount
read-only or a panic, which seems to be.... sub-optimal.

I was looking to see what xfs does to handle this case, and as near as I
can tell, xfs_fs_evict_inode() calls xfs_inactive(), which in turn calls
xfs_free_eofblocks() --- and ignores the error return.  And when I look
to see whether xfs_free_eofblocks() can return ENOMEM, it appears that
it can, via a call path that involves xfs_bmapi_read(),
xfs_iread_extents(), xfs_bmap_read_extents(), xfs_btree_read_bufl(),
xfs_trans_read_buf(), xfs_trans_read_buf_map(), xfs_buf_read_map(),
xfs_buf_get_map(), _xfs_buf_alloc(), which can return ENOMEM.

As near as I can tell, at least for ext4, we've been remarkably lucky,
in that GFP_NOFS allocations seem to rarely if ever fail.  However,
under enough memory pressure, and in a situation where the OOM killer
has been configured to be less aggressive, it is possible (which is as
we would expect) for a kmalloc() to fail, and short of using
_GFP_NOFAIL, or using a retry loop, I'm not sure there's a good answer
to this problem.

Am I missing something obvious?  Has someone come up with a good way of
dealing with the need to release an inode and its blocks in
evict_inode(), and what to do if a memory allocation fails for some
reason?

Thanks,

                                                - Ted

             reply	other threads:[~2014-08-04 23:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04 23:41 Theodore Ts'o [this message]
2014-08-05  1:13 ` How to handle an kmalloc failure in evict_inode()? Dave Chinner
2014-08-05  1:53   ` Theodore Ts'o
2014-08-05 12:17     ` Dave Chinner
2014-08-05 17:21       ` Theodore Ts'o
2014-08-05 22:12         ` Dave Chinner
2014-08-09 10:48           ` Tetsuo Handa
2014-08-09 15:43             ` Theodore Ts'o

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=nsx8un3akmq.fsf@closure.thunk.org \
    --to=tytso@mit.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    /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.