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:
Ameer Hamza
2025-03-10 00:43:28 +05:00
committed by Tony Hutter
parent 9cb9a59e1c
commit 6f6c504700
7 changed files with 40 additions and 12 deletions
+1 -1
View File
@@ -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,
+25 -1
View File
@@ -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;