ZVOL reservation

From: Andrea Venturoli <ml_at_netfence.it>
Date: Sat, 20 Nov 2021 18:41:35 UTC
Hello.

Seems after years I still have doubts on how to account for space on ZFS :)
(This is on 12.2, so no OpenZFS yet)


 From "man zfs":

_ refreservation = The minimum amount of space guaranteed to a dataset, 
not including its descendents. When the amount of space used is below 
this value, the dataset is treated as if it were taking up the amount of 
space specified by refreservation.

_ usedbyrefreservation = The amount of space used by a refreservation 
set on this dataset, which would be freed if the refreservation was removed.



Now:
> # zfs get all zroot/vm/sql/disk0 | grep G
> zroot/vm/sql/disk0  used                   495G                   -
> zroot/vm/sql/disk0  available              216G                   -
> zroot/vm/sql/disk0  referenced             58.3G                  -
> zroot/vm/sql/disk0  volsize                192G                   local
> zroot/vm/sql/disk0  refreservation         198G                   local
> zroot/vm/sql/disk0  usedbysnapshots        239G                   -
> zroot/vm/sql/disk0  usedbydataset          58.3G                  -
> zroot/vm/sql/disk0  usedbyrefreservation   198G                   -
> zroot/vm/sql/disk0  logicalused            341G                   -
> zroot/vm/sql/disk0  logicalreferenced      68.9G                  -

I would expect:
used=max(usedbydataset,usedbyrefreservation)+usedbysnapshots=
     =198+239=437G
Instead:
used=usedbydataset+usedbyrefreservation+usedbysnapshots=
     =58.3+198+239=495G

IIUC, then, those 58.3G are counted twice, once as real data and once 
more as reservation.

Is it so???



Given
> # zpool get all
> NAME   PROPERTY                       VALUE                          SOURCE
> zroot  size                           896G                           -
> zroot  capacity                       72%                            -
> zroot  altroot                        -                              default
> zroot  health                         ONLINE                         -
> zroot  guid                           13582901126454535548           default
> zroot  version                        -                              default
> zroot  bootfs                         zroot/ROOT/default             local
> zroot  delegation                     on                             default
> zroot  autoreplace                    off                            default
> zroot  cachefile                      -                              default
> zroot  failmode                       wait                           default
> zroot  listsnapshots                  off                            default
> zroot  autoexpand                     off                            default
> zroot  dedupditto                     0                              default
> zroot  dedupratio                     1.00x                          -
> zroot  free                           246G                           -
> zroot  allocated                      650G                           -
> zroot  readonly                       off                            -
> zroot  comment                        -                              default
> zroot  expandsize                     -                              -
> zroot  freeing                        0                              default
> zroot  fragmentation                  53%                            -
> zroot  leaked                         0                              default
> zroot  bootsize                       -                              default
> zroot  checkpoint                     -                              -
> zroot  multihost                      off                            default
> zroot  load_guid                      11887969528966574378           default
> zroot  feature@async_destroy          enabled                        local
> zroot  feature@empty_bpobj            active                         local
> zroot  feature@lz4_compress           active                         local
> zroot  feature@multi_vdev_crash_dump  enabled                        local
> zroot  feature@spacemap_histogram     active                         local
> zroot  feature@enabled_txg            active                         local
> zroot  feature@hole_birth             active                         local
> zroot  feature@extensible_dataset     enabled                        local
> zroot  feature@embedded_data          active                         local
> zroot  feature@bookmarks              enabled                        local
> zroot  feature@filesystem_limits      enabled                        local
> zroot  feature@large_blocks           enabled                        local
> zroot  feature@large_dnode            disabled                       local
> zroot  feature@sha512                 enabled                        local
> zroot  feature@skein                  enabled                        local
> zroot  feature@device_removal         disabled                       local
> zroot  feature@obsolete_counts        disabled                       local
> zroot  feature@zpool_checkpoint       disabled                       local
> zroot  feature@spacemap_v2            disabled                       local
> zroot  feature@allocation_classes     disabled                       local

would a zpool upgrade help here?





Also, while we are at it:
> # zfs get all zroot | grep G
> zroot  used                   850G                   -
> zroot  available              18.3G                  -
> zroot  usedbychildren         850G                   -
> zroot  logicalused            856G                   -
> # zpool get all zroot | grep G
> zroot  size                           896G                           -
> zroot  free                           246G                           -
> zroot  allocated                      650G                           -

Isn't it strange that zfs and zpool count free/available space in such a 
different way?

I guess zpool does not take refreservation (in my case 200G in total) 
into account.
Still 18.3+200=218, not 246G.
What does account for the difference?



  bye & Thanks
	av.