Bug 274613 - zfs list USEDSNAP, USEDDS no longer seem to work on RELENG_14
Summary: zfs list USEDSNAP, USEDDS no longer seem to work on RELENG_14
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2023-10-20 16:02 UTC by mike
Modified: 2023-10-25 16:57 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mike 2023-10-20 16:02:10 UTC
On RELENG_13, if I do something simple like

 zfs list  -o name,avail,used,usedsnap,usedds
NAME                                                       AVAIL USED  USEDSNAP  USEDDS
cageroot                                                    674G 202G        0B     96K
cageroot/ROOT                                               674G 16.5G        0B     96K
cageroot/ROOT/default                                       674G 16.5G        0B   16.5G
cageroot/tmp                                                674G 19.9G        0B   19.9G
cageroot/usr                                                674G 115G        0B     96K
cageroot/usr/home                                           674G 107G        0B    107G
cageroot/usr/ports                                          674G 5.59G        0B   5.59G
cageroot/usr/src                                            674G 3.22G        0B   3.22G
cageroot/var                                                674G 49.9G        0B     96K
cageroot/var/audit                                          674G 208K        0B    208K
cageroot/var/crash 674G    96K        0B     96K
cageroot/var/log                                            674G 49.9G        0B   49.9G
cageroot/var/mail                                           674G 1.15M        0B   1.15M
cageroot/var/tmp                                            674G 384K        0B    384K

where there are no snapshots, I get expected values for usedsnap.

If I create a snap and then create or change values, I get expected results

# zfs snapshot -r cageroot@test

dd if=/dev/urandom of=/tmp/junk count=1
1+0 records in
1+0 records out
512 bytes transferred in 0.000064 secs (7970360 bytes/sec)

# zfs list -o name,avail,used,usedsnap,usedds
NAME                                                       AVAIL USED  USEDSNAP  USEDDS
cageroot/tmp                                                674G 19.9G      232K   19.9G
cageroot/var/log                                            674G 49.9G      516K   49.9G


This does not seem to work on RELENG_14

# zfs list -p -o name,avail,used,usedsnap
NAME                     AVAIL         USED  USEDSNAP
zroot               9724133376  15760457728         -
zroot/ROOT          9724133376   4928872448         -
zroot/ROOT/default  9724133376   4928438272         -
zroot/home          9724133376       847872         -
zroot/tmp           9724133376    288845824         -
zroot/usr           9724133376  10526818304         -
zroot/usr/obj       9724133376       446464         -
zroot/usr/ports     9724133376  10525491200         -
zroot/usr/src       9724133376       446464         -
zroot/var           9724133376      6475776         -
zroot/var/audit     9724133376       438272         -
zroot/var/log       9724133376      4620288         -
zroot/var/mail      9724133376       520192         -
zroot/var/tmp       9724133376       462848         -

# dd if=/dev/urandom count=20 > /tmp/test1junk
# zfs snapshot -r zroot@test4
# dd if=/dev/urandom count=20 > /tmp/test1junk2
# zfs list -p -o name,avail,used,usedsnap
NAME                     AVAIL         USED  USEDSNAP
zroot               9723752448  15760838656         -
zroot/ROOT          9723752448   4929069056         -
zroot/ROOT/default  9723752448   4928634880         -
zroot/home          9723752448       847872         -
zroot/tmp           9723752448    288919552         -
zroot/usr           9723752448  10526818304         -
zroot/usr/obj       9723752448       446464         -
zroot/usr/ports     9723752448  10525491200         -
zroot/usr/src       9723752448       446464         -
zroot/var           9723752448      6475776         -
zroot/var/audit     9723752448       438272         -
zroot/var/log       9723752448      4620288         -
zroot/var/mail      9723752448       520192         -
zroot/var/tmp       9723752448       462848         -

used by snap shows zero values

# zfs get all zroot/tmp
NAME       PROPERTY              VALUE                     SOURCE
zroot/tmp  type                  filesystem                -
zroot/tmp  creation              Wed Dec 31 19:00 1969     -
zroot/tmp  used                  276M                      -
zroot/tmp  available             9.06G                     -
zroot/tmp  referenced            620K                      -
zroot/tmp  compressratio         1.00x                     -
zroot/tmp  mounted               yes                       -
zroot/tmp  quota                 none                      default
zroot/tmp  reservation           none                      default
zroot/tmp  recordsize            128K                      default
zroot/tmp  mountpoint            /tmp                      local
zroot/tmp  sharenfs              off                       default
zroot/tmp  checksum              on                        default
zroot/tmp  compression           off inherited from zroot
zroot/tmp  atime                 on                        default
zroot/tmp  devices               on                        default
zroot/tmp  exec                  on                        local
zroot/tmp  setuid                off                       local
zroot/tmp  readonly              off                       default
zroot/tmp  jailed                off                       default
zroot/tmp  snapdir               hidden                    default
zroot/tmp  aclmode               discard                   default
zroot/tmp  aclinherit            restricted                default
zroot/tmp  createtxg             3                         -
zroot/tmp  canmount              on                        default
zroot/tmp  xattr                 on                        default
zroot/tmp  copies                1                         default
zroot/tmp  version               5                         -
zroot/tmp  utf8only              off                       -
zroot/tmp  normalization         none                      -
zroot/tmp  casesensitivity       sensitive                 -
zroot/tmp  vscan                 off                       default
zroot/tmp  nbmand                off                       default
zroot/tmp  sharesmb              off                       default
zroot/tmp  refquota              none                      default
zroot/tmp  refreservation        none                      default
zroot/tmp  guid                  5738408658065305312       -
zroot/tmp  primarycache          all                       default
zroot/tmp  secondarycache        all                       default
zroot/tmp  logbias               latency                   default
zroot/tmp  objsetid              40                        -
zroot/tmp  dedup                 off                       default
zroot/tmp  mlslabel              none                      default
zroot/tmp  sync                  standard                  default
zroot/tmp  dnodesize             legacy                    default
zroot/tmp  refcompressratio      1.00x                     -
zroot/tmp  written               60K                       -
zroot/tmp  logicalused           275M                      -
zroot/tmp  logicalreferenced     522K                      -
zroot/tmp  volmode               default                   default
zroot/tmp  filesystem_limit      none                      default
zroot/tmp  snapshot_limit        none                      default
zroot/tmp  filesystem_count      none                      default
zroot/tmp  snapshot_count        none                      default
zroot/tmp  snapdev               hidden                    default
zroot/tmp  acltype               nfsv4                     default
zroot/tmp  context               none                      default
zroot/tmp  fscontext             none                      default
zroot/tmp  defcontext            none                      default
zroot/tmp  rootcontext           none                      default
zroot/tmp  relatime              on                        default
zroot/tmp  redundant_metadata    all                       default
zroot/tmp  overlay               on                        default
zroot/tmp  encryption            off                       default
zroot/tmp  keylocation           none                      default
zroot/tmp  keyformat             none                      default
zroot/tmp  pbkdf2iters           0                         default
zroot/tmp  special_small_blocks  0                         default
zroot/tmp  snapshots_changed     Fri Oct 20 11:28:16 2023  -

 # zfs list -t snapshot zroot/tmp
NAME              USED  AVAIL  REFER  MOUNTPOINT
zroot/tmp@test     56K      -   584K  -
zroot/tmp@test2    56K      -   596K  -
zroot/tmp@test3   275M      -   275M  -
zroot/tmp@test4    48K      -   608K  -

There is no usedsnap and usedds any more on RELENG_14 ? Also, should not the -p option be honored and display 0 and not a dash ?
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2023-10-20 16:17:33 UTC
Do you see the same problem if you create the pool yourself on 14, i.e., without using the pool created by makefs as part of VM image creation?
Comment 3 mike 2023-10-20 16:54:23 UTC
(In reply to Mark Johnston from comment #2)

WOW, good catch!  
from history 
   361  12:48   truncate -s 100M /tmp/a
   362  12:49   mdconfig -f /tmp/a
   363  12:49   gpart create -s gpt /dev/md0
   364  12:49   gpart add -t freebsd-zfs /dev/md0
   365  12:49   zpool create testpool /dev/md0p1
   370  12:50   dd if=/dev/urandom of=/testpool/junk count=1
   371  12:50   zfs snapshot -r testpool@test1
   372  12:51   rm /testpool/junk


# zfs list -p -o name,avail,used,usedsnap,usedds testpool
NAME         AVAIL    USED  USEDSNAP  USEDDS
testpool  41779200  163840     14848   24576

zfs get all testpool
NAME      PROPERTY              VALUE                     SOURCE
testpool  type                  filesystem                -
testpool  creation              Fri Oct 20 12:49 2023     -
testpool  used                  160K                      -
testpool  available             39.8M                     -
testpool  referenced            24K                       -
testpool  compressratio         1.00x                     -
testpool  mounted               yes                       -
testpool  quota                 none                      default
testpool  reservation           none                      default
testpool  recordsize            128K                      default
testpool  mountpoint            /testpool                 default
testpool  sharenfs              off                       default
testpool  checksum              on                        default
testpool  compression           on                        default
testpool  atime                 on                        default
testpool  devices               on                        default
testpool  exec                  on                        default
testpool  setuid                on                        default
testpool  readonly              off                       default
testpool  jailed                off                       default
testpool  snapdir               hidden                    default
testpool  aclmode               discard                   default
testpool  aclinherit            restricted                default
testpool  createtxg             1                         -
testpool  canmount              on                        default
testpool  xattr                 on                        default
testpool  copies                1                         default
testpool  version               5                         -
testpool  utf8only              off                       -
testpool  normalization         none                      -
testpool  casesensitivity       sensitive                 -
testpool  vscan                 off                       default
testpool  nbmand                off                       default
testpool  sharesmb              off                       default
testpool  refquota              none                      default
testpool  refreservation        none                      default
testpool  guid                  12863139616279728335      -
testpool  primarycache          all                       default
testpool  secondarycache        all                       default
testpool  usedbysnapshots       14.5K                     -
testpool  usedbydataset         24K                       -
testpool  usedbychildren        122K                      -
testpool  usedbyrefreservation  0B                        -
testpool  logbias               latency                   default
testpool  objsetid              54                        -
testpool  dedup                 off                       default
testpool  mlslabel              none                      default
testpool  sync                  standard                  default
testpool  dnodesize             legacy                    default
testpool  refcompressratio      1.00x                     -
testpool  written               14K                       -
testpool  logicalused           60K                       -
testpool  logicalreferenced     12K                       -
testpool  volmode               default                   default
testpool  filesystem_limit      none                      default
testpool  snapshot_limit        none                      default
testpool  filesystem_count      none                      default
testpool  snapshot_count        none                      default
testpool  snapdev               hidden                    default
testpool  acltype               nfsv4                     default
testpool  context               none                      default
testpool  fscontext             none                      default
testpool  defcontext            none                      default
testpool  rootcontext           none                      default
testpool  relatime              on                        default
testpool  redundant_metadata    all                       default
testpool  overlay               on                        default
testpool  encryption            off                       default
testpool  keylocation           none                      default
testpool  keyformat             none                      default
testpool  pbkdf2iters           0                         default
testpool  special_small_blocks  0                         default
testpool  snapshots_changed     Fri Oct 20 12:50:56 2023  -


# zpool status
  pool: testpool
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          md0p1     ONLINE       0     0     0

errors: No known data errors

  pool: zroot
 state: ONLINE
  scan: scrub repaired 0B in 00:00:18 with 0 errors on Fri Oct 20 10:05:47 2023
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          vtbd0p4   ONLINE       0     0     0

errors: No known data errors
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-10-23 15:18:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=96092bf9108c97b45d18fd26fbe91f2d1c7799b8

commit 96092bf9108c97b45d18fd26fbe91f2d1c7799b8
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-23 15:08:04 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-23 15:12:14 +0000

    makefs/zfs: Fill out dd_used_breakdown fields in DSL directories

    This is required for the "used", "usedds" and "usedchild" dataset
    properties to be displayed.

    PR:             274613
    Reported by:    Mike Tancsa <mike@sentex.net>
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation

 usr.sbin/makefs/zfs/dsl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-10-23 15:18:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9f9d18d61e74e2486d9dc0c0187eb72b02c66743

commit 9f9d18d61e74e2486d9dc0c0187eb72b02c66743
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-23 15:11:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-23 15:15:00 +0000

    makefs/zfs: Add a regression test which checks the 'used*' properties

    PR:             274613
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation

 usr.sbin/makefs/tests/makefs_zfs_tests.sh | 73 ++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 2 deletions(-)
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2023-10-23 15:21:23 UTC
So this will be fixed in images created by a patched makefs, but existing images will still have the problem.  I believe that the problem only occurs in datasets created by makefs, not in datasets created after the image is booted, even if they belong to the same pool.  So you could conceivably work around the problem in an affected image by creating new datasets and copying everything over.
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-10-25 15:03:38 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=eb5cbd793e31f9d656999033be54dac1a1107294

commit eb5cbd793e31f9d656999033be54dac1a1107294
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-23 15:08:04 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-25 14:27:27 +0000

    makefs/zfs: Fill out dd_used_breakdown fields in DSL directories

    This is required for the "used", "usedds" and "usedchild" dataset
    properties to be displayed.

    PR:             274613
    Reported by:    Mike Tancsa <mike@sentex.net>
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation

 usr.sbin/makefs/zfs/dsl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-10-25 15:03:40 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cfcb53e1a132932bf3d22e87e47e38e64b118c4a

commit cfcb53e1a132932bf3d22e87e47e38e64b118c4a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-23 15:11:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-25 14:27:27 +0000

    makefs/zfs: Add a regression test which checks the 'used*' properties

    PR:             274613
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation

 usr.sbin/makefs/tests/makefs_zfs_tests.sh | 73 ++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 2 deletions(-)
Comment 9 Mark Johnston freebsd_committer freebsd_triage 2023-10-25 15:11:41 UTC
I believe this is fixed now:

root@freebsd:~ # zfs list -p -o name,used,usedds,usedchild,usedsnap                                                                                                                                                                                                                                                           
NAME                      USED      USEDDS   USEDCHILD  USEDSNAP                                                                                                                                                                                                                                                              
zroot               3889631232      434176  3889197056         0                                                                                                                                                                                                                                                              
zroot/ROOT          3880652800      434176  3880218624         0                                                                                                                                                                                                                                                              
zroot/ROOT/default  3880218624  3880218624           0         0                                                                                                                                                                                                                                                              
zroot/home              430080      430080           0         0                                                                                                                                                                                                                                                              
zroot/tmp               430080      430080           0         0                                                                                                                                                                                                                                                              
zroot/usr              1724416      434176     1290240         0                                                                                                                                                                                                                                                              
zroot/usr/obj           430080      430080           0         0                                                                                                                                                                                                                                                              
zroot/usr/ports         430080      430080           0         0                                                                                                                                                                                                                                                              
zroot/usr/src           430080      430080           0         0                                                                                                                                                                                                                                                              
zroot/var              2273280      434176     1839104         0                                                                                                                                                                                                                                                              
zroot/var/audit         438272      438272           0         0                                                                                                                                                                                                                                                              
zroot/var/log           536576      536576           0         0                                                                                                                                                                                                                                                              
zroot/var/mail          430080      430080           0         0                                                                                                                                                                                                                                                              
zroot/var/tmp           434176      434176           0         0
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-10-25 16:57:04 UTC
A commit in branch releng/14.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=60bc03c9c36aa38204e862269f13bf79ded72119

commit 60bc03c9c36aa38204e862269f13bf79ded72119
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-23 15:08:04 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-25 16:55:52 +0000

    makefs/zfs: Fill out dd_used_breakdown fields in DSL directories

    This is required for the "used", "usedds" and "usedchild" dataset
    properties to be displayed.

    Approved by:    re (gjb)
    PR:             274613
    Reported by:    Mike Tancsa <mike@sentex.net>
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit eb5cbd793e31f9d656999033be54dac1a1107294)

 usr.sbin/makefs/zfs/dsl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)