add patch add-select-for-CONFIG_FS_IOMAP
[ext4-patch-queue.git] / avoid-split-extents-for-DAX-writes
blobe6c3052918f9c7f6eac2cc62f8a7d3a72ea91e86
1 ext4: avoid split extents for DAX writes
3 From: Jan Kara <jack@suse.cz>
5 Currently mapping of blocks for DAX writes happen with
6 EXT4_GET_BLOCKS_PRE_IO flag set. That has a result that each
7 ext4_map_blocks() call creates a separate written extent, although it
8 could be merged to the neighboring extents in the extent tree.  The
9 reason for using this flag is that in case the extent is unwritten, we
10 need to convert it to written one and zero it out. However this "convert
11 mapped range to written" operation is already implemented by
12 ext4_map_blocks() for the case of data writes into unwritten extent. So
13 just use flags for that mode of operation, simplify the code, and avoid
14 unnecessary split extents.
16 Signed-off-by: Jan Kara <jack@suse.cz>
17 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18 ---
19  fs/ext4/inode.c | 17 -----------------
20  1 file changed, 17 deletions(-)
22 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
23 index a7079cab645a..3192ec0768d4 100644
24 --- a/fs/ext4/inode.c
25 +++ b/fs/ext4/inode.c
26 @@ -3351,7 +3351,6 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
27                         return PTR_ERR(handle);
29                 ret = ext4_map_blocks(handle, inode, &map,
30 -                                     EXT4_GET_BLOCKS_PRE_IO |
31                                       EXT4_GET_BLOCKS_CREATE_ZERO);
32                 if (ret < 0) {
33                         ext4_journal_stop(handle);
34 @@ -3360,22 +3359,6 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
35                                 goto retry;
36                         return ret;
37                 }
38 -               /* For DAX writes we need to zero out unwritten extents */
39 -               if (map.m_flags & EXT4_MAP_UNWRITTEN) {
40 -                       /*
41 -                        * We are protected by i_mmap_sem or i_rwsem so we know
42 -                        * block cannot go away from under us even though we
43 -                        * dropped i_data_sem. Convert extent to written and
44 -                        * write zeros there.
45 -                        */
46 -                       ret = ext4_map_blocks(handle, inode, &map,
47 -                                             EXT4_GET_BLOCKS_CONVERT |
48 -                                             EXT4_GET_BLOCKS_CREATE_ZERO);
49 -                       if (ret < 0) {
50 -                               ext4_journal_stop(handle);
51 -                               return ret;
52 -                       }
53 -               }
55                 /*
56                  * If we added blocks beyond i_size we need to make sure they
57 -- 
58 2.6.6