preload
Jun 16

One of the most confusing property of ZFS is the complex space allocation of datasets if you are used to terms like thin provisioning, snapshot reserve and other common storage technobabbels. For me at least 🙂

I want to create 50G dataset which user sees as 50G of available space, it is all ways reserved for that user and snapshots cannot never consume space reserved for the user. User cant use space more than 50G even if there is space available on pool. I also want to have 50G space available for snapshots guaranteed.

So we have:
50G reserved for user
50G reserved for snapshots
Total: 100G

First we have to reserve that 100G from pool so no one else cannot use our precious space:


# zfs set reservation=100G tpool/nfs/user1

A ZFS reservation is an allocation of space from the pool that is guaranteed to be available to a dataset. As such, you cannot reserve 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 space in the pool. A dataset cannot consume space that has been reserved for another dataset.

Now we want to give exactly 50G for that user1 without freebies on space possibly available on pool:


# zfs set refquota=50G tpool/nfs/user1

refquota on a dataset limits the amount of space that the dataset can consume. This hard limit does not include space that is consumed by snapshots and clones.

Okay so now we have 100G of guaranteed space for our dataset and 50G limit to user1. Next thing is make sure that the user1 will have that 50G available no matter what:


# zfs set refreservation=50G tpool/nfs/user1

You can set a refreservation to guarantee space for a dataset that does not include space consumed by snapshots and clones. If refreservation is set, a snapshot is only allowed if enough free pool space exists outside of this reservation to accommodate the current number of referenced bytes in the dataset


# zfs get refquota,reservation,refreservation tpool/nfs/user1
NAME PROPERTY VALUE SOURCE
tpool/nfs/user1 refquota 50G local
tpool/nfs/user1 reservation 100G local
tpool/nfs/user1 refreservation 50G local

user1 is now one happy puppy.