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 <zab@versity.com>
This commit is contained in:
Zach Brown
2020-04-16 10:33:28 -07:00
committed by Zach Brown
parent 968e719a9a
commit 2478d124dd
+2 -1
View File
@@ -14,6 +14,7 @@
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/crc32c.h>
#include <linux/random.h>
#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;