Bug #46278
closedmds: Subvolume snapshot directory does not save attribute "ceph.quota.max_bytes" of snapshot source directory tree
0%
Description
NOTE: This is applicable even without using subvolume snapshots
A snapshot of a directory with quota set on it, via the xattr "ceph.quota.max_bytes", does not contain the same xattr preserved on the snapshot directory.
This prevents a clone of a subvolume snapshot, to read and set the same quota on the cloned subvolume.
Tests/experiments done:
1. Quota enforcement, based on a simple test, with hierarchical quotas, enforces the first minimum quota that is breached (as expected)
- NOTE: (q:NUM) is the quota on the directory is NUM bytes
- if quota looked like so: /dir(q:1024)/subdir(q:2048) a dd of > 1024 bytes on /dir/subdir/dd.bin fails
- if quota looked like so: /dir(q:2048)/subdir(q:1024) a dd of > 1024 bytes on /dir/subdir/dd.bin fails
2. Snapshot COW blocks do not seem to be accounted for in the space consumption of the snapshot source directory
- if quota looked like so: /dir(q:1024), the following operations never fail and snapshots hold onto older content, which would total to greater than the directory quota
- (repeat for i:1..10)
- dd if=/dev/urandom of=/mnt/dev/cephfs/dir/dd.bin count=1 bs=1000
- mkdir /mnt/dev/cephfs/dir/.snap/snap[i]
- rm /mnt/dev/cephfs/dir/dd.bin
- I am unsure if this is the right behavior
3. Also tested if a subdirectory of a directory being snapshotted, that has an explicit quota set on it is preserved in the snapshot, it is not
- Test goes something like so,
- getfattr -n ceph.quota.max_bytes /mnt/dev/cephfs/dir/sdir
# file: mnt/dev/cephfs/dir/sdir
ceph.quota.max_bytes="1024"
- mkdir /mnt/dev/cephfs/dir/.snap/snap5
- getfattr -n ceph.quota.max_bytes /mnt/dev/cephfs/dir/.snap/snap5/sdir
/mnt/dev/cephfs/dir/.snap/snap5/sdir: ceph.quota.max_bytes: No such attribute
Based on 1 and 2 above, we could safely preserve the quota xattr on the snapshot directory, as the parent of the snapshot directory would enforce any quota breach.
I am not sure about (2) though, as in, if that is the designed/expected behavior.