diff options
author | Zheng Liu <wenqing.lz@taobao.com> | 2014-04-12 12:45:55 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-04-12 12:45:55 -0400 |
commit | 847c6c422aa0ae81a5517a9558ec2737806dca48 (patch) | |
tree | ce45535cc38fecbc4a11d5d9c8e60d403cc1bf27 /fs/ext4/extents.c | |
parent | 6e6358fc3c3c862bfe9a5bc029d3f8ce43dc9765 (diff) |
ext4: fix byte order problems introduced by the COLLAPSE_RANGE patches
This commit tries to fix some byte order issues that is found by sparse
check.
$ make M=fs/ext4 C=2 CF=-D__CHECK_ENDIAN__
...
CHECK fs/ext4/extents.c
fs/ext4/extents.c:5232:41: warning: restricted __le32 degrades to integer
fs/ext4/extents.c:5236:52: warning: bad assignment (-=) to restricted __le32
fs/ext4/extents.c:5258:45: warning: bad assignment (-=) to restricted __le32
fs/ext4/extents.c:5303:28: warning: restricted __le32 degrades to integer
fs/ext4/extents.c:5318:18: warning: incorrect type in assignment (different base types)
fs/ext4/extents.c:5318:18: expected unsigned int [unsigned] [usertype] ex_start
fs/ext4/extents.c:5318:18: got restricted __le32 [usertype] ee_block
fs/ext4/extents.c:5319:24: warning: restricted __le32 degrades to integer
fs/ext4/extents.c:5334:31: warning: incorrect type in assignment (different base types)
...
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index b2d3869b5762..f24ef8697609 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -5229,11 +5229,11 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, | |||
5229 | if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) | 5229 | if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) |
5230 | update = 1; | 5230 | update = 1; |
5231 | 5231 | ||
5232 | *start = ex_last->ee_block + | 5232 | *start = le32_to_cpu(ex_last->ee_block) + |
5233 | ext4_ext_get_actual_len(ex_last); | 5233 | ext4_ext_get_actual_len(ex_last); |
5234 | 5234 | ||
5235 | while (ex_start <= ex_last) { | 5235 | while (ex_start <= ex_last) { |
5236 | ex_start->ee_block -= shift; | 5236 | le32_add_cpu(&ex_start->ee_block, -shift); |
5237 | if (ex_start > | 5237 | if (ex_start > |
5238 | EXT_FIRST_EXTENT(path[depth].p_hdr)) { | 5238 | EXT_FIRST_EXTENT(path[depth].p_hdr)) { |
5239 | if (ext4_ext_try_to_merge_right(inode, | 5239 | if (ext4_ext_try_to_merge_right(inode, |
@@ -5255,7 +5255,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, | |||
5255 | if (err) | 5255 | if (err) |
5256 | goto out; | 5256 | goto out; |
5257 | 5257 | ||
5258 | path[depth].p_idx->ei_block -= shift; | 5258 | le32_add_cpu(&path[depth].p_idx->ei_block, -shift); |
5259 | err = ext4_ext_dirty(handle, inode, path + depth); | 5259 | err = ext4_ext_dirty(handle, inode, path + depth); |
5260 | if (err) | 5260 | if (err) |
5261 | goto out; | 5261 | goto out; |
@@ -5300,7 +5300,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, | |||
5300 | return ret; | 5300 | return ret; |
5301 | } | 5301 | } |
5302 | 5302 | ||
5303 | stop_block = extent->ee_block + ext4_ext_get_actual_len(extent); | 5303 | stop_block = le32_to_cpu(extent->ee_block) + |
5304 | ext4_ext_get_actual_len(extent); | ||
5304 | ext4_ext_drop_refs(path); | 5305 | ext4_ext_drop_refs(path); |
5305 | kfree(path); | 5306 | kfree(path); |
5306 | 5307 | ||
@@ -5315,8 +5316,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, | |||
5315 | path = ext4_ext_find_extent(inode, start - 1, NULL, 0); | 5316 | path = ext4_ext_find_extent(inode, start - 1, NULL, 0); |
5316 | depth = path->p_depth; | 5317 | depth = path->p_depth; |
5317 | extent = path[depth].p_ext; | 5318 | extent = path[depth].p_ext; |
5318 | ex_start = extent->ee_block; | 5319 | ex_start = le32_to_cpu(extent->ee_block); |
5319 | ex_end = extent->ee_block + ext4_ext_get_actual_len(extent); | 5320 | ex_end = le32_to_cpu(extent->ee_block) + |
5321 | ext4_ext_get_actual_len(extent); | ||
5320 | ext4_ext_drop_refs(path); | 5322 | ext4_ext_drop_refs(path); |
5321 | kfree(path); | 5323 | kfree(path); |
5322 | 5324 | ||
@@ -5331,7 +5333,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, | |||
5331 | return PTR_ERR(path); | 5333 | return PTR_ERR(path); |
5332 | depth = path->p_depth; | 5334 | depth = path->p_depth; |
5333 | extent = path[depth].p_ext; | 5335 | extent = path[depth].p_ext; |
5334 | current_block = extent->ee_block; | 5336 | current_block = le32_to_cpu(extent->ee_block); |
5335 | if (start > current_block) { | 5337 | if (start > current_block) { |
5336 | /* Hole, move to the next extent */ | 5338 | /* Hole, move to the next extent */ |
5337 | ret = mext_next_extent(inode, path, &extent); | 5339 | ret = mext_next_extent(inode, path, &extent); |