From 4c8aa12ab136b8295feb3f19a4b541725caa1ba7 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 21 May 2026 13:13:56 +0200 Subject: [PATCH] Comment about extends shrinking directly in the tree --- cmdline/elem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmdline/elem.c b/cmdline/elem.c index 5385f096..36854e51 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -1371,6 +1371,12 @@ void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos) /* if it's at the start of the extent, shrink the extent */ if (parity_pos == extent->parity_pos) { + /* + * Note that modifying parity_pos and file_pos in-place is safe + * because extents never overlap. Shrinking the start of the extent + * keeps the relative sorted order of all nodes completely unchanged, + * preserving the tree invariants without delete/insert overhead. + */ ++extent->parity_pos; ++extent->file_pos; --extent->count;