Commit 8edd03c8 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: introduce f2fs_i_blocks_write with mark_inode_dirty_sync

This patch introduces f2fs_i_blocks_write() to call mark_inode_dirty_sync() when
changing inode->i_blocks.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent fc9581c8
...@@ -344,7 +344,6 @@ int reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count) ...@@ -344,7 +344,6 @@ int reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
if (set_page_dirty(dn->node_page)) if (set_page_dirty(dn->node_page))
dn->node_changed = true; dn->node_changed = true;
mark_inode_dirty(dn->inode);
sync_inode_page(dn); sync_inode_page(dn);
return 0; return 0;
} }
......
...@@ -1119,6 +1119,7 @@ static inline bool f2fs_has_xattr_block(unsigned int ofs) ...@@ -1119,6 +1119,7 @@ static inline bool f2fs_has_xattr_block(unsigned int ofs)
return ofs == XATTR_NODE_OFFSET; return ofs == XATTR_NODE_OFFSET;
} }
static inline void f2fs_i_blocks_write(struct inode *, blkcnt_t, bool);
static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi, static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
struct inode *inode, blkcnt_t *count) struct inode *inode, blkcnt_t *count)
{ {
...@@ -1141,7 +1142,7 @@ static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi, ...@@ -1141,7 +1142,7 @@ static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
} }
} }
/* *count can be recalculated */ /* *count can be recalculated */
inode->i_blocks += *count; f2fs_i_blocks_write(inode, *count, true);
sbi->total_valid_block_count = sbi->total_valid_block_count =
sbi->total_valid_block_count + (block_t)(*count); sbi->total_valid_block_count + (block_t)(*count);
spin_unlock(&sbi->stat_lock); spin_unlock(&sbi->stat_lock);
...@@ -1157,7 +1158,7 @@ static inline void dec_valid_block_count(struct f2fs_sb_info *sbi, ...@@ -1157,7 +1158,7 @@ static inline void dec_valid_block_count(struct f2fs_sb_info *sbi,
spin_lock(&sbi->stat_lock); spin_lock(&sbi->stat_lock);
f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count); f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count);
f2fs_bug_on(sbi, inode->i_blocks < count); f2fs_bug_on(sbi, inode->i_blocks < count);
inode->i_blocks -= count; f2fs_i_blocks_write(inode, count, false);
sbi->total_valid_block_count -= (block_t)count; sbi->total_valid_block_count -= (block_t)count;
spin_unlock(&sbi->stat_lock); spin_unlock(&sbi->stat_lock);
} }
...@@ -1294,7 +1295,7 @@ static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi, ...@@ -1294,7 +1295,7 @@ static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi,
} }
if (inode) if (inode)
inode->i_blocks++; f2fs_i_blocks_write(inode, 1, true);
sbi->total_valid_node_count++; sbi->total_valid_node_count++;
sbi->total_valid_block_count++; sbi->total_valid_block_count++;
...@@ -1313,7 +1314,7 @@ static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, ...@@ -1313,7 +1314,7 @@ static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
f2fs_bug_on(sbi, !sbi->total_valid_node_count); f2fs_bug_on(sbi, !sbi->total_valid_node_count);
f2fs_bug_on(sbi, !inode->i_blocks); f2fs_bug_on(sbi, !inode->i_blocks);
inode->i_blocks--; f2fs_i_blocks_write(inode, 1, false);
sbi->total_valid_node_count--; sbi->total_valid_node_count--;
sbi->total_valid_block_count--; sbi->total_valid_block_count--;
...@@ -1556,6 +1557,14 @@ static inline void set_acl_inode(struct inode *inode, umode_t mode) ...@@ -1556,6 +1557,14 @@ static inline void set_acl_inode(struct inode *inode, umode_t mode)
set_inode_flag(inode, FI_ACL_MODE); set_inode_flag(inode, FI_ACL_MODE);
} }
static inline void f2fs_i_blocks_write(struct inode *inode,
blkcnt_t diff, bool add)
{
inode->i_blocks = add ? inode->i_blocks + diff :
inode->i_blocks - diff;
mark_inode_dirty_sync(inode);
}
static inline void f2fs_i_size_write(struct inode *inode, loff_t i_size) static inline void f2fs_i_size_write(struct inode *inode, loff_t i_size)
{ {
if (i_size_read(inode) == i_size) if (i_size_read(inode) == i_size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment