mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-08-05 06:27:40 +03:00
Show default quotas in zfs userspace tools
Update zfs userspace, groupspace, and projectspace to display the default quotas when no per-ID specific quota is configured. This ensures tool outputs align with enforced limits. 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:
parent
9cb9a59e1c
commit
6f6c504700
@ -2986,7 +2986,8 @@ us_type2str(unsigned field_type)
|
||||
}
|
||||
|
||||
static int
|
||||
userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
|
||||
userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space,
|
||||
uint64_t default_quota)
|
||||
{
|
||||
us_cbdata_t *cb = (us_cbdata_t *)arg;
|
||||
zfs_userquota_prop_t prop = cb->cb_prop;
|
||||
@ -3142,7 +3143,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
|
||||
prop == ZFS_PROP_PROJECTUSED) {
|
||||
propname = "used";
|
||||
if (!nvlist_exists(props, "quota"))
|
||||
(void) nvlist_add_uint64(props, "quota", 0);
|
||||
(void) nvlist_add_uint64(props, "quota", default_quota);
|
||||
} else if (prop == ZFS_PROP_USERQUOTA || prop == ZFS_PROP_GROUPQUOTA ||
|
||||
prop == ZFS_PROP_PROJECTQUOTA) {
|
||||
propname = "quota";
|
||||
@ -3151,8 +3152,10 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
|
||||
} else if (prop == ZFS_PROP_USEROBJUSED ||
|
||||
prop == ZFS_PROP_GROUPOBJUSED || prop == ZFS_PROP_PROJECTOBJUSED) {
|
||||
propname = "objused";
|
||||
if (!nvlist_exists(props, "objquota"))
|
||||
(void) nvlist_add_uint64(props, "objquota", 0);
|
||||
if (!nvlist_exists(props, "objquota")) {
|
||||
(void) nvlist_add_uint64(props, "objquota",
|
||||
default_quota);
|
||||
}
|
||||
} else if (prop == ZFS_PROP_USEROBJQUOTA ||
|
||||
prop == ZFS_PROP_GROUPOBJQUOTA ||
|
||||
prop == ZFS_PROP_PROJECTOBJQUOTA) {
|
||||
|
@ -853,7 +853,7 @@ _LIBZFS_H uint64_t zvol_volsize_to_reservation(zpool_handle_t *, uint64_t,
|
||||
nvlist_t *);
|
||||
|
||||
typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain,
|
||||
uid_t rid, uint64_t space);
|
||||
uid_t rid, uint64_t space, uint64_t default_quota);
|
||||
|
||||
_LIBZFS_H int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t,
|
||||
zfs_userspace_cb_t, void *);
|
||||
|
@ -35,7 +35,7 @@ extern int zpl_get_file_info(dmu_object_type_t,
|
||||
extern int zfs_userspace_one(struct zfsvfs *, zfs_userquota_prop_t,
|
||||
const char *, uint64_t, uint64_t *);
|
||||
extern int zfs_userspace_many(struct zfsvfs *, zfs_userquota_prop_t,
|
||||
uint64_t *, void *, uint64_t *);
|
||||
uint64_t *, void *, uint64_t *, uint64_t *);
|
||||
extern int zfs_set_userquota(struct zfsvfs *, zfs_userquota_prop_t,
|
||||
const char *, uint64_t, uint64_t);
|
||||
|
||||
|
@ -3879,7 +3879,7 @@
|
||||
</data-member>
|
||||
</class-decl>
|
||||
<typedef-decl name='renameflags_t' type-id='7aee5792' id='067170c2'/>
|
||||
<typedef-decl name='zfs_userspace_cb_t' type-id='ca64ff60' id='16c5f410'/>
|
||||
<typedef-decl name='zfs_userspace_cb_t' type-id='bbaa4f9c' id='16c5f410'/>
|
||||
<enum-decl name='lzc_dataset_type' id='bc9887f1'>
|
||||
<underlying-type type-id='9cac1fee'/>
|
||||
<enumerator name='LZC_DATSET_TYPE_ZFS' value='2'/>
|
||||
@ -4074,7 +4074,7 @@
|
||||
<qualified-type-def type-id='566b3f52' restrict='yes' id='c878edd6'/>
|
||||
<pointer-type-def type-id='566b3f52' size-in-bits='64' id='82d4e9e8'/>
|
||||
<qualified-type-def type-id='82d4e9e8' restrict='yes' id='aa19c230'/>
|
||||
<pointer-type-def type-id='7e291ce6' size-in-bits='64' id='ca64ff60'/>
|
||||
<pointer-type-def type-id='02362c02' size-in-bits='64' id='bbaa4f9c'/>
|
||||
<pointer-type-def type-id='9da381c4' size-in-bits='64' id='cb785ebf'/>
|
||||
<pointer-type-def type-id='1b055409' size-in-bits='64' id='9d424d31'/>
|
||||
<pointer-type-def type-id='8e0af06e' size-in-bits='64' id='053457bd'/>
|
||||
@ -5019,11 +5019,12 @@
|
||||
<parameter type-id='80f4b756'/>
|
||||
<return type-id='c19b74c3'/>
|
||||
</function-decl>
|
||||
<function-type size-in-bits='64' id='7e291ce6'>
|
||||
<function-type size-in-bits='64' id='02362c02'>
|
||||
<parameter type-id='eaa32e2f'/>
|
||||
<parameter type-id='80f4b756'/>
|
||||
<parameter type-id='354978ed'/>
|
||||
<parameter type-id='9c313c2d'/>
|
||||
<parameter type-id='9c313c2d'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-type>
|
||||
</abi-instr>
|
||||
|
@ -4966,7 +4966,7 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
|
||||
|
||||
while (zc.zc_nvlist_dst_size > 0) {
|
||||
if ((ret = func(arg, zua->zu_domain, zua->zu_rid,
|
||||
zua->zu_space)) != 0)
|
||||
zua->zu_space, zc.zc_guid)) != 0)
|
||||
return (ret);
|
||||
zua++;
|
||||
zc.zc_nvlist_dst_size -= sizeof (zfs_useracct_t);
|
||||
|
@ -6350,7 +6350,7 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
|
||||
void *buf = vmem_alloc(bufsize, KM_SLEEP);
|
||||
|
||||
error = zfs_userspace_many(zfsvfs, zc->zc_objset_type, &zc->zc_cookie,
|
||||
buf, &zc->zc_nvlist_dst_size);
|
||||
buf, &zc->zc_nvlist_dst_size, &zc->zc_guid);
|
||||
|
||||
if (error == 0) {
|
||||
error = xcopyout(buf,
|
||||
|
@ -160,9 +160,31 @@ zfs_userquota_prop_to_obj(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type)
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
zfs_usedquota_prop_to_default(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case ZFS_PROP_USERUSED:
|
||||
return (zfsvfs->z_defaultuserquota);
|
||||
case ZFS_PROP_USEROBJUSED:
|
||||
return (zfsvfs->z_defaultuserobjquota);
|
||||
case ZFS_PROP_GROUPUSED:
|
||||
return (zfsvfs->z_defaultgroupquota);
|
||||
case ZFS_PROP_GROUPOBJUSED:
|
||||
return (zfsvfs->z_defaultgroupobjquota);
|
||||
case ZFS_PROP_PROJECTUSED:
|
||||
return (zfsvfs->z_defaultprojectquota);
|
||||
case ZFS_PROP_PROJECTOBJUSED:
|
||||
return (zfsvfs->z_defaultprojectobjquota);
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
|
||||
uint64_t *cookiep, void *vbuf, uint64_t *bufsizep)
|
||||
uint64_t *cookiep, void *vbuf, uint64_t *bufsizep,
|
||||
uint64_t *default_quota)
|
||||
{
|
||||
int error;
|
||||
zap_cursor_t zc;
|
||||
@ -187,6 +209,8 @@ zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
|
||||
!dmu_objset_userobjspace_present(zfsvfs->z_os))
|
||||
return (SET_ERROR(ENOTSUP));
|
||||
|
||||
*default_quota = zfs_usedquota_prop_to_default(zfsvfs, type);
|
||||
|
||||
obj = zfs_userquota_prop_to_obj(zfsvfs, type);
|
||||
if (obj == ZFS_NO_OBJECT) {
|
||||
*bufsizep = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user