Commit cb3358c5 authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Greg Kroah-Hartman

f2fs: do f2fs_balance_fs when block is allocated

commit 3c082b7b upstream.

We should consider data block allocation to trigger f2fs_balance_fs.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent baf12a6b
...@@ -504,7 +504,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset, ...@@ -504,7 +504,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
struct dnode_of_data dn; struct dnode_of_data dn;
u64 start = F2FS_BYTES_TO_BLK(offset); u64 start = F2FS_BYTES_TO_BLK(offset);
u64 len = F2FS_BYTES_TO_BLK(count); u64 len = F2FS_BYTES_TO_BLK(count);
bool allocated; bool allocated = false;
u64 end_offset; u64 end_offset;
int err = 0; int err = 0;
...@@ -546,7 +546,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset, ...@@ -546,7 +546,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
f2fs_balance_fs(sbi, dn.node_changed); f2fs_balance_fs(sbi, allocated);
} }
return err; return err;
...@@ -556,7 +556,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset, ...@@ -556,7 +556,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);
out: out:
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
f2fs_balance_fs(sbi, dn.node_changed); f2fs_balance_fs(sbi, allocated);
return err; return err;
} }
...@@ -650,14 +650,14 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, ...@@ -650,14 +650,14 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
if (dn.ofs_in_node >= end_offset) { if (dn.ofs_in_node >= end_offset) {
if (allocated) if (allocated)
sync_inode_page(&dn); sync_inode_page(&dn);
allocated = false;
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);
if (create) { if (create) {
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
f2fs_balance_fs(sbi, dn.node_changed); f2fs_balance_fs(sbi, allocated);
f2fs_lock_op(sbi); f2fs_lock_op(sbi);
} }
allocated = false;
set_new_dnode(&dn, inode, NULL, NULL, 0); set_new_dnode(&dn, inode, NULL, NULL, 0);
err = get_dnode_of_data(&dn, pgofs, mode); err = get_dnode_of_data(&dn, pgofs, mode);
...@@ -715,7 +715,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, ...@@ -715,7 +715,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
unlock_out: unlock_out:
if (create) { if (create) {
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
f2fs_balance_fs(sbi, dn.node_changed); f2fs_balance_fs(sbi, allocated);
} }
out: out:
trace_f2fs_map_blocks(inode, map, err); trace_f2fs_map_blocks(inode, map, err);
......
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