CephFS directory quotas limit how much data or how many files a workload can place below one point in a shared filesystem. They are useful for tenant, project, or application trees that should not consume the capacity of the whole CephFS namespace.
CephFS stores quotas as virtual extended attributes on the directory. ceph.quota.max_bytes controls byte usage, ceph.quota.max_files controls file count, and the client that changes those attributes needs the MDS p capability in addition to read/write access.
Quota enforcement happens in the mounted client, so keep cluster capacity monitoring in place and use quotas as guardrails rather than a security boundary for hostile clients. With path-restricted client keys, place the quota on the restricted directory or a child directory that the mounted client can see.
Related: How to create a CephFS filesystem
Related: How to mount CephFS on Linux
Steps to set a CephFS directory quota:
- Confirm the target path is on a CephFS mount.
$ findmnt -T /mnt/cephfs/projects/app TARGET SOURCE FSTYPE OPTIONS /mnt/cephfs ceph-fuse[/] fuse.ceph-fuse rw,relatime,user_id=0,group_id=0,allow_other
Replace /mnt/cephfs/projects/app with the directory that should receive the quota.
- Inspect the quota-setting client's capabilities.
$ ceph auth get client.app-quota [client.app-quota] key = ##### snipped ##### caps mds = "allow rwp fsname=cephfs path=/projects/app" caps mon = "allow r fsname=cephfs" caps osd = "allow rw tag cephfs data=cephfs"The p flag allows the client to set CephFS layout and quota attributes. Add it from an admin shell before setting quotas if the mds cap shows only rw.
Related: How to create a path-limited CephFS client key - Set the byte quota on the directory.
$ setfattr -n ceph.quota.max_bytes -v 104857600 /mnt/cephfs/projects/app
The value above sets a 100 MiB recursive limit for the directory tree. Use the byte value that matches the workload policy.
- Set a file-count quota when the directory also needs a file limit.
$ setfattr -n ceph.quota.max_files -v 10000 /mnt/cephfs/projects/app
Skip this step when only byte usage should be limited.
- Verify the byte quota attribute by name.
$ getfattr -n ceph.quota.max_bytes /mnt/cephfs/projects/app # file: mnt/cephfs/projects/app ceph.quota.max_bytes="104857600"
CephFS clients hide ceph.* virtual attributes from generic extended-attribute listings, so read each quota attribute by its exact name.
- Verify the file-count quota attribute by name.
$ getfattr -n ceph.quota.max_files /mnt/cephfs/projects/app # file: mnt/cephfs/projects/app ceph.quota.max_files="10000"
- Write a bounded file below the byte quota.
$ dd if=/dev/zero of=/mnt/cephfs/projects/app/quota-test-under.bin bs=1M count=10 status=none
Use a test size safely below the configured quota so the check does not disrupt application data.
- Confirm the under-limit test file exists.
$ ls -lh /mnt/cephfs/projects/app/quota-test-under.bin -rw-r--r-- 1 root root 10M Jun 29 10:12 /mnt/cephfs/projects/app/quota-test-under.bin
- Attempt a bounded write that exceeds the byte quota.
$ dd if=/dev/zero of=/mnt/cephfs/projects/app/quota-test-over.bin bs=1M count=120 dd: error writing '/mnt/cephfs/projects/app/quota-test-over.bin': Disk quota exceeded ##### snipped #####
CephFS quota enforcement is cooperative and can stop a writer shortly after the configured limit is crossed, so a partial over-limit file can remain until it is removed.
- Remove the quota test files.
$ rm -f /mnt/cephfs/projects/app/quota-test-under.bin /mnt/cephfs/projects/app/quota-test-over.bin
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.