changeset 891:77a35abc6a24

objstore: move dir buffer making helper to dir.c This is where it belongs since it doesn't do anything directly with objects. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 19 Dec 2022 19:44:45 -0500
parents aa5470a5ef8a
children 9b1ce98807c0
files src/objstore/dir.c src/objstore/include/nomad/objstore_backend.h src/objstore/obj_dir.c src/objstore/obj_dir_create.c src/objstore/posix/obj_create.c
diffstat 5 files changed, 47 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/src/objstore/dir.c	Mon Dec 19 19:39:43 2022 -0500
+++ b/src/objstore/dir.c	Mon Dec 19 19:44:45 2022 -0500
@@ -166,3 +166,41 @@
 
 	return 0;
 }
+
+int dir_make_buffer(uint64_t this_host, uint64_t this_uniq,
+		    uint64_t parent_host, uint64_t parent_uniq,
+		    struct buffer *buf)
+{
+	struct ndirent_tgt tgt;
+	struct dirblock block;
+	int ret;
+
+	dirblock_init(&block);
+
+	ret = buffer_truncate(buf, 0);
+	if (ret)
+		return ret;
+
+	/* '.' dirent */
+	tgt.type = NDIRENT_TYPE_DIR;
+	tgt.deleted = false;
+	tgt.host = this_host;
+	tgt.uniq = this_uniq;
+
+	ret = dirblock_add_dirent(&block, ".", &tgt);
+	if (ret)
+		return ret;
+
+	/* '..' dirent */
+	tgt.type = NDIRENT_TYPE_DIR;
+	tgt.deleted = false;
+	tgt.host = parent_host;
+	tgt.uniq = parent_uniq;
+
+	ret = dirblock_add_dirent(&block, "..", &tgt);
+	if (ret)
+		return ret;
+
+	/* serialize */
+	return dirblock_serialize(&block, buf);
+}
--- a/src/objstore/include/nomad/objstore_backend.h	Mon Dec 19 19:39:43 2022 -0500
+++ b/src/objstore/include/nomad/objstore_backend.h	Mon Dec 19 19:44:45 2022 -0500
@@ -279,8 +279,8 @@
 extern struct objver *obj_add_version(struct obj *obj,
 				      const struct nvclock *clock);
 
-extern int obj_make_dir_buffer(uint64_t this_host, uint64_t this_uniq,
-			       uint64_t parent_host, uint64_t parent_uniq,
-			       struct buffer *buf);
+extern int dir_make_buffer(uint64_t this_host, uint64_t this_uniq,
+			   uint64_t parent_host, uint64_t parent_uniq,
+			   struct buffer *buf);
 
 #endif
--- a/src/objstore/obj_dir.c	Mon Dec 19 19:39:43 2022 -0500
+++ b/src/objstore/obj_dir.c	Mon Dec 19 19:44:45 2022 -0500
@@ -50,44 +50,6 @@
 	return 0;
 }
 
-int obj_make_dir_buffer(uint64_t this_host, uint64_t this_uniq,
-			uint64_t parent_host, uint64_t parent_uniq,
-			struct buffer *buf)
-{
-	struct ndirent_tgt tgt;
-	struct dirblock block;
-	int ret;
-
-	dirblock_init(&block);
-
-	ret = buffer_truncate(buf, 0);
-	if (ret)
-		return ret;
-
-	/* '.' dirent */
-	tgt.type = NDIRENT_TYPE_DIR;
-	tgt.deleted = false;
-	tgt.host = this_host;
-	tgt.uniq = this_uniq;
-
-	ret = dirblock_add_dirent(&block, ".", &tgt);
-	if (ret)
-		return ret;
-
-	/* '..' dirent */
-	tgt.type = NDIRENT_TYPE_DIR;
-	tgt.deleted = false;
-	tgt.host = parent_host;
-	tgt.uniq = parent_uniq;
-
-	ret = dirblock_add_dirent(&block, "..", &tgt);
-	if (ret)
-		return ret;
-
-	/* serialize */
-	return dirblock_serialize(&block, buf);
-}
-
 /* find an entry - no matter what its state is (conflicts, all_deleted, etc.) */
 int dir_lookup_entry(struct objver *dirver, const char *name, uint8_t *raw,
 		     struct ndirent_mem *ent, uint64_t *_off,
--- a/src/objstore/obj_dir_create.c	Mon Dec 19 19:39:43 2022 -0500
+++ b/src/objstore/obj_dir_create.c	Mon Dec 19 19:44:45 2022 -0500
@@ -79,11 +79,11 @@
 		buffer_init_static(&contents, raw, sizeof(raw), sizeof(raw),
 				   true);
 
-		ret = obj_make_dir_buffer(noid_get_allocator(&child->obj->oid),
-					  noid_get_uniq(&child->obj->oid),
-					  noid_get_allocator(&dirver->obj->oid),
-					  noid_get_uniq(&dirver->obj->oid),
-					  &contents);
+		ret = dir_make_buffer(noid_get_allocator(&child->obj->oid),
+				      noid_get_uniq(&child->obj->oid),
+				      noid_get_allocator(&dirver->obj->oid),
+				      noid_get_uniq(&dirver->obj->oid),
+				      &contents);
 		if (ret)
 			goto err;
 
--- a/src/objstore/posix/obj_create.c	Mon Dec 19 19:39:43 2022 -0500
+++ b/src/objstore/posix/obj_create.c	Mon Dec 19 19:44:45 2022 -0500
@@ -163,7 +163,7 @@
 	if (ret)
 		return ret;
 
-	ret = obj_make_dir_buffer(host, uniq, host, uniq, &contents);
+	ret = dir_make_buffer(host, uniq, host, uniq, &contents);
 	if (ret)
 		goto err;