Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=696eccf4447... Commit: 696eccf4447a9421f2706f5f4b554e098339422c Parent: c1310a43bb88ff28c946c61eb1cceca83e18a2d0 Author: Andrew Price anprice@redhat.com AuthorDate: Thu Mar 20 13:43:28 2014 +0000 Committer: Andrew Price anprice@redhat.com CommitterDate: Sat Mar 29 23:20:29 2014 +0000
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(+), 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); +}