[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH 06/14] libgfs2: Add abstractions for rgrp tree traversal



Users of libgfs2 are required to include the gfs2-utils-specific
osi_tree.h in order to make use of the resource groups. With this patch
we introduce functions which wrap the osi_first and osi_next functions
so that we can hide the implementation of the resource group tree behind
the lgfs2_rgrp_t type. Converting users of the osi_tree.h functions to
the new rgrp APIs will be done later and gradually.

Signed-off-by: Andrew Price <anprice redhat com>
---
 gfs2/libgfs2/libgfs2.h |  3 +++
 gfs2/libgfs2/rgrp.c    | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b2f6bc3..3eeb04d 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -197,6 +197,9 @@ extern uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32
 extern lgfs2_rgrp_t lgfs2_rgrp_append(lgfs2_rgrps_t rgs, uint64_t addr, uint32_t rglen, uint64_t *nextaddr);
 extern int lgfs2_rgrp_write(lgfs2_rgrps_t rgs, int fd, lgfs2_rgrp_t rg);
 extern struct gfs2_rindex *lgfs2_rgrp_index(lgfs2_rgrp_t rg);
+extern lgfs2_rgrp_t lgfs2_rgrp_first(lgfs2_rgrps_t rgs);
+extern lgfs2_rgrp_t lgfs2_rgrp_last(lgfs2_rgrps_t rgs);
+extern lgfs2_rgrp_t lgfs2_rgrp_next(lgfs2_rgrp_t rg);
 // Temporary function to aid API migration
 extern struct osi_node *lgfs2_rgrps_root(lgfs2_rgrps_t rgs) __attribute__((deprecated));
 
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 1242385..fb2b115 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -479,3 +479,18 @@ int lgfs2_rgrp_write(const lgfs2_rgrps_t rgs, int fd, const lgfs2_rgrp_t rg)
 	free(buff);
 	return 0;
 }
+
+lgfs2_rgrp_t lgfs2_rgrp_first(lgfs2_rgrps_t rgs)
+{
+	return (lgfs2_rgrp_t)osi_first(&rgs->root);
+}
+
+lgfs2_rgrp_t lgfs2_rgrp_next(lgfs2_rgrp_t rg)
+{
+	return (lgfs2_rgrp_t)osi_next(&rg->node);
+}
+
+lgfs2_rgrp_t lgfs2_rgrp_last(lgfs2_rgrps_t rgs)
+{
+	return (lgfs2_rgrp_t)osi_last(&rgs->root);
+}
-- 
1.8.5.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]