changeset 598:f376beae5867

remove name from volumes Volumes are uniquely identified by their uuid. A name is neither necessary nor desired. Eventually, when volumes have properties, we can use a "comment" property to let the user tag a volume with a more meaningful name. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 04 Mar 2019 17:38:35 -0500
parents c0730cae0a8e
children daca430a9099
files docs/fs-protocol.md src/admin/vol.c src/client/cmd_vol.c src/common/fscall.c src/common/include/nomad/fscall.h src/common/rpc_fs.x src/objstore/include/nomad/objstore.h src/objstore/vol.c
diffstat 8 files changed, 16 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/docs/fs-protocol.md	Mon Mar 04 17:20:27 2019 -0500
+++ b/docs/fs-protocol.md	Mon Mar 04 17:38:35 2019 -0500
@@ -354,7 +354,6 @@
 Inputs
 ------
 * vdev uuid
-* volume name
 
 Outputs
 -------
@@ -375,7 +374,6 @@
 For each loaded volume matching the uuid criteria:
 
 * uuid
-* name
 
 
 Other RPCs that may end up useful
--- a/src/admin/vol.c	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/admin/vol.c	Mon Mar 04 17:38:35 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -24,32 +24,28 @@
 
 void cmd_vol_create_usage(void)
 {
-	fprintf(stderr, "<vdev> <name>\n\n");
+	fprintf(stderr, "<vdev>\n\n");
 
 	print_option("<vdev>", "the uuid of the vdev to hold the new volume");
-	print_option("<name>", "name for the new volume");
 }
 
 int cmd_vol_create(int argc, char **argv)
 {
 	char out[XUUID_PRINTABLE_STRING_LENGTH];
 	struct xuuid uuid;
-	const char *name;
 	int ret;
 
 	/* extra args other than the vdev & name? */
-	if ((optind + 2) != argc)
+	if ((optind + 1) != argc)
 		return PRINT_USAGE;
 
 	if (!xuuid_parse(&uuid, argv[optind]))
 		return PRINT_USAGE;
 
-	name = argv[optind + 1];
-
 	if ((ret = connect_to_server()))
 		return ret;
 
-	ret = fscall_vol_create(&state, &uuid, name, &uuid);
+	ret = fscall_vol_create(&state, &uuid, &uuid);
 
 	disconnect_from_server();
 
@@ -103,7 +99,7 @@
 		return 1;
 	}
 
-	printf("%-36s %-36s %s\n", "VOLID", "VDEVID", "NAME");
+	printf("%-36s %-36s\n", "VOLID", "VDEVID");
 
 	for (i = 0; i < nvols; i++) {
 		struct vol_info *vol = &vols[i];
@@ -113,9 +109,7 @@
 		xuuid_unparse(&vol->vdevid, vdevid);
 		xuuid_unparse(&vol->volid, volid);
 
-		printf("%-36s %-36s %s\n", volid, vdevid, vol->name);
-
-		free(vol->name);
+		printf("%-36s %-36s\n", volid, vdevid);
 	}
 
 	free(vols);
--- a/src/client/cmd_vol.c	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/client/cmd_vol.c	Mon Mar 04 17:38:35 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -38,7 +38,7 @@
 	if (IS_ERR(vdev))
 		return PTR_ERR(vdev);
 
-	vol = objstore_vol_create(vdev, req->name);
+	vol = objstore_vol_create(vdev);
 	if (!IS_ERR(vol)) {
 		res->volid = vol->id;
 		vol_putref(vol);
--- a/src/common/fscall.c	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/common/fscall.c	Mon Mar 04 17:38:35 2019 -0500
@@ -399,14 +399,13 @@
 }
 
 int fscall_vol_create(struct fscall_state *state, struct xuuid *vdevid,
-		      const char *name, struct xuuid *volid)
+		      struct xuuid *volid)
 {
 	struct rpc_vol_create_req vol_create_req;
 	struct rpc_vol_create_res vol_create_res;
 	int ret;
 
 	vol_create_req.vdevid = *vdevid;
-	vol_create_req.name = (char *) name;
 
 	ret = __fscall(state->sock, NRPC_VOL_CREATE,
 		       (void *) xdr_rpc_vol_create_req,
--- a/src/common/include/nomad/fscall.h	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/common/include/nomad/fscall.h	Mon Mar 04 17:38:35 2019 -0500
@@ -68,7 +68,7 @@
 extern int fscall_vdev_list(struct fscall_state *state, struct vdev_info **vdevs,
 			    size_t *nvdevs);
 extern int fscall_vol_create(struct fscall_state *state, struct xuuid *vdevid,
-			     const char *name, struct xuuid *volid);
+			     struct xuuid *volid);
 extern int fscall_vol_list(struct fscall_state *state, const struct xuuid *vdevid,
 			   struct vol_info **vols, size_t *nvols);
 
--- a/src/common/rpc_fs.x	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/common/rpc_fs.x	Mon Mar 04 17:38:35 2019 -0500
@@ -185,7 +185,6 @@
 %/***** VOL_CREATE *****/
 struct rpc_vol_create_req {
 	struct xuuid vdevid;
-	string name<>;
 };
 
 struct rpc_vol_create_res {
@@ -196,7 +195,6 @@
 struct vol_info {
 	struct xuuid vdevid;
 	struct xuuid volid;
-	string name<>;
 };
 
 struct rpc_vol_list_req {
--- a/src/objstore/include/nomad/objstore.h	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/objstore/include/nomad/objstore.h	Mon Mar 04 17:38:35 2019 -0500
@@ -64,7 +64,6 @@
 
 	/* the following can be read without locking the volume */
 	refcnt_t refcnt;
-	struct str *name;
 	const struct vol_ops *ops;
 	struct objstore_vdev *vdev;
 	struct xuuid id;
@@ -91,8 +90,7 @@
 REFCNT_INLINE_FXNS(struct objstore_vdev, vdev, refcnt, objstore_vdev_free, NULL)
 
 /* volume management */
-extern struct objstore *objstore_vol_create(struct objstore_vdev *vdev,
-					    const char *name);
+extern struct objstore *objstore_vol_create(struct objstore_vdev *vdev);
 extern int objstore_vol_import(struct objstore_vdev *vdev, struct xuuid *id);
 extern struct objstore *objstore_vol_lookup(const struct xuuid *volid);
 extern int objstore_vol_list(const struct xuuid *vdev, struct vol_info **vols,
--- a/src/objstore/vol.c	Mon Mar 04 17:20:27 2019 -0500
+++ b/src/objstore/vol.c	Mon Mar 04 17:38:35 2019 -0500
@@ -84,18 +84,13 @@
 	return noid_cmp(&a->oid, &b->oid);
 }
 
-static struct objstore *vol_alloc(struct objstore_vdev *vdev, const char *_name)
+static struct objstore *vol_alloc(struct objstore_vdev *vdev)
 {
 	struct objstore *vol;
-	struct str *name;
 	struct nvlist *props;
 	void *priv;
 	int ret;
 
-	name = str_dup(_name);
-	if (IS_ERR(name))
-		return ERR_CAST(name);
-
 	if (vdev->def->vol_private_size) {
 		priv = zalloc(vdev->def->vol_private_size);
 		if (!priv) {
@@ -112,7 +107,7 @@
 		goto err_priv;
 	}
 
-	ret = nvl_set_str(props, "name", str_getref(name));
+	ret = nvl_set_null(props, "comment");
 	if (ret)
 		goto err_props;
 
@@ -123,7 +118,6 @@
 	}
 
 	refcnt_init(&vol->refcnt, 1);
-	vol->name = name;
 	vol->ops = NULL;
 	vol->vdev = vdev_getref(vdev);
 	xuuid_generate(&vol->id);
@@ -143,7 +137,6 @@
 	free(priv);
 
 err:
-	str_putref(name);
 	return ERR_PTR(ret);
 }
 
@@ -154,7 +147,6 @@
 
 	vdev_putref(vol->vdev);
 	nvl_putref(vol->props);
-	str_putref(vol->name);
 
 	mem_cache_free(vol_cache, vol);
 }
@@ -174,8 +166,7 @@
 			vol->vdev->def->name);
 }
 
-struct objstore *objstore_vol_create(struct objstore_vdev *vdev,
-				     const char *name)
+struct objstore *objstore_vol_create(struct objstore_vdev *vdev)
 {
 	struct objstore *vol;
 	int ret;
@@ -183,7 +174,7 @@
 	if (!vdev->def->create_vol)
 		return ERR_PTR(-ENOTSUP);
 
-	vol = vol_alloc(vdev, name);
+	vol = vol_alloc(vdev);
 	if (IS_ERR(vol))
 		return vol;
 
@@ -213,7 +204,7 @@
 	if (!vdev->def->import_vol)
 		return -ENOTSUP;
 
-	vol = vol_alloc(vdev, "<imported>");
+	vol = vol_alloc(vdev);
 	if (IS_ERR(vol))
 		return PTR_ERR(vol);
 
@@ -280,9 +271,6 @@
 
 		info->vdevid = cur->vdev->uuid;
 		info->volid  = cur->id;
-		info->name   = strdup(str_cstr(cur->name));
-
-		/* TODO: check for allocation errors? */
 	}
 
 	ret = 0;
@@ -304,6 +292,5 @@
 	vdev_putref(vol->vdev);
 
 	nvl_putref(vol->props);
-	str_putref(vol->name);
 	mem_cache_free(vol_cache, vol);
 }