]> granicus.if.org Git - zfs/commit
Project Quota on ZFS
authorNasf-Fan <fan.yong@intel.com>
Tue, 13 Feb 2018 22:54:54 +0000 (06:54 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 13 Feb 2018 22:54:54 +0000 (14:54 -0800)
commit9c5167d19fe02e44ba09c6d0282363c19781b19d
tree32fd87dc2f943f05f964450c0f54ea3d0d601466
parentc03f04708caecf9a4a4ce2134aaa6a8cabe499c9
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
82 files changed:
cmd/zdb/zdb.c
cmd/zfs/Makefile.am
cmd/zfs/zfs_main.c
cmd/zfs/zfs_project.c [new file with mode: 0644]
cmd/zfs/zfs_projectutil.h [new file with mode: 0644]
cmd/zhack/zhack.c
configure.ac
include/sys/Makefile.am
include/sys/dmu.h
include/sys/dmu_objset.h
include/sys/dnode.h
include/sys/dsl_deleg.h
include/sys/fs/zfs.h
include/sys/sa.h
include/sys/xvattr.h
include/sys/zfs_acl.h
include/sys/zfs_project.h [new file with mode: 0644]
include/sys/zfs_sa.h
include/sys/zfs_vfsops.h
include/sys/zfs_znode.h
include/zfeature_common.h
include/zfs_deleg.h
lib/libzfs/libzfs_dataset.c
man/man5/zpool-features.5
man/man8/zfs.8
module/zcommon/zfeature_common.c
module/zcommon/zfs_deleg.c
module/zcommon/zfs_prop.c
module/zfs/dbuf.c
module/zfs/dmu.c
module/zfs/dmu_objset.c
module/zfs/dmu_traverse.c
module/zfs/dnode.c
module/zfs/dsl_pool.c
module/zfs/dsl_scan.c
module/zfs/sa.c
module/zfs/spa.c
module/zfs/zfs_acl.c
module/zfs/zfs_dir.c
module/zfs/zfs_ioctl.c
module/zfs/zfs_log.c
module/zfs/zfs_replay.c
module/zfs/zfs_sa.c
module/zfs/zfs_vfsops.c
module/zfs/zfs_vnops.c
module/zfs/zfs_znode.c
module/zfs/zpl_file.c
tests/runfiles/linux.run
tests/zfs-tests/include/commands.cfg
tests/zfs-tests/tests/functional/Makefile.am
tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg
tests/zfs-tests/tests/functional/privilege/setup.ksh
tests/zfs-tests/tests/functional/projectquota/Makefile.am [new file with mode: 0644]
tests/zfs-tests/tests/functional/projectquota/cleanup.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectid_001_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectid_002_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectid_003_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota.cfg [new file with mode: 0644]
tests/zfs-tests/tests/functional/projectquota/projectquota_001_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_002_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_004_neg.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_005_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_006_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_007_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_008_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_009_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib [new file with mode: 0644]
tests/zfs-tests/tests/functional/projectquota/projectspace_001_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectspace_002_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectspace_003_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projecttree_001_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projecttree_002_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/projecttree_003_neg.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/projectquota/setup.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/upgrade/Makefile.am
tests/zfs-tests/tests/functional/upgrade/cleanup.ksh
tests/zfs-tests/tests/functional/upgrade/setup.ksh
tests/zfs-tests/tests/functional/upgrade/upgrade_common.kshlib [new file with mode: 0644]
tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/upgrade/upgrade_userobj_001_pos.ksh