mirror of
https://github.com/versity/scoutfs.git
synced 2026-07-27 18:43:13 +00:00
Previously we had stubbed out the btree item API with static inlines. Those are replaced with real functions in a reasonably functional btree implementation. The btree implementation itself is pretty straight forward. Operations are performed top-down and we dirty, lock, and split/merge blocks as we go. Callers are given a cursor to give them full access to the item. Items in the btree blocks are stored in a treap. There are a lot of comments in the code to help make things clear. We add the notion of block references and some block functions for reading and dirtying blocks by reference. This passes tests up to the point where unmount tries to write out data and the world catches fire. That's far enough to commit what we have and iterate from there. Signed-off-by: Zach Brown <zab@versity.com>
38 lines
972 B
C
38 lines
972 B
C
#ifndef _SCOUTFS_BLOCK_H_
|
|
#define _SCOUTFS_BLOCK_H_
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/rwlock.h>
|
|
#include <linux/atomic.h>
|
|
|
|
#define SCOUTFS_BLOCK_BIT_UPTODATE (1 << 0)
|
|
#define SCOUTFS_BLOCK_BIT_ERROR (1 << 1)
|
|
|
|
struct scoutfs_block {
|
|
struct rw_semaphore rwsem;
|
|
atomic_t refcount;
|
|
u64 blkno;
|
|
|
|
unsigned long bits;
|
|
|
|
struct super_block *sb;
|
|
/* only high order page alloc for now */
|
|
struct page *page;
|
|
void *data;
|
|
};
|
|
|
|
struct scoutfs_block *scoutfs_read_block(struct super_block *sb, u64 blkno);
|
|
struct scoutfs_block *scoutfs_new_block(struct super_block *sb, u64 blkno);
|
|
struct scoutfs_block *scoutfs_alloc_block(struct super_block *sb);
|
|
|
|
struct scoutfs_block *scoutfs_read_ref(struct super_block *sb,
|
|
struct scoutfs_block_ref *ref);
|
|
struct scoutfs_block *scoutfs_dirty_ref(struct super_block *sb,
|
|
struct scoutfs_block_ref *ref);
|
|
|
|
void scoutfs_put_block(struct scoutfs_block *bl);
|
|
|
|
void scoutfs_calc_hdr_crc(struct scoutfs_block *bl);
|
|
|
|
#endif
|