mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-09 13:23:14 +00:00
scoutfs-utils: add transaction seq btree
Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -280,6 +280,15 @@ struct scoutfs_lock_client_btree_key {
|
||||
__be64 node_id;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* The server tracks transaction sequence numbers that clients have
|
||||
* open. This limits results that can be returned from the seq indices.
|
||||
*/
|
||||
struct scoutfs_trans_seq_btree_key {
|
||||
__be64 trans_seq;
|
||||
__be64 node_id;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* The max number of links defines the max number of entries that we can
|
||||
* index in o(log n) and the static list head storage size in the
|
||||
@@ -453,7 +462,7 @@ struct scoutfs_super_block {
|
||||
__le64 format_hash;
|
||||
__u8 uuid[SCOUTFS_UUID_BYTES];
|
||||
__le64 next_ino;
|
||||
__le64 next_seq;
|
||||
__le64 next_trans_seq;
|
||||
__le64 total_blocks;
|
||||
__le64 free_blocks;
|
||||
__le64 alloc_cursor;
|
||||
@@ -465,6 +474,7 @@ struct scoutfs_super_block {
|
||||
struct scoutfs_manifest manifest;
|
||||
struct scoutfs_quorum_config quorum_config;
|
||||
struct scoutfs_btree_root lock_clients;
|
||||
struct scoutfs_btree_root trans_seqs;
|
||||
} __packed;
|
||||
|
||||
#define SCOUTFS_ROOT_INO 1
|
||||
|
||||
@@ -234,7 +234,7 @@ static int write_new_fs(char *path, int fd, struct scoutfs_quorum_config *conf)
|
||||
super->format_hash = cpu_to_le64(SCOUTFS_FORMAT_HASH);
|
||||
uuid_generate(super->uuid);
|
||||
super->next_ino = cpu_to_le64(SCOUTFS_ROOT_INO + 1);
|
||||
super->next_seq = cpu_to_le64(1);
|
||||
super->next_trans_seq = cpu_to_le64(1);
|
||||
super->total_blocks = cpu_to_le64(total_blocks);
|
||||
super->next_seg_seq = cpu_to_le64(2);
|
||||
super->next_node_id = cpu_to_le64(1);
|
||||
|
||||
@@ -353,6 +353,17 @@ static int print_lock_clients_entry(void *key, unsigned key_len, void *val,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_trans_seqs_entry(void *key, unsigned key_len, void *val,
|
||||
unsigned val_len, void *arg)
|
||||
{
|
||||
struct scoutfs_trans_seq_btree_key *tsk = key;
|
||||
|
||||
printf(" trans_seq %llu node_ld %llu\n",
|
||||
be64_to_cpu(tsk->trans_seq), be64_to_cpu(tsk->node_id));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef int (*print_item_func)(void *key, unsigned key_len, void *val,
|
||||
unsigned val_len, void *arg);
|
||||
|
||||
@@ -527,16 +538,17 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno)
|
||||
le64_to_cpu(super->format_hash), uuid_str);
|
||||
|
||||
/* XXX these are all in a crazy order */
|
||||
printf(" next_ino %llu next_seq %llu next_seg_seq %llu\n"
|
||||
printf(" next_ino %llu next_trans_seq %llu next_seg_seq %llu\n"
|
||||
" next_node_id %llu next_compact_id %llu\n"
|
||||
" total_blocks %llu free_blocks %llu alloc_cursor %llu\n"
|
||||
" btree ring: first_blkno %llu nr_blocks %llu next_block %llu "
|
||||
"next_seq %llu\n"
|
||||
" lock_clients root: height %u blkno %llu seq %llu mig_len %u\n"
|
||||
" trans_seqs root: height %u blkno %llu seq %llu mig_len %u\n"
|
||||
" alloc btree root: height %u blkno %llu seq %llu mig_len %u\n"
|
||||
" manifest btree root: height %u blkno %llu seq %llu mig_len %u\n",
|
||||
le64_to_cpu(super->next_ino),
|
||||
le64_to_cpu(super->next_seq),
|
||||
le64_to_cpu(super->next_trans_seq),
|
||||
le64_to_cpu(super->next_seg_seq),
|
||||
le64_to_cpu(super->next_node_id),
|
||||
le64_to_cpu(super->next_compact_id),
|
||||
@@ -551,6 +563,10 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno)
|
||||
le64_to_cpu(super->lock_clients.ref.blkno),
|
||||
le64_to_cpu(super->lock_clients.ref.seq),
|
||||
le16_to_cpu(super->lock_clients.migration_key_len),
|
||||
super->trans_seqs.height,
|
||||
le64_to_cpu(super->trans_seqs.ref.blkno),
|
||||
le64_to_cpu(super->trans_seqs.ref.seq),
|
||||
le16_to_cpu(super->trans_seqs.migration_key_len),
|
||||
super->alloc_root.height,
|
||||
le64_to_cpu(super->alloc_root.ref.blkno),
|
||||
le64_to_cpu(super->alloc_root.ref.seq),
|
||||
@@ -615,6 +631,11 @@ static int print_volume(int fd)
|
||||
if (err && !ret)
|
||||
ret = err;
|
||||
|
||||
err = print_btree(fd, super, "trans_seqs", &super->trans_seqs,
|
||||
print_trans_seqs_entry, NULL);
|
||||
if (err && !ret)
|
||||
ret = err;
|
||||
|
||||
err = print_btree(fd, super, "alloc", &super->alloc_root,
|
||||
print_alloc_item, NULL);
|
||||
if (err && !ret)
|
||||
|
||||
Reference in New Issue
Block a user