changeset 142:dac1cb39ce51

objstore: specify vg type when creating a vg Volume groups are backed by several volumes. The policy decision how those volumes are used determined by the type of the volume group. One can easily envision at least three types of vgs: simple - just one volume backing a vg mirror - objects are mirrored across all vgs stripe - objects are striped across all vgs Currently, we support only one vg type - simple (aka. OS_VG_SIMPLE). Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 18 Oct 2015 13:16:30 -0400
parents 284620d22c0a
children 8cdc4c122e03
files src/client/main.c src/objstore/include/nomad/objstore.h src/objstore/vg.c
diffstat 3 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/client/main.c	Sun Oct 18 12:40:29 2015 -0400
+++ b/src/client/main.c	Sun Oct 18 13:16:30 2015 -0400
@@ -66,7 +66,7 @@
 		goto err;
 	}
 
-	vg = objstore_vg_create("myfiles");
+	vg = objstore_vg_create("myfiles", OS_VG_SIMPLE);
 	fprintf(stderr, "vg = %p\n", vg);
 
 	if (IS_ERR(vg)) {
--- a/src/objstore/include/nomad/objstore.h	Sun Oct 18 12:40:29 2015 -0400
+++ b/src/objstore/include/nomad/objstore.h	Sun Oct 18 13:16:30 2015 -0400
@@ -33,6 +33,12 @@
 	OS_MODE_STORE,
 };
 
+enum objstore_vg_type {
+	OS_VG_SIMPLE,
+	/* TODO: OS_VG_MIRROR, */
+	/* TODO: OS_VG_STRIPE, */
+};
+
 struct objstore {
 	list_node_t node;
 
@@ -59,7 +65,8 @@
 extern int objstore_init(void);
 
 /* volume group management */
-extern struct objstore *objstore_vg_create(const char *name);
+extern struct objstore *objstore_vg_create(const char *name,
+					   enum objstore_vg_type type);
 extern struct objstore *objstore_vg_lookup(const char *name);
 
 /* volume management */
--- a/src/objstore/vg.c	Sun Oct 18 12:40:29 2015 -0400
+++ b/src/objstore/vg.c	Sun Oct 18 13:16:30 2015 -0400
@@ -39,17 +39,21 @@
 	list_create(&vgs, sizeof(struct objstore),
 		    offsetof(struct objstore, node));
 
-	filecache = objstore_vg_create("file$");
+	filecache = objstore_vg_create("file$", OS_VG_SIMPLE);
 	if (IS_ERR(filecache))
 		return PTR_ERR(filecache);
 
 	return 0;
 }
 
-struct objstore *objstore_vg_create(const char *name)
+struct objstore *objstore_vg_create(const char *name,
+				    enum objstore_vg_type type)
 {
 	struct objstore *vg;
 
+	if (type != OS_VG_SIMPLE)
+		return ERR_PTR(EINVAL);
+
 	vg = malloc(sizeof(struct objstore));
 	if (!vg)
 		return ERR_PTR(ENOMEM);