提交 9a6633b1 编写于 作者: T Theodore Ts'o

ext4: add ext4_es_store_pblock_status()

Avoid false positives by static code analysis tools such as sparse and
coverity caused by the fact that we set the physical block, and then
the status in the extent_status structure.  It is also more efficient
to set both of these values at once.

Addresses-Coverity-Id: #989077
Addresses-Coverity-Id: #989078
Addresses-Coverity-Id: #1080722
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: NZheng Liu <wenqing.lz@taobao.com>
上级 ce37c429
...@@ -658,8 +658,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, ...@@ -658,8 +658,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
newes.es_lblk = lblk; newes.es_lblk = lblk;
newes.es_len = len; newes.es_len = len;
ext4_es_store_pblock(&newes, pblk); ext4_es_store_pblock_status(&newes, pblk, status);
ext4_es_store_status(&newes, status);
trace_ext4_es_insert_extent(inode, &newes); trace_ext4_es_insert_extent(inode, &newes);
ext4_es_insert_extent_check(inode, &newes); ext4_es_insert_extent_check(inode, &newes);
...@@ -699,8 +698,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk, ...@@ -699,8 +698,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
newes.es_lblk = lblk; newes.es_lblk = lblk;
newes.es_len = len; newes.es_len = len;
ext4_es_store_pblock(&newes, pblk); ext4_es_store_pblock_status(&newes, pblk, status);
ext4_es_store_status(&newes, status);
trace_ext4_es_cache_extent(inode, &newes); trace_ext4_es_cache_extent(inode, &newes);
if (!len) if (!len)
...@@ -812,13 +810,13 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, ...@@ -812,13 +810,13 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
newes.es_lblk = end + 1; newes.es_lblk = end + 1;
newes.es_len = len2; newes.es_len = len2;
block = 0x7FDEADBEEF;
if (ext4_es_is_written(&orig_es) || if (ext4_es_is_written(&orig_es) ||
ext4_es_is_unwritten(&orig_es)) { ext4_es_is_unwritten(&orig_es))
block = ext4_es_pblock(&orig_es) + block = ext4_es_pblock(&orig_es) +
orig_es.es_len - len2; orig_es.es_len - len2;
ext4_es_store_pblock(&newes, block); ext4_es_store_pblock_status(&newes, block,
} ext4_es_status(&orig_es));
ext4_es_store_status(&newes, ext4_es_status(&orig_es));
err = __es_insert_extent(inode, &newes); err = __es_insert_extent(inode, &newes);
if (err) { if (err) {
es->es_lblk = orig_es.es_lblk; es->es_lblk = orig_es.es_lblk;
......
...@@ -129,6 +129,15 @@ static inline void ext4_es_store_status(struct extent_status *es, ...@@ -129,6 +129,15 @@ static inline void ext4_es_store_status(struct extent_status *es,
(es->es_pblk & ~ES_MASK)); (es->es_pblk & ~ES_MASK));
} }
static inline void ext4_es_store_pblock_status(struct extent_status *es,
ext4_fsblk_t pb,
unsigned int status)
{
es->es_pblk = (((ext4_fsblk_t)
(status & EXTENT_STATUS_FLAGS) << ES_SHIFT) |
(pb & ~ES_MASK));
}
extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi); extern void ext4_es_register_shrinker(struct ext4_sb_info *sbi);
extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi); extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi);
extern void ext4_es_lru_add(struct inode *inode); extern void ext4_es_lru_add(struct inode *inode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册