file size wrong directly after copying a file
System information
Linux | zfs-2.2.4-1 zfs-kmod-2.2.4-1
--- | --- NixOS | 24.05 | 6.646 | x86_64 | zfs-2.2.4-1 zfs-kmod-2.2.4-1 |
Describe the problem you're observing
i have a script that copy a files and calls du directly afterwards. it shows the wrong filesize. after a few seconds it is correct. the copy doesnt run in the background
Describe how to reproduce the problem
the two du commands in the second line show different sizes. they should be identical
dd if=/dev/random of=/tmp/testfile bs=4M count=256 && cp /tmp/testfile . && du -sh testfile && sleep 1 && du -sh testfile
Physical disk space usage for a written file is just not known until ZFS transaction group commit is completed. If you really need it to be accurate, you may have to insert zpool sync call before the du, but it may affect performance.
Physical disk space usage for a written file is just not known until ZFS transaction group commit is completed. If you really need it to be accurate, you may have to insert
zpool synccall before thedu, but it may affect performance.
is there a way to delay the return of cp until the zfs transaction group is committed? i dont want to wait for all io on all pools to sync. i just need this cp call to be synced.
in that specific case i could help myself by just du'ing the source file instead of the destination though.