mirror of
https://github.com/versity/scoutfs.git
synced 2026-08-01 04:46:29 +00:00
Write locks are given an increasing version number as they're granted which makes its way into items in the log btrees and is used to find the most recent version of an item. The initialization of the lock server's next write_version for granted locks dates back to the initial prototype of the forest of log btrees. It is only initialized to zero as the module is loaded. This means that reloading the module, perhaps by rebooting, resets all the item versions to 0 and can lead to newly written items being ignored in favour of older existing items with greater versions from a previous mount. To fix this we initialize the lock server's write_version to the greatest of all the versions in items in log btrees. We add a field to the log_trees struct which records the greatest version which is maintained as we write out items in transactions. These are read by the server as it starts. Then lock recovery needs to include the write_version so that the lock_server can be sure to set the next write_version past the greatest version in the currently granted locks. Signed-off-by: Zach Brown <zab@versity.com>
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
#ifndef _SCOUTFS_FOREST_H_
|
|
#define _SCOUTFS_FOREST_H_
|
|
|
|
struct scoutfs_alloc;
|
|
struct scoutfs_block_writer;
|
|
struct scoutfs_block;
|
|
|
|
#include "btree.h"
|
|
|
|
/* caller gives an item to the callback */
|
|
typedef int (*scoutfs_forest_item_cb)(struct super_block *sb,
|
|
struct scoutfs_key *key,
|
|
struct scoutfs_log_item_value *liv,
|
|
void *val, int val_len, void *arg);
|
|
|
|
int scoutfs_forest_next_hint(struct super_block *sb, struct scoutfs_key *key,
|
|
struct scoutfs_key *next);
|
|
int scoutfs_forest_read_items(struct super_block *sb,
|
|
struct scoutfs_lock *lock,
|
|
struct scoutfs_key *key,
|
|
struct scoutfs_key *start,
|
|
struct scoutfs_key *end,
|
|
scoutfs_forest_item_cb cb, void *arg);
|
|
int scoutfs_forest_set_bloom_bits(struct super_block *sb,
|
|
struct scoutfs_lock *lock);
|
|
void scoutfs_forest_set_max_vers(struct super_block *sb, u64 max_vers);
|
|
int scoutfs_forest_get_max_vers(struct super_block *sb,
|
|
struct scoutfs_super_block *super,
|
|
u64 *vers);
|
|
int scoutfs_forest_insert_list(struct super_block *sb,
|
|
struct scoutfs_btree_item_list *lst);
|
|
int scoutfs_forest_srch_add(struct super_block *sb, u64 hash, u64 ino, u64 id);
|
|
|
|
void scoutfs_forest_init_btrees(struct super_block *sb,
|
|
struct scoutfs_alloc *alloc,
|
|
struct scoutfs_block_writer *wri,
|
|
struct scoutfs_log_trees *lt);
|
|
void scoutfs_forest_get_btrees(struct super_block *sb,
|
|
struct scoutfs_log_trees *lt);
|
|
|
|
int scoutfs_forest_setup(struct super_block *sb);
|
|
void scoutfs_forest_destroy(struct super_block *sb);
|
|
|
|
#endif
|