You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
virtiofs: fallocate: should enlarge but not shrink the file
Before this patch on virtiofs we had:
```
$ fallocate -o 0 -l 1024 f
$ ls -l f
-rw-r--r-- 1 root root 1024 Jun 24 13:00 f
$ fallocate -o 0 -l 512 f
$ ls -l f
-rw-r--r-- 1 root root 512 Jun 24 13:00 f
```
Unfortunately the second `fallocate` call caused the file to shrink, due to
the call to `ftruncate`.
On a tmpfs for comparison the file doesn't shrink:
```
$ fallocate -o 0 -l 1024 f
$ ls -l f
-rw-r--r-- 1 root root 1024 Jun 24 12:55 f
$ fallocate -o 0 -l 512 f
$ ls -l f
-rw-r--r-- 1 root root 1024 Jun 24 12:56 f
```
This patch only calls ftuncate() if the proposed_length is larger
than the current length.
Signed-off-by: David Scott <[email protected]>
0 commit comments