gfs2-utils: RHEL7 - libgfs2: Add abstractions for rgrp tree traversal

Andrew Price andyp at fedoraproject.org
Mon Sep 8 17:33:21 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=a0a6c1ed7c74cd25b51f4a8558d11d7d2e13194b
Commit:        a0a6c1ed7c74cd25b51f4a8558d11d7d2e13194b
Parent:        ba30e5f30d3ff7856f966b8be595179aa1ed47c9
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Thu Mar 20 13:43:28 2014 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Thu Jul 24 17:14:23 2014 +0100

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 at redhat.com>
---
 gfs2/libgfs2/libgfs2.h |    3 +++
 gfs2/libgfs2/rgrp.c    |   15 +++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

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);
+}


More information about the cluster-commits mailing list