diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-06-13 00:07:31 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-06-22 21:05:08 -0400 |
commit | 98397ff3cddcfdedd2ba1701bd30a73c1d733769 (patch) | |
tree | 2f3180fcfe2057df1c849482cebd7d1b6fe1c179 /fs/f2fs | |
parent | ead432756ab2c76b1f1de742a1c8a06992cb98eb (diff) |
f2fs: fix not to allocate unnecessary blocks during fallocate
This patch fixes the fallocate bug like below. (See xfstests/255)
In fallocate(fd, 0, 20480),
expand_inode_data processes
for (index = pg_start; index <= pg_end; index++) {
f2fs_reserve_block();
...
}
So, even though fallocate requests 20480, 5 blocks, f2fs allocates 6 blocks
including pg_end.
So, this patch adds one condition to avoid block allocation.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/file.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index f6c4bdaaae86..7d8b96275092 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -664,11 +664,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset, | |||
664 | for (index = pg_start; index <= pg_end; index++) { | 664 | for (index = pg_start; index <= pg_end; index++) { |
665 | struct dnode_of_data dn; | 665 | struct dnode_of_data dn; |
666 | 666 | ||
667 | if (index == pg_end && !off_end) | ||
668 | goto noalloc; | ||
669 | |||
667 | set_new_dnode(&dn, inode, NULL, NULL, 0); | 670 | set_new_dnode(&dn, inode, NULL, NULL, 0); |
668 | ret = f2fs_reserve_block(&dn, index); | 671 | ret = f2fs_reserve_block(&dn, index); |
669 | if (ret) | 672 | if (ret) |
670 | break; | 673 | break; |
671 | 674 | noalloc: | |
672 | if (pg_start == pg_end) | 675 | if (pg_start == pg_end) |
673 | new_size = offset + len; | 676 | new_size = offset + len; |
674 | else if (index == pg_start && off_start) | 677 | else if (index == pg_start && off_start) |