1 ext4: update PF_MEMALLOC handling in ext4_write_inode()
3 The special handling of PF_MEMALLOC callers in ext4_write_inode()
4 shouldn't be necessary as there shouldn't be any. Warn about it. Also
5 update comment before the function as it seems somewhat outdated.
7 (Changes modeled on an ext3 patch posted by Jan Kara to the linux-ext4
8 mailing list on Februaryt 28, 2014, which apparently never went into
11 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 Cc: Jan Kara <jack@suse.cz>
13 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
14 index 93f16c5..7b93df9 100644
17 @@ -4427,21 +4427,20 @@ out_brelse:
19 * We are called from a few places:
21 - * - Within generic_file_write() for O_SYNC files.
22 + * - Within generic_file_aio_write() -> generic_write_sync() for O_SYNC files.
23 * Here, there will be no transaction running. We wait for any running
24 * transaction to commit.
26 - * - Within sys_sync(), kupdate and such.
27 - * We wait on commit, if tol to.
28 + * - Within flush work (sys_sync(), kupdate and such).
29 + * We wait on commit, if told to.
31 - * - Within prune_icache() (PF_MEMALLOC == true)
32 - * Here we simply return. We can't afford to block kswapd on the
34 + * - Within iput_final() -> write_inode_now()
35 + * We wait on commit, if told to.
37 * In all cases it is actually safe for us to return without doing anything,
38 * because the inode has been copied into a raw inode buffer in
39 - * ext4_mark_inode_dirty(). This is a correctness thing for O_SYNC and for
41 + * ext4_mark_inode_dirty(). This is a correctness thing for WB_SYNC_ALL
44 * Note that we are absolutely dependent upon all inode dirtiers doing the
45 * right thing: they *must* call mark_inode_dirty() after dirtying info in
46 @@ -4453,15 +4452,15 @@ out_brelse:
48 * inode->i_size = expr;
50 - * is in error because a kswapd-driven write_inode() could occur while
51 - * `stuff()' is running, and the new i_size will be lost. Plus the inode
52 - * will no longer be on the superblock's dirty inode list.
53 + * is in error because write_inode() could occur while `stuff()' is running,
54 + * and the new i_size will be lost. Plus the inode will no longer be on the
55 + * superblock's dirty inode list.
57 int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
61 - if (current->flags & PF_MEMALLOC)
62 + if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
65 if (EXT4_SB(inode->i_sb)->s_journal) {