changeset 103:b397469f53d2

objstore: rename "struct objstore" to "struct objstore_vol" The current structure keeps track of exactly one volume yet it uses the most generic and high-level name. In preparation of making volume groups (that will contain zero or more volumes) let's rename the volume's structure to something that more accurately reflects its purpose. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net> Signed-off-by: Steve Dougherty <steve@asksteved.com>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Oct 2015 15:27:29 -0400
parents 29867876857f
children 40b4277fb1e1
files src/client/main.c src/objstore/include/nomad/objstore.h src/objstore/include/nomad/objstore_impl.h src/objstore/mem/main.c src/objstore/objstore.c src/objstore/posix/main.c
diffstat 6 files changed, 50 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/src/client/main.c	Sat Oct 17 11:58:48 2015 -0400
+++ b/src/client/main.c	Sat Oct 17 15:27:29 2015 -0400
@@ -40,7 +40,7 @@
 
 int main(int argc, char **argv)
 {
-	struct objstore *store;
+	struct objstore_vol *vol;
 	int ret;
 
 	/*
@@ -62,22 +62,22 @@
 		goto err;
 	}
 
-	store = objstore_store_create("abc", OS_MODE_STORE);
-	fprintf(stderr, "store = %p\n", store);
+	vol = objstore_vol_create("abc", OS_MODE_STORE);
+	fprintf(stderr, "vol = %p\n", vol);
 
-	if (IS_ERR(store)) {
-		ret = PTR_ERR(store);
+	if (IS_ERR(vol)) {
+		ret = PTR_ERR(vol);
 		fprintf(stderr, "error: %s\n", strerror(ret));
-		goto err_objstore;
+		goto err_vol;
 	}
 
-	ret = connsvc(NULL, CLIENT_DAEMON_PORT, process_connection, store);
+	ret = connsvc(NULL, CLIENT_DAEMON_PORT, process_connection, vol);
 
 	fprintf(stderr, "connsvc() = %d (%s)\n", ret, strerror(ret));
 
-	/* XXX: undo objstore_store_create() */
+	/* XXX: undo objstore_vol_create() */
 
-err_objstore:
+err_vol:
 	/* XXX: undo objstore_init() */
 
 err:
--- a/src/objstore/include/nomad/objstore.h	Sat Oct 17 11:58:48 2015 -0400
+++ b/src/objstore/include/nomad/objstore.h	Sat Oct 17 15:27:29 2015 -0400
@@ -30,10 +30,10 @@
 	OS_MODE_STORE,
 };
 
-struct objstore_def;
+struct objstore_vol_def;
 
-struct objstore {
-	const struct objstore_def *def;
+struct objstore_vol {
+	const struct objstore_vol_def *def;
 
 	struct nuuid uuid;
 	const char *path;
@@ -43,15 +43,18 @@
 };
 
 extern int objstore_init(void);
-extern struct objstore *objstore_store_create(const char *path,
-					      enum objstore_mode mode);
-extern struct objstore *objstore_store_load(struct nuuid *uuid, const char *path);
 
-/* store operations */
-extern int objstore_getroot(struct objstore *store, struct nobjhndl *hndl);
+/* volume management */
+extern struct objstore_vol *objstore_vol_create(const char *path,
+						enum objstore_mode mode);
+extern struct objstore_vol *objstore_vol_load(struct nuuid *uuid,
+					      const char *path);
+
+/* volume operations */
+extern int objstore_getroot(struct objstore_vol *store, struct nobjhndl *hndl);
 
 /* object operations */
-extern int objstore_obj_getattr(struct objstore *store,
+extern int objstore_obj_getattr(struct objstore_vol *store,
 				const struct nobjhndl *hndl,
 				struct nattr *attr);
 
--- a/src/objstore/include/nomad/objstore_impl.h	Sat Oct 17 11:58:48 2015 -0400
+++ b/src/objstore/include/nomad/objstore_impl.h	Sat Oct 17 15:27:29 2015 -0400
@@ -25,10 +25,10 @@
 
 #include <nomad/objstore.h>
 
-struct objstore_ops {
-	int (*create)(struct objstore *store);
-	int (*load)(struct objstore *store);
-	int (*getroot)(struct objstore *store, struct nobjhndl *hndl);
+struct vol_ops {
+	int (*create)(struct objstore_vol *store);
+	int (*load)(struct objstore_vol *store);
+	int (*getroot)(struct objstore_vol *store, struct nobjhndl *hndl);
 };
 
 struct obj_ops {
@@ -47,16 +47,16 @@
 	int (*commit)();	/* make temp object live */
 	int (*abort)();		/* delete temp object */
 
-	int (*getattr)(struct objstore *store, const struct nobjhndl *hndl,
+	int (*getattr)(struct objstore_vol *store, const struct nobjhndl *hndl,
 		       struct nattr *attr);
 	int (*setattr)();	/* set attributes of an object */
 	ssize_t (*read)();	/* read portion of an object */
 	ssize_t (*write)();	/* write portion of an object */
 };
 
-struct objstore_def {
+struct objstore_vol_def {
 	const char *name;
-	const struct objstore_ops *store_ops;
+	const struct vol_ops *vol_ops;
 	const struct obj_ops *obj_ops;
 };
 
--- a/src/objstore/mem/main.c	Sat Oct 17 11:58:48 2015 -0400
+++ b/src/objstore/mem/main.c	Sat Oct 17 15:27:29 2015 -0400
@@ -104,7 +104,7 @@
 	return ERR_PTR(ret);
 }
 
-static int mem_store_create(struct objstore *store)
+static int mem_vol_create(struct objstore_vol *store)
 {
 	struct memstore *ms;
 	struct memobj *obj;
@@ -135,7 +135,7 @@
 	return 0;
 }
 
-static int mem_store_getroot(struct objstore *store, struct nobjhndl *hndl)
+static int mem_vol_getroot(struct objstore_vol *store, struct nobjhndl *hndl)
 {
 	struct memstore *ms;
 
@@ -153,16 +153,16 @@
 	return 0;
 }
 
-static const struct objstore_ops store_ops = {
-	.create = mem_store_create,
-	.getroot = mem_store_getroot,
+static const struct vol_ops vol_ops = {
+	.create = mem_vol_create,
+	.getroot = mem_vol_getroot,
 };
 
 static const struct obj_ops obj_ops = {
 };
 
-const struct objstore_def objstore = {
+const struct objstore_vol_def objvol = {
 	.name = "mem",
-	.store_ops = &store_ops,
+	.vol_ops = &vol_ops,
 	.obj_ops = &obj_ops,
 };
--- a/src/objstore/objstore.c	Sat Oct 17 11:58:48 2015 -0400
+++ b/src/objstore/objstore.c	Sat Oct 17 15:27:29 2015 -0400
@@ -30,7 +30,7 @@
 #include <nomad/objstore_impl.h>
 
 struct backend {
-	const struct objstore_def *def;
+	const struct objstore_vol_def *def;
 	void *module;
 };
 
@@ -51,7 +51,7 @@
 	if (!backend->module)
 		return ENOENT;
 
-	backend->def = dlsym(backend->module, "objstore");
+	backend->def = dlsym(backend->module, "objvol");
 	if (!backend->def) {
 		dlclose(backend->module);
 		return ENOENT;
@@ -73,15 +73,15 @@
 	return 0;
 }
 
-struct objstore *objstore_store_create(const char *path, enum objstore_mode mode)
+struct objstore_vol *objstore_vol_create(const char *path, enum objstore_mode mode)
 {
-	struct objstore *s;
+	struct objstore_vol *s;
 	int ret;
 
-	if (!backend->def->store_ops->create)
+	if (!backend->def->vol_ops->create)
 		return ERR_PTR(ENOTSUP);
 
-	s = malloc(sizeof(struct objstore));
+	s = malloc(sizeof(struct objstore_vol));
 	if (!s)
 		return ERR_PTR(ENOMEM);
 
@@ -93,7 +93,7 @@
 		goto err;
 	}
 
-	ret = s->def->store_ops->create(s);
+	ret = s->def->vol_ops->create(s);
 	if (ret)
 		goto err_path;
 
@@ -108,23 +108,23 @@
 	return ERR_PTR(ret);
 }
 
-struct objstore *objstore_store_load(struct nuuid *uuid, const char *path)
+struct objstore_vol *objstore_vol_load(struct nuuid *uuid, const char *path)
 {
 	return ERR_PTR(ENOTSUP);
 }
 
-int objstore_getroot(struct objstore *store, struct nobjhndl *hndl)
+int objstore_getroot(struct objstore_vol *store, struct nobjhndl *hndl)
 {
 	if (!hndl)
 		return EINVAL;
 
-	if (!store || !store->def->store_ops || !store->def->store_ops->getroot)
+	if (!store || !store->def->vol_ops || !store->def->vol_ops->getroot)
 		return EINVAL;
 
-	return store->def->store_ops->getroot(store, hndl);
+	return store->def->vol_ops->getroot(store, hndl);
 }
 
-int objstore_obj_getattr(struct objstore *store, const struct nobjhndl *hndl,
+int objstore_obj_getattr(struct objstore_vol *store, const struct nobjhndl *hndl,
 			 struct nattr *attr)
 {
 	if (!hndl || !hndl->clock)
--- a/src/objstore/posix/main.c	Sat Oct 17 11:58:48 2015 -0400
+++ b/src/objstore/posix/main.c	Sat Oct 17 15:27:29 2015 -0400
@@ -23,14 +23,14 @@
 #include <nomad/error.h>
 #include <nomad/objstore_impl.h>
 
-static const struct objstore_ops store_ops = {
+static const struct vol_ops vol_ops = {
 };
 
 static const struct obj_ops obj_ops = {
 };
 
-const struct objstore_def objstore = {
+const struct objstore_vol_def objvol = {
 	.name = "posix",
-	.store_ops = &store_ops,
+	.vol_ops = &vol_ops,
 	.obj_ops = &obj_ops,
 };