freebsd-dev/module/zcommon
Nasf-Fan 9c5167d19f Project Quota on ZFS
Project quota is a new ZFS system space/object usage accounting
and enforcement mechanism. Similar as user/group quota, project
quota is another dimension of system quota. It bases on the new
object attribute - project ID.

Project ID is a numerical value to indicate to which project an
object belongs. An object only can belong to one project though
you (the object owner or privileged user) can change the object
project ID via 'chattr -p' or 'zfs project [-s] -p' explicitly.
The object also can inherit the project ID from its parent when
created if the parent has the project inherit flag (that can be
set via 'chattr +P' or 'zfs project -s [-p]').

By accounting the spaces/objects belong to the same project, we
can know how many spaces/objects used by the project. And if we
set the upper limit then we can control the spaces/objects that
are consumed by such project. It is useful when multiple groups
and users cooperate for the same project, or a user/group needs
to participate in multiple projects.

Support the following commands and functionalities:

zfs set projectquota@project
zfs set projectobjquota@project

zfs get projectquota@project
zfs get projectobjquota@project
zfs get projectused@project
zfs get projectobjused@project

zfs projectspace

zfs allow projectquota
zfs allow projectobjquota
zfs allow projectused
zfs allow projectobjused

zfs unallow projectquota
zfs unallow projectobjquota
zfs unallow projectused
zfs unallow projectobjused

chattr +/-P
chattr -p project_id
lsattr -p

This patch also supports tree quota based on the project quota via
"zfs project" commands set as following:
zfs project [-d|-r] <file|directory ...>
zfs project -C [-k] [-r] <file|directory ...>
zfs project -c [-0] [-d|-r] [-p id] <file|directory ...>
zfs project [-p id] [-r] [-s] <file|directory ...>

For "df [-i] $DIR" command, if we set INHERIT (project ID) flag on
the $DIR, then the proejct [obj]quota and [obj]used values for the
$DIR's project ID will be shown as the total/free (avail) resource.
Keep the same behavior as EXT4/XFS does.

Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by  Ned Bass <bass6@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Fan Yong <fan.yong@intel.com>
TEST_ZIMPORT_POOLS="zol-0.6.1 zol-0.6.2 master"
Change-Id: Ib4f0544602e03fb61fd46a849d7ba51a6005693c
Closes #6290
2018-02-13 14:54:54 -08:00
..
Makefile.in OpenZFS 7431 - ZFS Channel Programs 2018-02-08 15:28:18 -08:00
zfeature_common.c Project Quota on ZFS 2018-02-13 14:54:54 -08:00
zfs_comutil.c Add libtpool (thread pools) 2017-08-09 15:31:08 -07:00
zfs_deleg.c Project Quota on ZFS 2018-02-13 14:54:54 -08:00
zfs_fletcher_aarch64_neon.c Add superscalar fletcher4 2016-11-04 10:53:03 -07:00
zfs_fletcher_avx512.c Suppress incorrect objtool warnings 2017-12-07 10:28:50 -08:00
zfs_fletcher_intel.c Fletcher4: save/reload implementation context 2016-10-05 16:41:46 +02:00
zfs_fletcher_sse.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
zfs_fletcher_superscalar4.c Add superscalar fletcher4 2016-11-04 10:53:03 -07:00
zfs_fletcher_superscalar.c Add superscalar fletcher4 2016-11-04 10:53:03 -07:00
zfs_fletcher.c Add libtpool (thread pools) 2017-08-09 15:31:08 -07:00
zfs_namecheck.c Undo c89 workarounds to match with upstream 2017-11-04 13:25:13 -07:00
zfs_prop.c Project Quota on ZFS 2018-02-13 14:54:54 -08:00
zfs_uio.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
zpool_prop.c Multi-modifier protection (MMP) 2017-07-13 13:54:00 -04:00
zprop_common.c Undo c89 workarounds to match with upstream 2017-11-04 13:25:13 -07:00