Re: [PATCH 3/6] EXT4: Remove ENOMEM/congestion_wait() loops.
From: NeilBrown <hidden>
Date: 2021-09-15 05:25:53
Also in:
linux-ext4, linux-fsdevel, linux-nfs, linux-xfs, lkml
On Wed, 15 Sep 2021, Theodore Ts'o wrote:
On Tue, Sep 14, 2021 at 10:13:04AM +1000, NeilBrown wrote:quoted
Of particular interest is the ext4_journal_start family of calls which can now have EXT4_EX_NOFAIL 'or'ed in to the 'type'. This could be seen as a blurring of types. However 'type' is 8 bits, and EXT4_EX_NOFAIL is a high bit, so it is safe in practice.I'm really not fond of this type blurring. What I'd suggeset doing instead is adding a "gfp_t gfp_mask" parameter to the __ext4_journal_start_sb(). With the exception of one call site in fs/ext4/ialloc.c, most of the callers of __ext4_journal_start_sb() are via #define helper macros or inline funcions. So it would just require adding a GFP_NOFS as an extra parameter to the various macros and inline functions which call __ext4_journal_start_sb() in ext4_jbd2.h. The function ext4_journal_start_with_revoke() is called exactly once so we could just bury the __GFP_NOFAIL in the definition of that macros, e.g.: #define ext4_journal_start_with_revoke(inode, type, blocks, revoke_creds) \ __ext4_journal_start((inode), __LINE__, (type), (blocks), 0, \ GFP_NOFS | __GFP_NOFAIL, (revoke_creds)) but it's probably better to do something like this: #define ext4_journal_start_with_revoke(gfp_mask, inode, type, blocks, revoke_creds) \ __ext4_journal_start((inode), __LINE__, (type), (blocks), 0, \ gfp_mask, (revoke_creds)) So it's explicit in the C function ext4_ext_remove_space() in fs/ext4/extents.c that we are explicitly requesting the __GFP_NOFAIL behavior. Does that make sense?
Mostly. Adding gfp_mask to __ext4_journal_start_sb() make perfect sense. There doesn't seem much point adding one to __ext4_journal_start(), we can have ext4_journal_start_with_revoke() call __ext4_journal_start_sb() directly. But I cannot see what it doesn't already do that. i.e. why have the inline __ext4_journal_start() at all? Is it OK if I don't use that for ext4_journal_start_with_revoke()? Thanks, NeilBrown