1 ext4: fix byte order problems introduced by the COLLAPSE_RANGE patches
3 From: Zheng Liu <wenqing.lz@taobao.com>
5 This commit tries to fix some byte order issues that is found by sparse
8 $ make M=fs/ext4 C=2 CF=-D__CHECK_ENDIAN__
10 CHECK fs/ext4/extents.c
11 fs/ext4/extents.c:5232:41: warning: restricted __le32 degrades to integer
12 fs/ext4/extents.c:5236:52: warning: bad assignment (-=) to restricted __le32
13 fs/ext4/extents.c:5258:45: warning: bad assignment (-=) to restricted __le32
14 fs/ext4/extents.c:5303:28: warning: restricted __le32 degrades to integer
15 fs/ext4/extents.c:5318:18: warning: incorrect type in assignment (different base types)
16 fs/ext4/extents.c:5318:18: expected unsigned int [unsigned] [usertype] ex_start
17 fs/ext4/extents.c:5318:18: got restricted __le32 [usertype] ee_block
18 fs/ext4/extents.c:5319:24: warning: restricted __le32 degrades to integer
19 fs/ext4/extents.c:5334:31: warning: incorrect type in assignment (different base types)
22 Cc: Andreas Dilger <adilger.kernel@dilger.ca>
23 Cc: Namjae Jeon <namjae.jeon@samsung.com>
24 Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
25 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
27 fs/ext4/extents.c | 16 +++++++++-------
28 1 file changed, 9 insertions(+), 7 deletions(-)
30 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
31 index 82df3ce..1867af6 100644
32 --- a/fs/ext4/extents.c
33 +++ b/fs/ext4/extents.c
34 @@ -5229,11 +5229,11 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,
35 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr))
38 - *start = ex_last->ee_block +
39 + *start = le32_to_cpu(ex_last->ee_block) +
40 ext4_ext_get_actual_len(ex_last);
42 while (ex_start <= ex_last) {
43 - ex_start->ee_block -= shift;
44 + le32_add_cpu(&ex_start->ee_block, -shift);
46 EXT_FIRST_EXTENT(path[depth].p_hdr)) {
47 if (ext4_ext_try_to_merge_right(inode,
48 @@ -5255,7 +5255,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,
52 - path[depth].p_idx->ei_block -= shift;
53 + le32_add_cpu(&path[depth].p_idx->ei_block, -shift);
54 err = ext4_ext_dirty(handle, inode, path + depth);
57 @@ -5300,7 +5300,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
61 - stop_block = extent->ee_block + ext4_ext_get_actual_len(extent);
62 + stop_block = le32_to_cpu(extent->ee_block) +
63 + ext4_ext_get_actual_len(extent);
64 ext4_ext_drop_refs(path);
67 @@ -5315,8 +5316,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
68 path = ext4_ext_find_extent(inode, start - 1, NULL, 0);
69 depth = path->p_depth;
70 extent = path[depth].p_ext;
71 - ex_start = extent->ee_block;
72 - ex_end = extent->ee_block + ext4_ext_get_actual_len(extent);
73 + ex_start = le32_to_cpu(extent->ee_block);
74 + ex_end = le32_to_cpu(extent->ee_block) +
75 + ext4_ext_get_actual_len(extent);
76 ext4_ext_drop_refs(path);
79 @@ -5331,7 +5333,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
81 depth = path->p_depth;
82 extent = path[depth].p_ext;
83 - current_block = extent->ee_block;
84 + current_block = le32_to_cpu(extent->ee_block);
85 if (start > current_block) {
86 /* Hole, move to the next extent */
87 ret = mext_next_extent(inode, path, &extent);