From 2478d124dd839b5a7a1d8fe68a197c49299d284e Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 15 Apr 2020 11:04:57 -0700 Subject: [PATCH] scoutfs: use random radix block ref seqs The seq portion of radix block references is intended to differentiate versions of a given block location over time. The current method of incrementing the existing value as the block is dirtied is risky. It means that every lineage of a block has the same sequence number progression. Different trees referencing the same block over time could get confused. It's more robust to have large random numbers. The collision window is then evenly distributed over the 64bit space rather than being bunched up all in in the initial seq values. Signed-off-by: Zach Brown --- kmod/src/radix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kmod/src/radix.c b/kmod/src/radix.c index c390850a..429b867c 100644 --- a/kmod/src/radix.c +++ b/kmod/src/radix.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "super.h" #include "format.h" @@ -1102,7 +1103,7 @@ static void dirty_all_path_blocks(struct super_block *sb, rdx = bl->data; rdx->hdr.blkno = cpu_to_le64(bl->blkno); - le64_add_cpu(&rdx->hdr.seq, 1); + prandom_bytes(&rdx->hdr.seq, sizeof(rdx->hdr.seq)); ref = path_ref(path, level); ref->blkno = rdx->hdr.blkno;