Allow rewrite skip cloned and snapshotted blocks

Rewrite of cloned and snapshotted blocks can allocate additional
space, that may be undesired.  In some cases it may have sense
to still rewrite snapshotted blocks, expecting the snapshots to
rotate with time, freeing space.  In other cases rewrite of cloned
blocks may be acceptable, despite persistent space usage increase.
For this reason add them as separate flags to `zfs rewrite`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com>
Closes #18179
This commit is contained in:
Alexander Motin
2026-02-09 13:17:56 -05:00
committed by GitHub
parent 15fbf534c6
commit 2646bd5585
13 changed files with 273 additions and 32 deletions
+22
View File
@@ -3943,4 +3943,26 @@ function pop_coredump_pattern
esac
}
#
# get_same_blocks dataset1 path/to/file1 dataset2 path/to/file2 [key]
#
# Returns a space-separated list of the indexes (starting at 0) of the L0
# blocks that are shared between both files (by first DVA and checksum).
#
function get_same_blocks # dataset1 file1 dataset2 file2 [key]
{
typeset KEY=$5
if [ ${#KEY} -gt 0 ]; then
KEY="--key=$KEY"
fi
typeset zdbout1=$(mktemp)
typeset zdbout2=$(mktemp)
zdb $KEY -vvvvv $1 -O $2 | \
awk '/ L0 / { print l++ " " $3 " " $7 }' > $zdbout1
zdb $KEY -vvvvv $3 -O $4 | \
awk '/ L0 / { print l++ " " $3 " " $7 }' > $zdbout2
echo $(sort -n $zdbout1 $zdbout2 | uniq -d | cut -f1 -d' ')
rm -f $zdbout1 $zdbout2
}
. ${STF_SUITE}/include/kstat.shlib