diff --git a/utils/src/format.h b/utils/src/format.h index d46b2195..be2931dc 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -272,6 +272,14 @@ struct scoutfs_extent_btree_key { __be64 minor; } __packed; +/* + * The lock server keeps a persistent record of connected clients so that + * server failover knows who to wait for before resuming operations. + */ +struct scoutfs_lock_client_btree_key { + __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 @@ -456,6 +464,7 @@ struct scoutfs_super_block { struct scoutfs_btree_root alloc_root; struct scoutfs_manifest manifest; struct scoutfs_quorum_config quorum_config; + struct scoutfs_btree_root lock_clients; } __packed; #define SCOUTFS_ROOT_INO 1 @@ -642,6 +651,7 @@ enum { SCOUTFS_NET_CMD_STATFS, SCOUTFS_NET_CMD_COMPACT, SCOUTFS_NET_CMD_LOCK, + SCOUTFS_NET_CMD_LOCK_RECOVER, SCOUTFS_NET_CMD_FAREWELL, SCOUTFS_NET_CMD_UNKNOWN, }; @@ -768,6 +778,15 @@ struct scoutfs_net_lock { __u8 new_mode; } __packed; +struct scoutfs_net_lock_recover { + __le16 nr; + struct scoutfs_net_lock locks[0]; +} __packed; + +#define SCOUTFS_NET_LOCK_MAX_RECOVER_NR \ + ((SCOUTFS_NET_MAX_DATA_LEN - sizeof(struct scoutfs_net_lock_recover)) /\ + sizeof(struct scoutfs_net_lock)) + /* some enums for tracing */ enum { SLT_CLIENT, diff --git a/utils/src/print.c b/utils/src/print.c index e697b40b..896cf83b 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -343,6 +343,16 @@ static int print_alloc_item(void *key, unsigned key_len, void *val, return 0; } +static int print_lock_clients_entry(void *key, unsigned key_len, void *val, + unsigned val_len, void *arg) +{ + struct scoutfs_lock_client_btree_key *cbk = key; + + printf(" node_ld %llu\n", be64_to_cpu(cbk->node_id)); + + return 0; +} + typedef int (*print_item_func)(void *key, unsigned key_len, void *val, unsigned val_len, void *arg); @@ -522,6 +532,7 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno) " 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" " 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), @@ -536,6 +547,10 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno) le64_to_cpu(super->bring.nr_blocks), le64_to_cpu(super->bring.next_block), le64_to_cpu(super->bring.next_seq), + super->lock_clients.height, + 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->alloc_root.height, le64_to_cpu(super->alloc_root.ref.blkno), le64_to_cpu(super->alloc_root.ref.seq), @@ -595,6 +610,11 @@ static int print_volume(int fd) ret = print_quorum_blocks(fd, super); + err = print_btree(fd, super, "lock_clients", &super->lock_clients, + print_lock_clients_entry, NULL); + if (err && !ret) + ret = err; + err = print_btree(fd, super, "alloc", &super->alloc_root, print_alloc_item, NULL); if (err && !ret)