提交 ef86d709 编写于 作者: G Gu Zheng 提交者: Jaegeuk Kim

f2fs: convert inc/dec_valid_node_count to inc/dec one count

Signed-off-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
上级 da19b0dc
...@@ -706,50 +706,48 @@ static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi) ...@@ -706,50 +706,48 @@ static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)
} }
static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi, static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi,
struct inode *inode, struct inode *inode)
unsigned int count)
{ {
block_t valid_block_count; block_t valid_block_count;
unsigned int valid_node_count; unsigned int valid_node_count;
spin_lock(&sbi->stat_lock); spin_lock(&sbi->stat_lock);
valid_block_count = sbi->total_valid_block_count + (block_t)count; valid_block_count = sbi->total_valid_block_count + 1;
sbi->alloc_valid_block_count += (block_t)count;
valid_node_count = sbi->total_valid_node_count + count;
if (valid_block_count > sbi->user_block_count) { if (valid_block_count > sbi->user_block_count) {
spin_unlock(&sbi->stat_lock); spin_unlock(&sbi->stat_lock);
return false; return false;
} }
valid_node_count = sbi->total_valid_node_count + 1;
if (valid_node_count > sbi->total_node_count) { if (valid_node_count > sbi->total_node_count) {
spin_unlock(&sbi->stat_lock); spin_unlock(&sbi->stat_lock);
return false; return false;
} }
if (inode) if (inode)
inode->i_blocks += count; inode->i_blocks++;
sbi->total_valid_node_count = valid_node_count;
sbi->total_valid_block_count = valid_block_count; sbi->alloc_valid_block_count++;
sbi->total_valid_node_count++;
sbi->total_valid_block_count++;
spin_unlock(&sbi->stat_lock); spin_unlock(&sbi->stat_lock);
return true; return true;
} }
static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
struct inode *inode, struct inode *inode)
unsigned int count)
{ {
spin_lock(&sbi->stat_lock); spin_lock(&sbi->stat_lock);
f2fs_bug_on(sbi->total_valid_block_count < count); f2fs_bug_on(!sbi->total_valid_block_count);
f2fs_bug_on(sbi->total_valid_node_count < count); f2fs_bug_on(!sbi->total_valid_node_count);
f2fs_bug_on(inode->i_blocks < count); f2fs_bug_on(!inode->i_blocks);
inode->i_blocks -= count; inode->i_blocks--;
sbi->total_valid_node_count -= count; sbi->total_valid_node_count--;
sbi->total_valid_block_count -= (block_t)count; sbi->total_valid_block_count--;
spin_unlock(&sbi->stat_lock); spin_unlock(&sbi->stat_lock);
} }
......
...@@ -502,7 +502,7 @@ static void truncate_node(struct dnode_of_data *dn) ...@@ -502,7 +502,7 @@ static void truncate_node(struct dnode_of_data *dn)
/* Deallocate node address */ /* Deallocate node address */
invalidate_blocks(sbi, ni.blk_addr); invalidate_blocks(sbi, ni.blk_addr);
dec_valid_node_count(sbi, dn->inode, 1); dec_valid_node_count(sbi, dn->inode);
set_node_addr(sbi, &ni, NULL_ADDR); set_node_addr(sbi, &ni, NULL_ADDR);
if (dn->nid == dn->inode->i_ino) { if (dn->nid == dn->inode->i_ino) {
...@@ -851,7 +851,7 @@ struct page *new_node_page(struct dnode_of_data *dn, ...@@ -851,7 +851,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
if (!page) if (!page)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (!inc_valid_node_count(sbi, dn->inode, 1)) { if (!inc_valid_node_count(sbi, dn->inode)) {
err = -ENOSPC; err = -ENOSPC;
goto fail; goto fail;
} }
...@@ -1560,7 +1560,7 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) ...@@ -1560,7 +1560,7 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
new_ni = old_ni; new_ni = old_ni;
new_ni.ino = ino; new_ni.ino = ino;
if (!inc_valid_node_count(sbi, NULL, 1)) if (!inc_valid_node_count(sbi, NULL))
WARN_ON(1); WARN_ON(1);
set_node_addr(sbi, &new_ni, NEW_ADDR); set_node_addr(sbi, &new_ni, NEW_ADDR);
inc_valid_inode_count(sbi); inc_valid_inode_count(sbi);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册