1 ext4: add ext4_es_store_pblock_status()
3 Avoid false positives by static code analysis tools such as sparse and
4 coverity caused by the fact that we set the physical block, and then
5 the status in the extent_status structure. It is also more efficient
6 to set both of these values at once.
8 Addresses-Coverity-Id: #989077
9 Addresses-Coverity-Id: #989078
10 Addresses-Coverity-Id: #1080722
12 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
15 fs/ext4/extents_status.c | 14 ++++++--------
16 fs/ext4/extents_status.h | 9 +++++++++
17 2 files changed, 15 insertions(+), 8 deletions(-)
19 diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
20 index 3981ff7..a900004 100644
21 --- a/fs/ext4/extents_status.c
22 +++ b/fs/ext4/extents_status.c
23 @@ -658,8 +658,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
27 - ext4_es_store_pblock(&newes, pblk);
28 - ext4_es_store_status(&newes, status);
29 + ext4_es_store_pblock_status(&newes, pblk, status);
30 trace_ext4_es_insert_extent(inode, &newes);
32 ext4_es_insert_extent_check(inode, &newes);
33 @@ -699,8 +698,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
37 - ext4_es_store_pblock(&newes, pblk);
38 - ext4_es_store_status(&newes, status);
39 + ext4_es_store_pblock_status(&newes, pblk, status);
40 trace_ext4_es_cache_extent(inode, &newes);
43 @@ -812,13 +810,13 @@ retry:
45 newes.es_lblk = end + 1;
47 + block = 0x7FDEADBEEF;
48 if (ext4_es_is_written(&orig_es) ||
49 - ext4_es_is_unwritten(&orig_es)) {
50 + ext4_es_is_unwritten(&orig_es))
51 block = ext4_es_pblock(&orig_es) +
52 orig_es.es_len - len2;
53 - ext4_es_store_pblock(&newes, block);
55 - ext4_es_store_status(&newes, ext4_es_status(&orig_es));
56 + ext4_es_store_pblock_status(&newes, block,
57 + ext4_es_status(&orig_es));
58 err = __es_insert_extent(inode, &newes);
60 es->es_lblk = orig_es.es_lblk;
61 diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h
62 index 167f4ab8..f1b62a4 100644
63 --- a/fs/ext4/extents_status.h
64 +++ b/fs/ext4/extents_status.h
65 @@ -129,6 +129,15 @@ static inline void ext4_es_store_status(struct extent_status *es,
66 (es->es_pblk & ~ES_MASK));
69 +static inline void ext4_es_store_pblock_status(struct extent_status *es,
71 + unsigned int status)
73 + es->es_pblk = (((ext4_fsblk_t)
74 + (status & EXTENT_STATUS_FLAGS) << ES_SHIFT) |
78 extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi);
79 extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi);
80 extern void ext4_es_lru_add(struct inode *inode);