Page MenuHomeFreeBSD

MFZol: Fix performance of "zfs recv" with many deletions

Authored by asomers on Oct 4 2019, 3:20 PM.



MFZol: Fix performance of "zfs recv" with many deletions

This patch fixes 2 issues with the DMU free throttle implemented
in dmu_free_long_range(). The first issue is that get_next_chunk()
was calculating the number of L1 blocks the free would dirty
incorrectly. In some cases involving extremely large files, this
code would greatly overestimate the number of effected L1 blocks,
causing excessive calls to txg_wait_open(). This patch corrects
the calculation.

The second issue is that the free throttle uses the total number
of free'd blocks in all (open, quiescing, and syncing) txgs to
determine whether to throttle. This causes large frees (such as
those created by the first issue) to cause 4 txg syncs before
any further frees were allowed to proceed. This patch ensures
that the accounting is done entirely in a per-txg fashion, so
that frees from a given txg don't affect those that immediately
follow it.

Reviewed-by: Brian Behlendorf <>
Reviewed-by: Matthew Ahrens <>
Signed-off-by: Tom Caputi <>

Freeing throttle should account for holes

Deletion throttle currently does not account for holes in a file.
This means that it can activate when it shouldn't.
To fix it we switch the throttle to be based on the number of
L1 blocks we will have to dirty when freeing

Reviewed-by: Tom Caputi <>
Reviewed-by: Matt Ahrens <>
Reviewed-by: Brian Behlendorf <>
Signed-off-by: Alek Pinchuk <>

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

asomers created this revision.Oct 4 2019, 3:20 PM
asomers updated this revision to Diff 62906.Oct 4 2019, 4:55 PM

Update tunable description, too.

This revision is now accepted and ready to land.Oct 4 2019, 5:00 PM

This patch improves performance by fixing bugs in the freeing throttle. It's a combination of two patches that have been in ZoL since May (ZoL v0.8.0).

The way the freeing throttle is implemented now is susceptible to the overestimation of the data to be free which means artificially slow freeing of data.

One place where this slow freeing is a noticeable problem is a zfs recv when there are lots of FREE records present in the stream as it can make the recv speed very, very slow.

allanjude added a subscriber: allanjude.
allanjude accepted this revision.Oct 11 2019, 2:54 PM

Reviewed By: allanjude

Thanks Allan!

This revision was automatically updated to reflect the committed changes.