Skip to content

ZFS quota strategy on multi-tenant hosts: quota vs refquota vs reservation, and the gotchas

How quota, refquota, reservation, and refreservation interact on multi-tenant ZFS hosts — what each actually enforces, the snapshot accounting gotchas, and the policy operators trip over.

You run a multi-tenant ZFS host — say twenty customer accounts, each a child dataset under tank/customers/. One customer takes a heavy snapshot week and suddenly their dataset exceeds the 100 GB you “set as their limit.” Another customer’s writes start failing with disk quota exceeded even though their dataset is only at 60 GB. Both situations are real, both come from the same misunderstanding, and both have a clean fix once you know which of quota, refquota, reservation, and refreservation you actually wanted.

What’s happening

ZFS has four space-management properties at the dataset level. They look similar in the man page and they are routinely confused in practice. The differences come down to one question: does the property count snapshot space, and does it carve out space or just cap it?

  • quota — hard cap on the total space the dataset and all its descendants and snapshots can occupy. If a tenant has a 100 GB quota and produces 90 GB of files plus 20 GB of snapshot churn, they hit the cap at 110 GB total and writes fail. Snapshots count.
  • refquota — hard cap on the referenced space only — i.e. the space the dataset’s live filesystem consumes, not counting snapshots and clones. A 100 GB refquota means “you may have at most 100 GB of live files,” and snapshots can take the dataset’s total to 200 GB without tripping the cap.
  • reservation — guaranteed space carved out of the pool for the dataset and its descendants. A 50 GB reservation means “no other dataset can take this 50 GB from the pool, even if I’m not using it.” Counts toward pool usage immediately.
  • refreservation — guaranteed space for the dataset’s referenced data only. Like reservation, but doesn’t reserve room for snapshots. Useful when you want to guarantee an application has its working set available but you don’t want snapshot growth to take pool space away from other tenants.

In a multi-tenant setup, the policy that operators reach for is almost always refquota + refreservation, not quota + reservation. The reason: with quota, a tenant who deletes a 50 GB file but keeps a recent snapshot doesn’t get the space back — quota still counts the snapshot. The tenant calls support, the snapshot is invisible to them through their normal filesystem view, and they conclude that “ZFS quotas are broken.” With refquota, deleting the file frees the live space and the cap resets immediately; the snapshot still exists and still costs pool space, but it costs the provider’s pool, not the tenant’s quota.

The trap with refquota is the reverse: a tenant whose application produces 10 GB of churn per day and has a refquota of 100 GB plus a generous snapshot retention policy can quietly cost the pool 500 GB in snapshots without ever appearing to exceed their quota. That’s a policy decision: do you charge the tenant for snapshot space, in which case quota is right; or do you treat snapshots as an infrastructure expense (DR posture, restore drill capability), in which case refquota is right and you cap snapshot retention at the host level.

A second class of mistake: assuming quota and reservation reserve overlapping space. They don’t. quota is a ceiling; reservation is a floor. A dataset can have quota=100G, reservation=20G — meaning “you’re guaranteed 20 GB and capped at 100 GB.” Setting reservation larger than quota makes no sense and ZFS will refuse it.

A third class: parent-level quotas always win over child-level quotas. If tank/customers has refquota=1T and you split it across twenty children with refquota=100G each, the children sum to 2 TB on paper — but the parent will start refusing writes at 1 TB. This is usually what you want for a host-level safety net, but you have to be intentional about it.

How to verify

The properties on a candidate dataset, in one shot:

zfs get -p quota,refquota,reservation,refreservation,used,usedbydataset,usedbysnapshots,referenced,available tank/customers/acme
# NAME                     PROPERTY         VALUE          SOURCE
# tank/customers/acme      quota            -              default
# tank/customers/acme      refquota         107374182400   local
# tank/customers/acme      reservation      -              default
# tank/customers/acme      refreservation   21474836480    local
# tank/customers/acme      used             54321098432    -
# tank/customers/acme      usedbydataset    32212254720    -
# tank/customers/acme      usedbysnapshots  22108843712    -
# tank/customers/acme      referenced       32212254720    -
# tank/customers/acme      available        75162927616    -

Read this row by row:

  • refquota=100G → tenant cap on live files
  • refreservation=20G → 20 GB guaranteed
  • referenced=30G → live filesystem is using 30 GB of those 100 GB
  • usedbysnapshots=20.6G → snapshots are costing the pool another 20.6 GB
  • used=50.6G → total dataset footprint
  • available=70G → tenant can still write 70 GB before hitting refquota

When a tenant complains “quota exceeded but I only have 60 GB of files,” the column that explains it is almost always usedbysnapshots. With refquota policy, this should never produce a wrong-feeling block; with quota policy, it routinely does.

Audit the whole tenant tier for tenants near their cap:

zfs list -o name,refquota,referenced,available -t filesystem -r tank/customers \
  | awk 'NR>1 && $3+0 > 0.8 * $2+0'

(Filter >0.8 is a stand-in for whatever the operational threshold is — “tenants above 80% of cap” — and gives ops a list of accounts to inspect proactively.)

Pool-level sanity check: do the reservations sum to less than the pool’s capacity?

zpool list tank
# NAME    SIZE   ALLOC   FREE   ...
zfs list -o name,refreservation -t filesystem -r tank/customers \
  | awk 'NR>1 {sum += $2} END {printf "Sum of refreservations: %.2f GB\n", sum/1024/1024/1024}'

If the sum of refreservation values exceeds the pool capacity, you’ve over-committed — new dataset creation will fail at the moment the pool genuinely runs out.

The fix

A practical multi-tenant policy that we install on customer hosts:

Default per-tenant settings:

zfs create -o compression=lz4 \
           -o atime=off \
           -o xattr=sa \
           -o snapdir=visible \
           -o recordsize=128K \
           -o refquota=100G \
           -o refreservation=20G \
           tank/customers/<tenant>

snapdir=visible exposes the .zfs/snapshot/ directory in the tenant’s filesystem — so they can self-restore individual files from a snapshot without a support ticket. (Disable it if your tenant model doesn’t include self-service restores.)

Snapshot policy lives at the parent, not the child. A nightly snapshot of every tenant dataset, with retention enforced at the parent level by your snapshot tool:

zfs set com.sun:auto-snapshot=true tank/customers
# Configure the snapshot tool (sanoid, zrepl, custom systemd timer) to:
# - take :hourly retention=6
# - take :daily   retention=14
# - take :weekly  retention=4
# - take :monthly retention=6
# on every child of tank/customers

This separates the tenant-visible cap (refquota) from the provider-controlled snapshot policy. Tenants never accidentally exceed quota because of snapshots they didn’t choose to take.

Apply a parent-level safety net so the sum of children’s caps can’t exceed the pool:

zfs set refquota=80% tank/customers   # 80% of pool, as a backstop

ZFS accepts a percentage shorthand for quota and refquota since 2.1. This caps the entire customer tier at 80% of the pool, leaving 20% headroom for the OS, logs, and emergency growth.

Three gotchas to write into the runbook:

  1. reservation charges the pool immediately. If you zfs set reservation=100G on twenty tenants, you’ve consumed 2 TB of pool space before anyone writes a byte. Use refreservation instead — it reserves only the live-data slice.

  2. refquota does not stop runaway snapshots. A tenant with a 100 GB refquota and a per-customer snapshot policy can still cost the pool hundreds of GB in snapshot history. Either (a) keep snapshot policy at the provider level, not per-tenant, or (b) move to quota and accept that tenants will sometimes hit cap because of their own snapshot history.

  3. Resizing refquota down on a full dataset doesn’t free space. ZFS will accept zfs set refquota=50G on a dataset that currently references 80 GB — but writes will fail immediately. If you’re cutting a tenant’s plan, give them notice or stage the resize so they have time to clean up.

Set both refquota and refreservation, drive snapshot retention from the provider, alert when any tenant crosses 80% of refquota, and the multi-tenant pool stops being a source of support tickets. Audit the policy once a quarter — a pool that’s been quietly drifting toward over-commit since the last review is one busy week away from refusing writes.

Stack Harbor designs multi-tenant ZFS layouts (and the alerting that keeps them sane) as part of Cloud compute, under Managed Cloud Ops. If your multi-tenant host has had three “quota exceeded but I’m not full” tickets this month, book a storage policy review.