A ZFS reservation is an allocation of disk space from the pool that is guaranteed to be available to a dataset. As such, you cannot reserve disk space for a dataset if that space is not currently available in the pool. The total amount of all outstanding, unconsumed reservations cannot exceed the amount of unused disk space in the pool. ZFS reservations can be set and displayed by using the zfs set and zfs get commands. For example:
# zfs set reservation=5G tank/home/bill # zfs get reservation tank/home/bill NAME PROPERTY VALUE SOURCE tank/home/bill reservation 5G local
Reservations can affect the output of the zfs list command. For example:
# zfs list -r tank/home NAME USED AVAIL REFER MOUNTPOINT tank/home 5.00G 61.9G 37K /tank/home tank/home/bill 31K 66.9G 31K /tank/home/bill tank/home/jeff 337K 10.0G 306K /tank/home/jeff tank/home/lori 547K 61.9G 547K /tank/home/lori tank/home/mark 31K 61.9G 31K /tank/home/mark
Note that tank/home is using 5 GB of disk space, although the total amount of space referred to by tank/home and its descendents is much less than 5 GB. The used space reflects the space reserved for tank/home/bill. Reservations are considered in the used disk space calculation of the parent file system and do count against its quota, reservation, or both.
# zfs set quota=5G pool/filesystem # zfs set reservation=10G pool/filesystem/user1 cannot set reservation for 'pool/filesystem/user1': size is greater than available space
A dataset can use more disk space than its reservation, as long as unreserved space is available in the pool, and the dataset's current usage is below its quota. A dataset cannot consume disk space that has been reserved for another dataset.
Reservations are not cumulative. That is, a second invocation of zfs set to set a reservation does not add its reservation to the existing reservation. Rather, the second reservation replaces the first reservation. For example:
# zfs set reservation=10G tank/home/bill # zfs set reservation=5G tank/home/bill # zfs get reservation tank/home/bill NAME PROPERTY VALUE SOURCE tank/home/bill reservation 5G local
You can set a refreservation reservation to guarantee disk space for a dataset that does not include disk space consumed by snapshots and clones. This reservation is accounted for in the parent dataset's space used calculation, and counts against the parent dataset's quotas and reservations. For example:
# zfs set refreservation=10g profs/prof1 # zfs list NAME USED AVAIL REFER MOUNTPOINT profs 10.0G 23.2G 19K /profs profs/prof1 10G 33.2G 18K /profs/prof1
You can also set a reservation on the same dataset to guarantee dataset space and snapshot space. For example:
# zfs set reservation=20g profs/prof1 # zfs list NAME USED AVAIL REFER MOUNTPOINT profs 20.0G 13.2G 19K /profs profs/prof1 10G 33.2G 18K /profs/prof1
Regular reservations are accounted for in the parent's used space calculation.
In the preceding example, the smaller of the two quotas (10 GB as compared to 20 GB) is displayed in the zfs list output. To view the value of both quotas, use the zfs get command. For example:
# zfs get reservation,refreserv profs/prof1 NAME PROPERTY VALUE SOURCE profs/prof1 reservation 20G local profs/prof1 refreservation 10G local
If refreservation is set, a snapshot is only allowed if sufficient unreserved pool space exists outside of this reservation to accommodate the current number of referenced bytes in the dataset.