add patch fix-punch-hole-for-inline_data
[ext4-patch-queue.git] / fix-warning-when-turn-on-dioread_nolock-and-inline_data
blobeaae3ea261cfa47923c23e3d94f4067dade2b657
1 ext4: fix warning when turn on dioread_nolock and inline_data
3 From: yangerkun <yangerkun@huawei.com>
5 mkfs.ext4 -O inline_data /dev/vdb
6 mount -o dioread_nolock /dev/vdb /mnt
7 echo "some inline data..." >> /mnt/test-file
8 echo "some inline data..." >> /mnt/test-file
9 sync
11 The above script will trigger "WARN_ON(!io_end->handle && sbi->s_journal)"
12 because ext4_should_dioread_nolock() returns false for a file with inline
13 data. Move the check to a place after we have already removed the inline
14 data and prepared inode to write normal pages.
16 Reviewed-by: Jan Kara <jack@suse.cz>
17 Signed-off-by: yangerkun <yangerkun@huawei.com>
18 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
19 ---
20  fs/ext4/inode.c | 18 +++++++++---------
21  1 file changed, 9 insertions(+), 9 deletions(-)
23 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
24 index c7f77c6..3f2a366 100644
25 --- a/fs/ext4/inode.c
26 +++ b/fs/ext4/inode.c
27 @@ -2769,15 +2769,6 @@ static int ext4_writepages(struct address_space *mapping,
28                 goto out_writepages;
29         }
31 -       if (ext4_should_dioread_nolock(inode)) {
32 -               /*
33 -                * We may need to convert up to one extent per block in
34 -                * the page and we may dirty the inode.
35 -                */
36 -               rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
37 -                                               PAGE_SIZE >> inode->i_blkbits);
38 -       }
40         /*
41          * If we have inline data and arrive here, it means that
42          * we will soon create the block for the 1st page, so
43 @@ -2796,6 +2787,15 @@ static int ext4_writepages(struct address_space *mapping,
44                 ext4_journal_stop(handle);
45         }
47 +       if (ext4_should_dioread_nolock(inode)) {
48 +               /*
49 +                * We may need to convert up to one extent per block in
50 +                * the page and we may dirty the inode.
51 +                */
52 +               rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
53 +                                               PAGE_SIZE >> inode->i_blkbits);
54 +       }
56         if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
57                 range_whole = 1;