[PATCH 0/2] block/export/fuse: fix regression with O_TRUNC when export is not growable

Fiona Ebner posted 2 patches 3 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260702132256.661429-1-f.ebner@proxmox.com
Maintainers: Hanna Reitz <hreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
block/export/fuse.c                        |  12 ++
tests/qemu-iotests/tests/fuse-truncate     | 171 +++++++++++++++++++++
tests/qemu-iotests/tests/fuse-truncate.out |   5 +
3 files changed, 188 insertions(+)
create mode 100755 tests/qemu-iotests/tests/fuse-truncate
create mode 100644 tests/qemu-iotests/tests/fuse-truncate.out
[PATCH 0/2] block/export/fuse: fix regression with O_TRUNC when export is not growable
Posted by Fiona Ebner 3 weeks, 2 days ago
Before commit a94a1d7699 ("fuse: Manually process requests (without
libfuse)"), the O_TRUNC flag when open()-ing an export would be
ignored. This is because libfuse sets FUSE_CAP_ATOMIC_O_TRUNC, so the
kernel lets user space handle the O_TRUNC flag, which is ignored by
the fuse code for export. After the commit, FUSE_CAP_ATOMIC_O_TRUNC is
not set anymore, so the O_TRUNC flag is handled by the kernel, which
executes a truncate.

For blockdev-based exports, this causes a regression, because opening
with O_TRUNC would previously work, but results in an ENOTSUP after
commit a94a1d7699. For file-based exports, the fact that truncate is
executed can be considered an improvement in general. However, in
combination with growable=off, this still results in a practical
regression in combination with virt-fw-vars, which opens its output
file with O_TRUNC and previously worked with a file-based export with
growable=off. After commit a94a1d7699, the file is truncated upon open
and then cannot grow, meaning virt-fw-vars won't be able to write the
output.

To fix these regressions, while keeping the improved behavior for
file-based exports with growable=on, set the FUSE_CAP_ATOMIC_O_TRUNC
flag again if growable=off.

Fiona Ebner (2):
  block/export/fuse: fix regression with O_TRUNC when export is not
    growable
  iotests: test O_TRUNC behavior for fuse exports

 block/export/fuse.c                        |  12 ++
 tests/qemu-iotests/tests/fuse-truncate     | 171 +++++++++++++++++++++
 tests/qemu-iotests/tests/fuse-truncate.out |   5 +
 3 files changed, 188 insertions(+)
 create mode 100755 tests/qemu-iotests/tests/fuse-truncate
 create mode 100644 tests/qemu-iotests/tests/fuse-truncate.out

-- 
2.47.3