add patch fix-sleep-in-atomic-context-in-grab_mapping_entry
[ext4-patch-queue.git] / allow-inode-expansion-for-nojournal-file-systems
blobcc57a5a1003f68f2e24b9580ddc8070c7ff74e25
1 ext4: allow inode expansion for nojournal file systems
3 From: Eric Whitney <enwlinux@gmail.com>
5 Runs of xfstest ext4/022 on nojournal file systems result in failures
6 because the inodes of some of its test files do not expand as expected.
7 The cause is a conditional in ext4_mark_inode_dirty() that prevents inode
8 expansion unless the test file system has a journal.  Remove this
9 unnecessary restriction.
11 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 ---
14  fs/ext4/inode.c | 12 +++++++-----
15  1 file changed, 7 insertions(+), 5 deletions(-)
17 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
18 index 9c06472..260da4d 100644
19 --- a/fs/ext4/inode.c
20 +++ b/fs/ext4/inode.c
21 @@ -5455,18 +5455,20 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
22         err = ext4_reserve_inode_write(handle, inode, &iloc);
23         if (err)
24                 return err;
25 -       if (ext4_handle_valid(handle) &&
26 -           EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize &&
27 +       if (EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize &&
28             !ext4_test_inode_state(inode, EXT4_STATE_NO_EXPAND)) {
29                 /*
30 -                * We need extra buffer credits since we may write into EA block
31 +                * In nojournal mode, we can immediately attempt to expand
32 +                * the inode.  When journaled, we first need to obtain extra
33 +                * buffer credits since we may write into the EA block
34                  * with this same handle. If journal_extend fails, then it will
35                  * only result in a minor loss of functionality for that inode.
36                  * If this is felt to be critical, then e2fsck should be run to
37                  * force a large enough s_min_extra_isize.
38                  */
39 -               if ((jbd2_journal_extend(handle,
40 -                            EXT4_DATA_TRANS_BLOCKS(inode->i_sb))) == 0) {
41 +               if (!ext4_handle_valid(handle) ||
42 +                   jbd2_journal_extend(handle,
43 +                            EXT4_DATA_TRANS_BLOCKS(inode->i_sb)) == 0) {
44                         ret = ext4_expand_extra_isize(inode,
45                                                       sbi->s_want_extra_isize,
46                                                       iloc, handle);
47 -- 
48 2.1.4