Hello,

On a FUSE file system with the kernel's write-back cache, Linux 6.16
and later return an error that occurs while the kernel writes a file
out from the call that sets the file's times or permissions (futimens,
fchmod), and the close() that follows returns 0.  Up to 6.15 the
close() returned it.  virtiofs with virtiofsd's --writeback behaves
the same way.

The change in the kernel is reported to the FUSE maintainers as a
regression, with a patch:
https://lore.kernel.org/all/[email protected]/

mv across file systems treats a failure to set the destination's times
or permissions as a warning, since it does not require them to be
preserved (src/copy.c in 9.12, lines 1050 to 1058, the same on master
at lines 1054 to 1062, and src/mv.c, line 145).  On such a file system
the warning is then the only report that the data was not stored, and
mv goes on to remove the source: the only copy of the file is lost and
mv exits 0.

To reproduce, as an ordinary user (fuse-overlayfs over an upper
directory on a full tmpfs, mounted in a user namespace):

  #!/bin/sh
  # mv across file systems onto a FUSE file system with the write-back cache 
(fuse-overlayfs) whose
  # store is full: on Linux 6.16 and later the call that sets the times returns 
the write error,
  # mv prints a warning, removes the source and exits 0, and the store holds 
nothing of the file.
  # Runs as an ordinary user: tmpfs and fuse-overlayfs are mounted in a user 
namespace.
  # MV names the mv to run (mv by default).
  set -e
  work=$(mktemp -d)
  trap 'rm -rf "$work"' EXIT
  cd "$work"
  unshare --user --map-root-user --mount sh -c '
    set -e
    mkdir low back mnt src
    mount -t tmpfs -o size=8m tmpfs back
    mount -t tmpfs -o size=8m tmpfs src
    mkdir back/upper back/work
    fuse-overlayfs -o 
lowerdir=$PWD/low,upperdir=$PWD/back/upper,workdir=$PWD/back/work "$PWD/mnt"
    head -c 1048576 /dev/urandom > src/file
    # Fill the file system under the upper directory.
    head -c 16777216 /dev/zero > back/filler 2>/dev/null || true
    status=0
    "${MV:-mv}" src/file mnt/file 2>&1 || status=$?
    echo "mv exit status: $status"
    echo "source still there: $(test -e src/file && echo yes || echo no)"
    echo "size in the upper directory: $(stat -c %s back/upper/file 2>/dev/null 
|| echo none)"
    fusermount3 -u mnt
  '

Output with coreutils 9.12 on Linux 7.3.4 (fuse-overlayfs 1.17):

  mv: preserving times for 'mnt/file': No space left on device
  mv exit status: 0
  source still there: no
  size in the upper directory: 0

A suggestion: when setting the times, permissions or owner of the
destination fails with EIO, ENOSPC or EDQUOT, treat the copy as failed,
as with require_preserve, and keep the source, since on these file
systems the error can stand for data that was not written.  Syncing the
destination before removing the source would catch it as well, at a
cost.



Reply via email to