Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information