Skip to content

Commit

Permalink
Fix 'zfs get {user|group}objused@' functionality
Browse files Browse the repository at this point in the history
Fix a regression accidentally introduced in 1b81ab4 that prevents
'zfs get {user|group}objused@' from correctly reporting the requested
value.

Update "userspace_003_pos.ksh" and "groupspace_003_pos.ksh" to verify
this functionality.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Giuseppe Di Natale <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes openzfs#6908

Requires-spl: refs/pull/669/head
  • Loading branch information
loli10K authored and behlendorf committed Nov 29, 2017
1 parent 3e2755d commit 01be745
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion module/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
return (0);

if (type == ZFS_PROP_USEROBJUSED || type == ZFS_PROP_GROUPOBJUSED) {
strlcpy(buf, DMU_OBJACCT_PREFIX, DMU_OBJACCT_PREFIX_LEN);
strlcpy(buf, DMU_OBJACCT_PREFIX, DMU_OBJACCT_PREFIX_LEN + 1);
offset = DMU_OBJACCT_PREFIX_LEN;
}

Expand Down
14 changes: 10 additions & 4 deletions tests/zfs-tests/tests/functional/userquota/groupspace_003_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/include/math.shlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

#
Expand All @@ -56,10 +57,15 @@ function cleanup
function group_object_count
{
typeset fs=$1
typeset user=$2
typeset cnt=$(zfs groupspace -oname,objused $fs | grep $user |
awk '{print $2}')
echo $cnt
typeset group=$2
typeset -i groupspacecnt=$(zfs groupspace -oname,objused $fs |
awk /$group/'{print $2}')
typeset -i zfsgetcnt=$(zfs get -H -ovalue groupobjused@$group $fs)

# 'zfs groupspace' and 'zfs get groupobjused@' should be equal
verify_eq "$groupspacecnt" "$zfsgetcnt" "groupobjused@$group"

echo $groupspacecnt
}

log_onexit cleanup
Expand Down
10 changes: 8 additions & 2 deletions tests/zfs-tests/tests/functional/userquota/userspace_003_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/include/math.shlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

#
Expand Down Expand Up @@ -58,9 +59,14 @@ function user_object_count
{
typeset fs=$1
typeset user=$2
typeset cnt=$(zfs userspace -oname,objused $fs |
typeset -i userspacecnt=$(zfs userspace -oname,objused $fs |
awk /$user/'{print $2}')
echo $cnt
typeset -i zfsgetcnt=$(zfs get -H -ovalue userobjused@$user $fs)

# 'zfs userspace' and 'zfs get userobjused@' should be equal
verify_eq "$userspacecnt" "$zfsgetcnt" "userobjused@$user"

echo $userspacecnt
}

log_onexit cleanup
Expand Down

0 comments on commit 01be745

Please sign in to comment.