f2fs: don't miss any f2fs_balance_fs cases
commit 6f2d8ed654bfa391854df4de854953f772a16a9d upstream. In f2fs_map_blocks, let f2fs_balance_fs detects node page modification with dn.node_changed to avoid miss some corner cases. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
4c7eae1fef
commit
332f40b43f
1 changed files with 3 additions and 8 deletions
|
@ -671,7 +671,6 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
|
||||||
unsigned int ofs_in_node, last_ofs_in_node;
|
unsigned int ofs_in_node, last_ofs_in_node;
|
||||||
blkcnt_t prealloc;
|
blkcnt_t prealloc;
|
||||||
struct extent_info ei;
|
struct extent_info ei;
|
||||||
bool allocated = false;
|
|
||||||
block_t blkaddr;
|
block_t blkaddr;
|
||||||
|
|
||||||
if (!maxblocks)
|
if (!maxblocks)
|
||||||
|
@ -730,10 +729,8 @@ next_block:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = __allocate_data_block(&dn);
|
err = __allocate_data_block(&dn);
|
||||||
if (!err) {
|
if (!err)
|
||||||
set_inode_flag(inode, FI_APPEND_WRITE);
|
set_inode_flag(inode, FI_APPEND_WRITE);
|
||||||
allocated = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (err)
|
if (err)
|
||||||
goto sync_out;
|
goto sync_out;
|
||||||
|
@ -788,7 +785,6 @@ skip:
|
||||||
err = reserve_new_blocks(&dn, prealloc);
|
err = reserve_new_blocks(&dn, prealloc);
|
||||||
if (err)
|
if (err)
|
||||||
goto sync_out;
|
goto sync_out;
|
||||||
allocated = dn.node_changed;
|
|
||||||
|
|
||||||
map->m_len += dn.ofs_in_node - ofs_in_node;
|
map->m_len += dn.ofs_in_node - ofs_in_node;
|
||||||
if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {
|
if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {
|
||||||
|
@ -807,9 +803,8 @@ skip:
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
f2fs_unlock_op(sbi);
|
f2fs_unlock_op(sbi);
|
||||||
f2fs_balance_fs(sbi, allocated);
|
f2fs_balance_fs(sbi, dn.node_changed);
|
||||||
}
|
}
|
||||||
allocated = false;
|
|
||||||
goto next_dnode;
|
goto next_dnode;
|
||||||
|
|
||||||
sync_out:
|
sync_out:
|
||||||
|
@ -817,7 +812,7 @@ sync_out:
|
||||||
unlock_out:
|
unlock_out:
|
||||||
if (create) {
|
if (create) {
|
||||||
f2fs_unlock_op(sbi);
|
f2fs_unlock_op(sbi);
|
||||||
f2fs_balance_fs(sbi, allocated);
|
f2fs_balance_fs(sbi, dn.node_changed);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
trace_f2fs_map_blocks(inode, map, err);
|
trace_f2fs_map_blocks(inode, map, err);
|
||||||
|
|
Loading…
Add table
Reference in a new issue