Commit 7cddc193924ef6ce679ef0977e01e96d0aedfd1d
Committed by
Chris Mason
1 parent
c095ba7224
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
btrfs: fix file truncation if FALLOC_FL_KEEP_SIZE is specified
Create a small file and fallocate it to a big size with FALLOC_FL_KEEP_SIZE option, then truncate it back to the small size again, the disk free space is not changed back in this case. i.e, total 4 -rw-r--r-- 1 root root 512 Jun 28 11:35 test Filesystem Size Used Avail Use% Mounted on .... /dev/sdb1 8.0G 56K 7.2G 1% /mnt -rw-r--r-- 1 root root 512 Jun 28 11:35 /mnt/test Filesystem Size Used Avail Use% Mounted on .... /dev/sdb1 8.0G 5.1G 2.2G 70% /mnt Filesystem Size Used Avail Use% Mounted on .... /dev/sdb1 8.0G 5.1G 2.2G 70% /mnt With this fix, the truncated up space is back as: Filesystem Size Used Avail Use% Mounted on .... /dev/sdb1 8.0G 56K 7.2G 1% /mnt Signed-off-by: Jie Liu <jeff.liu@oracle.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Showing 1 changed file with 0 additions and 3 deletions Side-by-side Diff
fs/btrfs/inode.c
... | ... | @@ -4391,9 +4391,6 @@ |
4391 | 4391 | int mask = attr->ia_valid; |
4392 | 4392 | int ret; |
4393 | 4393 | |
4394 | - if (newsize == oldsize) | |
4395 | - return 0; | |
4396 | - | |
4397 | 4394 | /* |
4398 | 4395 | * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a |
4399 | 4396 | * special case where we need to update the times despite not having |