changeset 143:8cdc4c122e03

objstore: objstore_getroot should be with vg code In the process of moving the code, update it slightly to make it obvious we support only simple vgs. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 18 Oct 2015 13:18:54 -0400
parents dac1cb39ce51
children b3d800982276
files src/objstore/include/nomad/objstore_impl.h src/objstore/vg.c src/objstore/vol.c
diffstat 3 files changed, 30 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/objstore/include/nomad/objstore_impl.h	Sun Oct 18 13:16:30 2015 -0400
+++ b/src/objstore/include/nomad/objstore_impl.h	Sun Oct 18 13:18:54 2015 -0400
@@ -64,4 +64,7 @@
 extern int objstore_vg_init(void);
 extern void objstore_vg_add_vol(struct objstore *vg, struct objstore_vol *vol);
 
+/* wrappers for volume ops */
+extern int objstore_vol_getroot(struct objstore_vol *vol, struct nobjhndl *hndl);
+
 #endif
--- a/src/objstore/vg.c	Sun Oct 18 13:16:30 2015 -0400
+++ b/src/objstore/vg.c	Sun Oct 18 13:18:54 2015 -0400
@@ -95,3 +95,25 @@
 
 	return vg;
 }
+
+int objstore_getroot(struct objstore *vg, struct nobjhndl *hndl)
+{
+	struct objstore_vol *vol;
+	int ret;
+
+	if (!vg || !hndl)
+		return EINVAL;
+
+	/*
+	 * TODO: we're assuming OS_VG_SIMPLE
+	 */
+	mxlock(&vg->lock);
+	vol = list_head(&vg->vols);
+	if (vol)
+		ret = objstore_vol_getroot(vol, hndl);
+	else
+		ret = ENXIO;
+	mxunlock(&vg->lock);
+
+	return ret;
+}
--- a/src/objstore/vol.c	Sun Oct 18 13:16:30 2015 -0400
+++ b/src/objstore/vol.c	Sun Oct 18 13:18:54 2015 -0400
@@ -24,27 +24,13 @@
 #include <nomad/objstore.h>
 #include <nomad/objstore_impl.h>
 
-int objstore_getroot(struct objstore *vg, struct nobjhndl *hndl)
+int objstore_vol_getroot(struct objstore_vol *vol, struct nobjhndl *hndl)
 {
-	struct objstore_vol *vol;
-	int ret;
-
-	if (!vg || !hndl)
+	if (!vol || !hndl)
 		return EINVAL;
 
-	mxlock(&vg->lock);
-
-	/*
-	 * FIXME: we only inspect the first volume
-	 */
-	vol = list_head(&vg->vols);
+	if (!vol->def->vol_ops || !vol->def->vol_ops->getroot)
+		return ENOTSUP;
 
-	if (vol && vol->def->vol_ops && vol->def->vol_ops->getroot)
-		ret = vol->def->vol_ops->getroot(vol, hndl);
-	else
-		ret = ENOTSUP;
-
-	mxunlock(&vg->lock);
-
-	return ret;
+	return vol->def->vol_ops->getroot(vol, hndl);
 }