changeset 1253:40d18d06086a

objstore: add create argument to initobj clone op Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Dec 2022 20:43:16 -0500
parents cf7893023f05
children 77da9822fa93
files src/objstore/include/nomad/objstore_backend.h src/objstore/obj.c src/objstore/posix/vol.c
diffstat 3 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/objstore/include/nomad/objstore_backend.h	Sat Dec 17 13:53:59 2022 -0500
+++ b/src/objstore/include/nomad/objstore_backend.h	Sat Dec 17 20:43:16 2022 -0500
@@ -216,8 +216,12 @@
 	 *
 	 * Typically, the backend also:
 	 *  - sets obj->private
+	 *
+	 * The create argument indicates whether this object is in the
+	 * process of being created (and therefore doesn't yet exist on
+	 * disk).
 	 */
-	int (*initobj)(struct obj *obj);
+	int (*initobj)(struct obj *obj, bool create);
 	/*
 	 * Allocate a new oid.  This is used when the generic code wants to
 	 * allocate a new object (e.g., because of a create(2) call).  This
--- a/src/objstore/obj.c	Sat Dec 17 13:53:59 2022 -0500
+++ b/src/objstore/obj.c	Sat Dec 17 20:43:16 2022 -0500
@@ -243,7 +243,7 @@
 				goto err_obj_new;
 			}
 
-			ret = clone->ops->initobj(obj);
+			ret = clone->ops->initobj(obj, false);
 			if (ret)
 				goto err_obj_new;
 
--- a/src/objstore/posix/vol.c	Sat Dec 17 13:53:59 2022 -0500
+++ b/src/objstore/posix/vol.c	Sat Dec 17 20:43:16 2022 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2018-2020,2022 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
@@ -48,7 +48,7 @@
 	return IS_ERR(ver) ? PTR_ERR(ver) : 0;
 }
 
-static int posix_initobj(struct obj *obj)
+static int posix_initobj(struct obj *obj, bool create)
 {
 	struct posix_obj *pobj;
 	int ret;