Commit 6b1bdb5
fuse: allow fallocate(FALLOC_FL_ZERO_RANGE)
The current fuse module filters out fallocate(FALLOC_FL_ZERO_RANGE)
returning -EOPNOTSUPP. libnbd's nbdfuse would like to translate
FALLOC_FL_ZERO_RANGE requests into the NBD command
NBD_CMD_WRITE_ZEROES which allows NBD servers that support it to do
zeroing efficiently.
This commit treats this flag exactly like FALLOC_FL_PUNCH_HOLE.
A way to test this, requiring fuse >= 3, nbdkit >= 1.8 and the latest
nbdfuse from https://gitlab.com/nbdkit/libnbd/-/tree/master/fuse is to
create a file containing some data and "mirror" it to a fuse file:
$ dd if=/dev/urandom of=disk.img bs=1M count=1
$ nbdkit file disk.img
$ touch mirror.img
$ nbdfuse mirror.img nbd://localhost &
(mirror.img -> nbdfuse -> NBD over loopback -> nbdkit -> disk.img)
You can then run commands such as:
$ fallocate -z -o 1024 -l 1024 mirror.img
and check that the content of the original file ("disk.img") stays
synchronized. To show NBD commands, export LIBNBD_DEBUG=1 before
running nbdfuse. To clean up:
$ fusermount3 -u mirror.img
$ killall nbdkit
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>1 parent 1b53991 commit 6b1bdb5
1 file changed
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2907 | 2907 | | |
2908 | 2908 | | |
2909 | 2909 | | |
2910 | | - | |
| 2910 | + | |
| 2911 | + | |
2911 | 2912 | | |
2912 | 2913 | | |
2913 | 2914 | | |
2914 | | - | |
| 2915 | + | |
| 2916 | + | |
2915 | 2917 | | |
2916 | 2918 | | |
2917 | 2919 | | |
| |||
2926 | 2928 | | |
2927 | 2929 | | |
2928 | 2930 | | |
2929 | | - | |
| 2931 | + | |
2930 | 2932 | | |
2931 | 2933 | | |
2932 | 2934 | | |
| |||
2966 | 2968 | | |
2967 | 2969 | | |
2968 | 2970 | | |
2969 | | - | |
| 2971 | + | |
2970 | 2972 | | |
2971 | 2973 | | |
2972 | 2974 | | |
| |||
0 commit comments