How does quota usage for ZFS on Linux work?
I have a user who according to ZFS is at their quota. However, I cannot find how they are using all of their space. This file system has no descendant file systems and according to the man page the userquota space calculation does not include space that is used by descendent datasets, such as snapshots and clones.
Why do zfs and find&du disagree to such a large extent?
# zfs get -H userquota@user1 zpool/zfs1 && zfs get -H userused@user1 zppol/zfs1
zpool/zfs1 userquota@user1 20G local
zpool/zfs1 userused@user1 20.0G local
# find $(zfs get -H -o value mountpoint zpool/zfs1) -user user1 -print0 | du -hc --files0-from=- | tail -n 1
5.9G total
Additionally, I have another user with seemingly the opposite problem.
# zfs get -H userquota@user2 zpool/zfs1 && zfs get -H userused@user2 zpool/zfs1
zpool/zfs1 userquota@user2 50G local
zpool/zfs1 userused@user2 14.9G local
# find $(zfs get -H -o value mountpoint zpool/zfs1) -user user2 -print0 | du -hc --files0-from=- | tail -n 1
81G total
Solution 1:
In the 1st case, maybe some files of user1 can't be discovered by find(1) because they're hidden by some fs being mounted on top of them?
In the 2nd case, maybe something is mounted somewhere under the zfs1 mountpoint and you include that in the space calculation?
Incidentally,
zfs get -H -o value mountpoint zpool/zfs1
will print just the mountpoint, so you don't need the cut(1).