History

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

Jie Liu committed 13 years ago

Commit 7cddc191 parent c095ba71 file · +0 −3Browse files

Unified · Split

fs/btrfs/inode.c+0−3
@@ -4391,9 +4391,6 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) · 4390 unmodified lines
43914391 int mask = attr->ia_valid;
43924392 int ret;
43934393
4394− if (newsize == oldsize)
4395− return 0;
4396−
43974394 /*
43984395 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a
43994396 * special case where we need to update the times despite not having

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t