mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
9c5167d19f
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
154 lines
4.4 KiB
C
154 lines
4.4 KiB
C
/*
|
|
* CDDL HEADER START
|
|
*
|
|
* The contents of this file are subject to the terms of the
|
|
* Common Development and Distribution License (the "License").
|
|
* You may not use this file except in compliance with the License.
|
|
*
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
* See the License for the specific language governing permissions
|
|
* and limitations under the License.
|
|
*
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
*
|
|
* CDDL HEADER END
|
|
*/
|
|
/*
|
|
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
|
* Use is subject to license terms.
|
|
*/
|
|
|
|
#ifndef _SYS_ZFS_SA_H
|
|
#define _SYS_ZFS_SA_H
|
|
|
|
#ifdef _KERNEL
|
|
#include <sys/types32.h>
|
|
#include <sys/list.h>
|
|
#include <sys/dmu.h>
|
|
#include <sys/zfs_acl.h>
|
|
#include <sys/zfs_znode.h>
|
|
#include <sys/sa.h>
|
|
#include <sys/zil.h>
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* This is the list of known attributes
|
|
* to the ZPL. The values of the actual
|
|
* attributes are not defined by the order
|
|
* the enums. It is controlled by the attribute
|
|
* registration mechanism. Two different file system
|
|
* could have different numeric values for the same
|
|
* attributes. this list is only used for dereferencing
|
|
* into the table that will hold the actual numeric value.
|
|
*/
|
|
typedef enum zpl_attr {
|
|
ZPL_ATIME,
|
|
ZPL_MTIME,
|
|
ZPL_CTIME,
|
|
ZPL_CRTIME,
|
|
ZPL_GEN,
|
|
ZPL_MODE,
|
|
ZPL_SIZE,
|
|
ZPL_PARENT,
|
|
ZPL_LINKS,
|
|
ZPL_XATTR,
|
|
ZPL_RDEV,
|
|
ZPL_FLAGS,
|
|
ZPL_UID,
|
|
ZPL_GID,
|
|
ZPL_PAD,
|
|
ZPL_ZNODE_ACL,
|
|
ZPL_DACL_COUNT,
|
|
ZPL_SYMLINK,
|
|
ZPL_SCANSTAMP,
|
|
ZPL_DACL_ACES,
|
|
ZPL_DXATTR,
|
|
ZPL_PROJID,
|
|
ZPL_END
|
|
} zpl_attr_t;
|
|
|
|
#define ZFS_OLD_ZNODE_PHYS_SIZE 0x108
|
|
#define ZFS_SA_BASE_ATTR_SIZE (ZFS_OLD_ZNODE_PHYS_SIZE - \
|
|
sizeof (zfs_acl_phys_t))
|
|
|
|
#define SA_MODE_OFFSET 0
|
|
#define SA_SIZE_OFFSET 8
|
|
#define SA_GEN_OFFSET 16
|
|
#define SA_UID_OFFSET 24
|
|
#define SA_GID_OFFSET 32
|
|
#define SA_PARENT_OFFSET 40
|
|
#define SA_FLAGS_OFFSET 48
|
|
#define SA_PROJID_OFFSET 128
|
|
|
|
extern sa_attr_reg_t zfs_attr_table[ZPL_END + 1];
|
|
extern sa_attr_reg_t zfs_legacy_attr_table[ZPL_END + 1];
|
|
|
|
/*
|
|
* This is a deprecated data structure that only exists for
|
|
* dealing with file systems create prior to ZPL version 5.
|
|
*/
|
|
typedef struct znode_phys {
|
|
uint64_t zp_atime[2]; /* 0 - last file access time */
|
|
uint64_t zp_mtime[2]; /* 16 - last file modification time */
|
|
uint64_t zp_ctime[2]; /* 32 - last file change time */
|
|
uint64_t zp_crtime[2]; /* 48 - creation time */
|
|
uint64_t zp_gen; /* 64 - generation (txg of creation) */
|
|
uint64_t zp_mode; /* 72 - file mode bits */
|
|
uint64_t zp_size; /* 80 - size of file */
|
|
uint64_t zp_parent; /* 88 - directory parent (`..') */
|
|
uint64_t zp_links; /* 96 - number of links to file */
|
|
uint64_t zp_xattr; /* 104 - DMU object for xattrs */
|
|
uint64_t zp_rdev; /* 112 - dev_t for VBLK & VCHR files */
|
|
uint64_t zp_flags; /* 120 - persistent flags */
|
|
uint64_t zp_uid; /* 128 - file owner */
|
|
uint64_t zp_gid; /* 136 - owning group */
|
|
uint64_t zp_zap; /* 144 - extra attributes */
|
|
uint64_t zp_pad[3]; /* 152 - future */
|
|
zfs_acl_phys_t zp_acl; /* 176 - 263 ACL */
|
|
/*
|
|
* Data may pad out any remaining bytes in the znode buffer, eg:
|
|
*
|
|
* |<---------------------- dnode_phys (512) ------------------------>|
|
|
* |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->|
|
|
* |<---- znode (264) ---->|<---- data (56) ---->|
|
|
*
|
|
* At present, we use this space for the following:
|
|
* - symbolic links
|
|
* - 32-byte anti-virus scanstamp (regular files only)
|
|
*/
|
|
} znode_phys_t;
|
|
|
|
#ifdef _KERNEL
|
|
|
|
#define DXATTR_MAX_ENTRY_SIZE (32768)
|
|
#define DXATTR_MAX_SA_SIZE (SPA_OLD_MAXBLOCKSIZE >> 1)
|
|
|
|
int zfs_sa_readlink(struct znode *, uio_t *);
|
|
void zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *);
|
|
void zfs_sa_get_scanstamp(struct znode *, xvattr_t *);
|
|
void zfs_sa_set_scanstamp(struct znode *, xvattr_t *, dmu_tx_t *);
|
|
int zfs_sa_get_xattr(struct znode *);
|
|
int zfs_sa_set_xattr(struct znode *);
|
|
void zfs_sa_upgrade(struct sa_handle *, dmu_tx_t *);
|
|
void zfs_sa_upgrade_txholds(dmu_tx_t *, struct znode *);
|
|
void zfs_sa_init(void);
|
|
void zfs_sa_fini(void);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _SYS_ZFS_SA_H */
|