scoutfs: have btree use blocks, allocator, writer

Convert the btree to use our block cache, block allocation, and the
caller's explicit dirty block tracking writer context instead of the
ring.  This is in preparation for the btree forest format where there
are concurrent multiple writers of independent dynamically sized btrees
instead of only the server writing one btree with a fixed maximum size.

All the machinery for tracking dirty blocks in the ring and migrating is
no longer needed.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2020-01-17 11:21:36 -08:00
committed by Zach Brown
parent bdafa6ede6
commit 8775826d7e
4 changed files with 201 additions and 578 deletions
+173 -546
View File
File diff suppressed because it is too large Load Diff
+23 -11
View File
@@ -3,7 +3,13 @@
#include <linux/uio.h>
struct scoutfs_balloc_allocator;
struct scoutfs_block_writer;
struct scoutfs_block;
struct scoutfs_btree_item_ref {
struct super_block *sb;
struct scoutfs_block *bl;
void *key;
unsigned key_len;
void *val;
@@ -13,16 +19,26 @@ struct scoutfs_btree_item_ref {
#define SCOUTFS_BTREE_ITEM_REF(name) \
struct scoutfs_btree_item_ref name = {NULL,}
int scoutfs_btree_lookup(struct super_block *sb, struct scoutfs_btree_root *root,
void *key, unsigned key_len,
struct scoutfs_btree_item_ref *iref);
int scoutfs_btree_insert(struct super_block *sb, struct scoutfs_btree_root *root,
int scoutfs_btree_insert(struct super_block *sb,
struct scoutfs_balloc_allocator *alloc,
struct scoutfs_block_writer *wri,
struct scoutfs_btree_root *root,
void *key, unsigned key_len,
void *val, unsigned val_len);
int scoutfs_btree_update(struct super_block *sb, struct scoutfs_btree_root *root,
int scoutfs_btree_update(struct super_block *sb,
struct scoutfs_balloc_allocator *alloc,
struct scoutfs_block_writer *wri,
struct scoutfs_btree_root *root,
void *key, unsigned key_len,
void *val, unsigned val_len);
int scoutfs_btree_delete(struct super_block *sb, struct scoutfs_btree_root *root,
int scoutfs_btree_delete(struct super_block *sb,
struct scoutfs_balloc_allocator *alloc,
struct scoutfs_block_writer *wri,
struct scoutfs_btree_root *root,
void *key, unsigned key_len);
int scoutfs_btree_next(struct super_block *sb, struct scoutfs_btree_root *root,
void *key, unsigned key_len,
@@ -36,16 +52,12 @@ int scoutfs_btree_prev(struct super_block *sb, struct scoutfs_btree_root *root,
int scoutfs_btree_before(struct super_block *sb, struct scoutfs_btree_root *root,
void *key, unsigned key_len,
struct scoutfs_btree_item_ref *iref);
int scoutfs_btree_dirty(struct super_block *sb, struct scoutfs_btree_root *root,
int scoutfs_btree_dirty(struct super_block *sb,
struct scoutfs_balloc_allocator *alloc,
struct scoutfs_block_writer *wri,
struct scoutfs_btree_root *root,
void *key, unsigned key_len);
void scoutfs_btree_put_iref(struct scoutfs_btree_item_ref *iref);
bool scoutfs_btree_has_dirty(struct super_block *sb);
int scoutfs_btree_write_dirty(struct super_block *sb);
void scoutfs_btree_write_complete(struct super_block *sb);
int scoutfs_btree_setup(struct super_block *sb);
void scoutfs_btree_destroy(struct super_block *sb);
#endif
-5
View File
@@ -199,15 +199,10 @@ struct scoutfs_btree_ref {
/*
* A height of X means that the first block read will have level X-1 and
* the leaves will have level 0.
*
* The migration key is used to walk the tree finding old blocks to migrate
* into the current half of the ring.
*/
struct scoutfs_btree_root {
struct scoutfs_btree_ref ref;
__u8 height;
__le16 migration_key_len;
__u8 migration_key[SCOUTFS_BTREE_MAX_KEY_LEN];
} __packed;
struct scoutfs_btree_item_header {
+5 -16
View File
@@ -2389,21 +2389,15 @@ TRACE_EVENT(scoutfs_btree_read_error,
);
TRACE_EVENT(scoutfs_btree_dirty_block,
TP_PROTO(struct super_block *sb, u64 blkno, u64 seq, u64 next_block,
u64 next_seq, unsigned long cur_dirtied,
unsigned long old_dirtied, u64 bt_blkno, u64 bt_seq),
TP_PROTO(struct super_block *sb, u64 blkno, u64 seq,
u64 bt_blkno, u64 bt_seq),
TP_ARGS(sb, blkno, seq, next_block, next_seq, cur_dirtied, old_dirtied,
bt_blkno, bt_seq),
TP_ARGS(sb, blkno, seq, bt_blkno, bt_seq),
TP_STRUCT__entry(
SCSB_TRACE_FIELDS
__field(__u64, blkno)
__field(__u64, seq)
__field(__u64, next_block)
__field(__u64, next_seq)
__field(unsigned long, cur_dirtied)
__field(unsigned long, old_dirtied)
__field(__u64, bt_blkno)
__field(__u64, bt_seq)
),
@@ -2412,18 +2406,13 @@ TRACE_EVENT(scoutfs_btree_dirty_block,
SCSB_TRACE_ASSIGN(sb);
__entry->blkno = blkno;
__entry->seq = seq;
__entry->next_block = next_block;
__entry->next_seq = next_seq;
__entry->cur_dirtied = cur_dirtied;
__entry->old_dirtied = old_dirtied;
__entry->bt_blkno = bt_blkno;
__entry->bt_seq = bt_seq;
),
TP_printk(SCSBF" blkno %llu seq %llu next_block %llu next_seq %llu cur_dirtied %lu old_dirtied %lu bt_blkno %llu bt_seq %llu",
TP_printk(SCSBF" blkno %llu seq %llu bt_blkno %llu bt_seq %llu",
SCSB_TRACE_ARGS, __entry->blkno, __entry->seq,
__entry->next_block, __entry->next_seq, __entry->cur_dirtied,
__entry->old_dirtied, __entry->bt_blkno, __entry->bt_seq)
__entry->bt_blkno, __entry->bt_seq)
);
DECLARE_EVENT_CLASS(scoutfs_extent_class,