mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add default user/group/project quota properties
This adds default userquota, groupquota, and projectquota properties to MASTER_NODE_OBJ to make them accessible during zfsvfs_init() (regular DSL properties require dsl_config_lock, which cannot be safely acquired in this context). The zfs_fill_zplprops_impl() logic is updated to read these default properties directly from MASTER_NODE_OBJ. Signed-off-by: Ameer Hamza <ahamza@ixsystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
@@ -861,6 +861,36 @@ zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os)
|
||||
zfsvfs->z_xattr_sa = B_TRUE;
|
||||
}
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTUSERQUOTA,
|
||||
&zfsvfs->z_defaultuserquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTGROUPQUOTA,
|
||||
&zfsvfs->z_defaultgroupquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTPROJECTQUOTA,
|
||||
&zfsvfs->z_defaultprojectquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTUSEROBJQUOTA,
|
||||
&zfsvfs->z_defaultuserobjquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTGROUPOBJQUOTA,
|
||||
&zfsvfs->z_defaultgroupobjquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTPROJECTOBJQUOTA,
|
||||
&zfsvfs->z_defaultprojectobjquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END,
|
||||
&zfsvfs->z_attr_table);
|
||||
if (error != 0)
|
||||
@@ -2241,6 +2271,62 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
zfs_set_default_quota(zfsvfs_t *zfsvfs, zfs_prop_t prop, uint64_t quota)
|
||||
{
|
||||
int error;
|
||||
objset_t *os = zfsvfs->z_os;
|
||||
const char *propstr = zfs_prop_to_name(prop);
|
||||
dmu_tx_t *tx;
|
||||
|
||||
tx = dmu_tx_create(os);
|
||||
dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, B_FALSE, propstr);
|
||||
error = dmu_tx_assign(tx, DMU_TX_WAIT);
|
||||
if (error) {
|
||||
dmu_tx_abort(tx);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if (quota == 0) {
|
||||
error = zap_remove(os, MASTER_NODE_OBJ, propstr, tx);
|
||||
if (error == ENOENT)
|
||||
error = 0;
|
||||
} else {
|
||||
error = zap_update(os, MASTER_NODE_OBJ, propstr, 8, 1,
|
||||
"a, tx);
|
||||
}
|
||||
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
switch (prop) {
|
||||
case ZFS_PROP_DEFAULTUSERQUOTA:
|
||||
zfsvfs->z_defaultuserquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTGROUPQUOTA:
|
||||
zfsvfs->z_defaultgroupquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTPROJECTQUOTA:
|
||||
zfsvfs->z_defaultprojectquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTUSEROBJQUOTA:
|
||||
zfsvfs->z_defaultuserobjquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTGROUPOBJQUOTA:
|
||||
zfsvfs->z_defaultgroupobjquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTPROJECTOBJQUOTA:
|
||||
zfsvfs->z_defaultprojectobjquota = quota;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
dmu_tx_commit(tx);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the corresponding vfs's unmounted flag is set.
|
||||
* Otherwise return false.
|
||||
|
||||
@@ -697,6 +697,36 @@ zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os)
|
||||
zfsvfs->z_xattr_sa = B_TRUE;
|
||||
}
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTUSERQUOTA,
|
||||
&zfsvfs->z_defaultuserquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTGROUPQUOTA,
|
||||
&zfsvfs->z_defaultgroupquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTPROJECTQUOTA,
|
||||
&zfsvfs->z_defaultprojectquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTUSEROBJQUOTA,
|
||||
&zfsvfs->z_defaultuserobjquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTGROUPOBJQUOTA,
|
||||
&zfsvfs->z_defaultgroupobjquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zfs_get_zplprop(os, ZFS_PROP_DEFAULTPROJECTOBJQUOTA,
|
||||
&zfsvfs->z_defaultprojectobjquota);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_ROOT_OBJ, 8, 1,
|
||||
&zfsvfs->z_root);
|
||||
if (error != 0)
|
||||
@@ -2005,6 +2035,62 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
zfs_set_default_quota(zfsvfs_t *zfsvfs, zfs_prop_t prop, uint64_t quota)
|
||||
{
|
||||
int error;
|
||||
objset_t *os = zfsvfs->z_os;
|
||||
const char *propstr = zfs_prop_to_name(prop);
|
||||
dmu_tx_t *tx;
|
||||
|
||||
tx = dmu_tx_create(os);
|
||||
dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, B_FALSE, propstr);
|
||||
error = dmu_tx_assign(tx, DMU_TX_WAIT);
|
||||
if (error) {
|
||||
dmu_tx_abort(tx);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if (quota == 0) {
|
||||
error = zap_remove(os, MASTER_NODE_OBJ, propstr, tx);
|
||||
if (error == ENOENT)
|
||||
error = 0;
|
||||
} else {
|
||||
error = zap_update(os, MASTER_NODE_OBJ, propstr, 8, 1,
|
||||
"a, tx);
|
||||
}
|
||||
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
switch (prop) {
|
||||
case ZFS_PROP_DEFAULTUSERQUOTA:
|
||||
zfsvfs->z_defaultuserquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTGROUPQUOTA:
|
||||
zfsvfs->z_defaultgroupquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTPROJECTQUOTA:
|
||||
zfsvfs->z_defaultprojectquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTUSEROBJQUOTA:
|
||||
zfsvfs->z_defaultuserobjquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTGROUPOBJQUOTA:
|
||||
zfsvfs->z_defaultgroupobjquota = quota;
|
||||
break;
|
||||
case ZFS_PROP_DEFAULTPROJECTOBJQUOTA:
|
||||
zfsvfs->z_defaultprojectobjquota = quota;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
dmu_tx_commit(tx);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the corresponding vfs's unmounted flag is set.
|
||||
* Otherwise return false.
|
||||
@@ -2073,4 +2159,5 @@ EXPORT_SYMBOL(zfs_remount);
|
||||
EXPORT_SYMBOL(zfs_statvfs);
|
||||
EXPORT_SYMBOL(zfs_vget);
|
||||
EXPORT_SYMBOL(zfs_prune);
|
||||
EXPORT_SYMBOL(zfs_set_default_quota);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user