From 1de321e6260f5b83eb943b6ce2166a3879f42df4 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Tue, 4 Oct 2016 11:46:10 -0700 Subject: Add support for user/group dnode accounting & quota This patch tracks dnode usage for each user/group in the DMU_USER/GROUPUSED_OBJECT ZAPs. ZAP entries dedicated to dnode accounting have the key prefixed with "obj-" followed by the UID/GID in string format (as done for the block accounting). A new SPA feature has been added for dnode accounting as well as a new ZPL version. The SPA feature must be enabled in the pool before upgrading the zfs filesystem. During the zfs version upgrade, a "quotacheck" will be executed by marking all dnode as dirty. ZoL-bug-id: https://github.com/zfsonlinux/zfs/issues/3500 Signed-off-by: Jinshan Xiong Signed-off-by: Johann Lombardi --- include/sys/dmu_objset.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/sys/dmu_objset.h') diff --git a/include/sys/dmu_objset.h b/include/sys/dmu_objset.h index 1674897c2..68fb5cffb 100644 --- a/include/sys/dmu_objset.h +++ b/include/sys/dmu_objset.h @@ -56,6 +56,7 @@ struct dmu_tx; (arc_buf_size(buf) > OBJSET_OLD_PHYS_SIZE) #define OBJSET_FLAG_USERACCOUNTING_COMPLETE (1ULL<<0) +#define OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE (1ULL<<1) typedef struct objset_phys { dnode_phys_t os_meta_dnode; @@ -68,6 +69,8 @@ typedef struct objset_phys { dnode_phys_t os_groupused_dnode; } objset_phys_t; +typedef int (*dmu_objset_upgrade_cb_t)(objset_t *); + struct objset { /* Immutable: */ struct dsl_dataset *os_dsl_dataset; @@ -125,6 +128,13 @@ struct objset { kmutex_t os_user_ptr_lock; void *os_user_ptr; sa_os_t *os_sa; + + /* kernel thread to upgrade this dataset */ + kmutex_t os_upgrade_lock; + taskqid_t os_upgrade_id; + dmu_objset_upgrade_cb_t os_upgrade_cb; + boolean_t os_upgrade_exit; + int os_upgrade_status; }; #define DMU_META_OBJSET 0 @@ -173,6 +183,17 @@ void dmu_objset_userquota_get_ids(dnode_t *dn, boolean_t before, dmu_tx_t *tx); boolean_t dmu_objset_userused_enabled(objset_t *os); int dmu_objset_userspace_upgrade(objset_t *os); boolean_t dmu_objset_userspace_present(objset_t *os); +boolean_t dmu_objset_userobjused_enabled(objset_t *os); +void dmu_objset_userobjspace_upgrade(objset_t *os); +boolean_t dmu_objset_userobjspace_present(objset_t *os); + +static inline boolean_t dmu_objset_userobjspace_upgradable(objset_t *os) +{ + return (dmu_objset_type(os) == DMU_OST_ZFS && + dmu_objset_userobjused_enabled(os) && + !dmu_objset_userobjspace_present(os)); +} + int dmu_fsname(const char *snapname, char *buf); void dmu_objset_evict_done(objset_t *os); -- cgit v1.2.3