Cephfs quota support


Enable quota support for Cephfs. We want to implement quota support on individual directory hierarchies, it does not distinguish users and groups, like XFS's project quota. Since currently, Ceph does not have an united uid/gid mechnism, implement the traditional user and group based quota support is hard to use.


  • Li Wang (UbuntuKylin)

Interested Parties

  • Yan, Zheng (Intel)
  • Sage
  • Greg
  • Anip Patel (Arizona State University(student))

Current Status

With original design

Detailed Description

- add an optional directory property for the quota limit
- add quota_info_t struct to inode_t
- protect quota_info_t with policylock
- add to CInode::{encode,decode}_lock_state
- allow setting the quota
see Server::handle_set_vxattr()
fsetxattr(dirfd, "ceph.quota.max_bytes", "123000000")
fsetxattr(dirfd, "ceph.quota.max_files", "123000")
- tell client qtree_ino when WR cap is issued
add a CInode::get_containing_qtree() helper
- client: track qtree_ino for any open file for write
- client: is expected to keep quota parent open in its cache and limit
its writes
- it can getattr the quota parent, watch for rbytes >= quota_max
- maybe, mds pushes quotatree rbytes updates to client when there are
significant change

If we do want to track actually used file space, the algorithm could be,
For each OSD object write operation, OSD return the offset to the actual object size (before writing) in the reply, the offset may be positive or minus, client calculates all the offsets to get a total offset, tell the total offset to MDS, MDS maintain the total used space for a file by add the total offset reported by client.
The major problem for this algorithm is that if for some reason, some client does not tell the MDS the offset, MDS may get that the actual used file size is less than zero. For example, a file is originall 2MB,
one client write it to 8MB, then the other client truncate it to 2MB. The first client should tell MDS offset be +6MB, the second client should tell MDS offset be -6MB. If the former get lost, MDS will think the file now be 2MB-6MB=-4MB. In that case, something like quota check will need, that is expensive.

Work items

Coding tasks

  1. Task 1
  2. Task 2
  3. Task 3

Build / release tasks

  1. Task 1
  2. Task 2
  3. Task 3

Documentation tasks

  1. Task 1
  2. Task 2
  3. Task 3

Deprecation tasks

  1. Task 1
  2. Task 2
  3. Task 3