Implement physical rewrites

Based on previous commit this implements `zfs rewrite -P` flag,
making ZFS to keep blocks logical birth times while rewriting
files.  It should exclude the rewritten blocks from incremental
sends, snapshot diffs, etc.  Snapshots space usage same time will
reflect the additional space usage from newly allocated blocks.

Since this begins to use new "rewrite" flag in the block pointers,
this commit introduces a new read-compatible per-dataset feature
physical_rewrite.  It must be enabled for the command to not fail,
it is activated on first use and deactivated on deletion of the
last affected dataset.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by:  Alexander Motin <alexander.motin@TrueNAS.com>
Closes #17565
This commit is contained in:
Alexander Motin
2025-07-23 15:51:00 -04:00
committed by Brian Behlendorf
parent 4ae8bf406b
commit 60f714e6e2
19 changed files with 270 additions and 18 deletions
+17
View File
@@ -853,6 +853,23 @@ when the
command is used on a top-level vdev, and will never return to being
.Sy enabled .
.
.feature com.truenas physical_rewrite yes extensible_dataset
This feature enables physical block rewriting that preserves logical birth
times, avoiding unnecessary inclusion of rewritten blocks in incremental
.Nm zfs Cm send
streams.
When enabled, the
.Nm zfs Cm rewrite Fl P
command can be used.
.Pp
This feature becomes
.Sy active
the first time
.Nm zfs Cm rewrite Fl P
is used on any dataset, and will return to being
.Sy enabled
once all datasets that have ever used physical rewrite are destroyed.
.
.feature org.zfsonlinux project_quota yes extensible_dataset
This feature allows administrators to account the spaces and objects usage
information against the project identifier