mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-19 14:34:16 +00:00
Add write_nr to quorum blocks
Add a write_nr field to the quorum block header which is incremented with every write. Each event also gets a write_nr field that is set to the incremented value from the header. This gives us a history of the order of event updates that isn't sensitive to misconfigured time. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -733,7 +733,9 @@ enum {
|
||||
|
||||
struct scoutfs_quorum_block {
|
||||
struct scoutfs_block_header hdr;
|
||||
__le64 write_nr;
|
||||
struct scoutfs_quorum_block_event {
|
||||
__le64 write_nr;
|
||||
__le64 rid;
|
||||
__le64 term;
|
||||
struct scoutfs_timespec ts;
|
||||
|
||||
@@ -448,8 +448,10 @@ static void set_quorum_block_event(struct super_block *sb, struct scoutfs_quorum
|
||||
return;
|
||||
|
||||
getnstimeofday64(&ts);
|
||||
le64_add_cpu(&blk->write_nr, 1);
|
||||
|
||||
ev = &blk->events[event];
|
||||
ev->write_nr = blk->write_nr;
|
||||
ev->rid = cpu_to_le64(sbi->rid);
|
||||
ev->term = cpu_to_le64(term);
|
||||
ev->ts.sec = cpu_to_le64(ts.tv_sec);
|
||||
|
||||
+4
-2
@@ -898,13 +898,15 @@ static int print_quorum_blocks(int fd, struct scoutfs_super_block *super)
|
||||
printf("quorum blkno %llu (slot %llu)\n",
|
||||
blkno, blkno - SCOUTFS_QUORUM_BLKNO);
|
||||
print_block_header(&blk->hdr, SCOUTFS_BLOCK_SM_SIZE);
|
||||
printf(" write_nr %llu\n", le64_to_cpu(blk->write_nr));
|
||||
|
||||
for (e = 0; e < array_size(event_names); e++) {
|
||||
ev = &blk->events[e];
|
||||
|
||||
printf(" %12s: rid %016llx term %llu ts %llu.%08u\n",
|
||||
printf(" %12s: rid %016llx term %llu write_nr %llu ts %llu.%08u\n",
|
||||
event_names[e], le64_to_cpu(ev->rid), le64_to_cpu(ev->term),
|
||||
le64_to_cpu(ev->ts.sec), le32_to_cpu(ev->ts.nsec));
|
||||
le64_to_cpu(ev->write_nr), le64_to_cpu(ev->ts.sec),
|
||||
le32_to_cpu(ev->ts.nsec));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user