[Ocfs2-tools-devel] [RFC 5/8] dx_dirs v4: extent tree code for indexed dirs in libocfs2
Coly Li
coly.li at suse.de
Wed Jan 20 07:25:00 PST 2010
This patch adds indexed dir support to extent tree operations. The v4 patch changes (almost) nothing from v3 and v2 patch.
Signed-off-by: Coly Li <coly.li at suse.de>
---
extent_tree.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
extent_tree.h | 4 ++++
2 files changed, 57 insertions(+)
diff --git a/libocfs2/extent_tree.c b/libocfs2/extent_tree.c
index 499ce1b..3954726 100644
--- a/libocfs2/extent_tree.c
+++ b/libocfs2/extent_tree.c
@@ -60,6 +60,49 @@ static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = {
.eo_fill_root_el = ocfs2_dinode_fill_root_el,
};
+static void ocfs2_dx_root_set_last_eb_blk (struct ocfs2_extent_tree *et,
+ uint64_t blkno)
+{
+ struct ocfs2_dx_root_block *dx_root = et->et_object;
+ dx_root->dr_last_eb_blk = blkno;
+}
+
+static uint64_t ocfs2_dx_root_get_last_eb_blk (struct ocfs2_extent_tree *et)
+{
+ struct ocfs2_dx_root_block *dx_root = et->et_object;
+ return dx_root->dr_last_eb_blk;
+}
+
+static void ocfs2_dx_root_update_clusters(struct ocfs2_extent_tree *et,
+ uint32_t clusters)
+{
+ struct ocfs2_dx_root_block *dx_root = et->et_object;
+ dx_root->dr_clusters += clusters;
+}
+
+static int ocfs2_dx_root_sanity_check(struct ocfs2_extent_tree *et)
+{
+ struct ocfs2_dx_root_block *dx_root = (struct ocfs2_dx_root_block *)et->et_object;
+ assert(OCFS2_IS_VALID_DX_ROOT(dx_root));
+
+ return 0;
+}
+
+static void ocfs2_dx_root_fill_root_el (struct ocfs2_extent_tree *et)
+{
+ struct ocfs2_dx_root_block *dx_root = et->et_object;
+
+ et->et_root_el = &dx_root->dr_list;
+}
+
+static struct ocfs2_extent_tree_operations ocfs2_dx_root_et_ops = {
+ .eo_set_last_eb_blk = ocfs2_dx_root_set_last_eb_blk,
+ .eo_get_last_eb_blk = ocfs2_dx_root_get_last_eb_blk,
+ .eo_update_clusters = ocfs2_dx_root_update_clusters,
+ .eo_sanity_check = ocfs2_dx_root_sanity_check,
+ .eo_fill_root_el = ocfs2_dx_root_fill_root_el,
+};
+
static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
ocfs2_filesys *fs,
char *buf,
@@ -90,6 +133,15 @@ void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
buf, &ocfs2_dinode_et_ops);
}
+void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et,
+ ocfs2_filesys *fs,
+ char *buf, uint64_t blkno)
+{
+ __ocfs2_init_extent_tree(et, fs, buf, blkno,
+ ocfs2_write_dx_root,
+ buf, &ocfs2_dx_root_et_ops);
+}
+
static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
uint64_t new_last_eb_blk)
{
@@ -4072,3 +4124,4 @@ out:
ocfs2_free_path(path);
return ret;
}
+
diff --git a/libocfs2/extent_tree.h b/libocfs2/extent_tree.h
index 4e6e091..42a3155 100644
--- a/libocfs2/extent_tree.h
+++ b/libocfs2/extent_tree.h
@@ -109,3 +109,7 @@ int ocfs2_change_extent_flag(ocfs2_filesys *fs,
int ocfs2_remove_extent(ocfs2_filesys *fs,
struct ocfs2_extent_tree *et,
uint32_t cpos, uint32_t len);
+void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et,
+ ocfs2_filesys *fs,
+ char *buf, uint64_t blkno);
+
--
Coly Li
SuSE Labs
More information about the Ocfs2-tools-devel
mailing list