Add Jan Kara's ext4 data corruption bugs for blocksize < pagesize
[ext4-patch-queue.git] / use-ext4_ext_next_allocated_block-instead-of-mext_next_extent
blob46e5f8757c5bbfcb3c2c1e05490b9efa47dff336
1 ext4: use ext4_ext_next_allocated_block instead of mext_next_extent
3 From: Dmitry Monakhov <dmonakhov@openvz.org>
5 This allows us to make mext_next_extent static and potentially get rid
6 of it.
8 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 ---
11 Changes from v1-v2:
12  - Optimize traversing inside one leaf (in response to lczerner@ comments)
14  fs/ext4/ext4.h        |    2 --
15  fs/ext4/extents.c     |   16 +++++++---------
16  fs/ext4/move_extent.c |    2 +-
17  3 files changed, 8 insertions(+), 12 deletions(-)
19 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
20 index 5b19760..f8d85f7 100644
21 --- a/fs/ext4/ext4.h
22 +++ b/fs/ext4/ext4.h
23 @@ -2739,8 +2739,6 @@ extern void ext4_double_up_write_data_sem(struct inode *orig_inode,
24  extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
25                              __u64 start_orig, __u64 start_donor,
26                              __u64 len, __u64 *moved_len);
27 -extern int mext_next_extent(struct inode *inode, struct ext4_ext_path *path,
28 -                           struct ext4_extent **extent);
30  /* page-io.c */
31  extern int __init ext4_init_pageio(void);
32 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
33 index 76c2df3..cbbc04b 100644
34 --- a/fs/ext4/extents.c
35 +++ b/fs/ext4/extents.c
36 @@ -5304,7 +5304,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
37         struct ext4_ext_path *path;
38         int ret = 0, depth;
39         struct ext4_extent *extent;
40 -       ext4_lblk_t stop_block, current_block;
41 +       ext4_lblk_t stop_block;
42         ext4_lblk_t ex_start, ex_end;
44         /* Let path point to the last extent */
45 @@ -5365,17 +5365,15 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
46                                          (unsigned long) start);
47                         return -EIO;
48                 }
50 -               current_block = le32_to_cpu(extent->ee_block);
51 -               if (start > current_block) {
52 +               if (start > le32_to_cpu(extent->ee_block)) {
53                         /* Hole, move to the next extent */
54 -                       ret = mext_next_extent(inode, path, &extent);
55 -                       if (ret != 0) {
56 +                       if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) {
57 +                               path[depth].p_ext++;
58 +                       } else {
59 +                               start = ext4_ext_next_allocated_block(path);
60                                 ext4_ext_drop_refs(path);
61                                 kfree(path);
62 -                               if (ret == 1)
63 -                                       ret = 0;
64 -                               break;
65 +                               continue;
66                         }
67                 }
68                 ret = ext4_ext_shift_path_extents(path, shift, inode,
69 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
70 index 671a74b..123a51b 100644
71 --- a/fs/ext4/move_extent.c
72 +++ b/fs/ext4/move_extent.c
73 @@ -76,7 +76,7 @@ copy_extent_status(struct ext4_extent *src, struct ext4_extent *dest)
74   * ext4_ext_path structure refers to the last extent, or a negative error
75   * value on failure.
76   */
77 -int
78 +static int
79  mext_next_extent(struct inode *inode, struct ext4_ext_path *path,
80                       struct ext4_extent **extent)
81  {
82 -- 
83 1.7.1
86 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
87 the body of a message to majordomo@vger.kernel.org
88 More majordomo info at  http://vger.kernel.org/majordomo-info.html