changeset 853:dc84208232c6

objstore: rename cleanup txn entry method to rollback The code executes when the transaction is aborted, so calling it rollback makes it clearer when it executes. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Dec 2022 14:26:39 -0500
parents 8ccfc441cff6
children 9c372d07da55
files src/objstore/include/nomad/objstore_backend.h src/objstore/obj.c src/objstore/obj_txn.c src/objstore/txn.c
diffstat 4 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/objstore/include/nomad/objstore_backend.h	Sat Dec 17 14:03:31 2022 -0500
+++ b/src/objstore/include/nomad/objstore_backend.h	Sat Dec 17 14:26:39 2022 -0500
@@ -136,7 +136,7 @@
 	bool failed; /* log entry failed */
 
 	int (*perform)(struct txn *txn, struct txn_entry *entry);
-	void (*cleanup)(struct txn *txn, struct txn_entry *entry);
+	void (*rollback)(struct txn *txn, struct txn_entry *entry);
 
 	union {
 		struct {
--- a/src/objstore/obj.c	Sat Dec 17 14:03:31 2022 -0500
+++ b/src/objstore/obj.c	Sat Dec 17 14:26:39 2022 -0500
@@ -547,7 +547,7 @@
 	return 0;
 }
 
-static void __obj_cow_cleanup(struct txn *txn, struct txn_entry *entry)
+static void __obj_cow_rollback(struct txn *txn, struct txn_entry *entry)
 {
 	struct objstore_open_obj_info *open = entry->cow.open;
 	struct objver *old = entry->cow.old;
@@ -605,7 +605,7 @@
 	entry = txn_alloc_entry(txn);
 	entry->op = OP_COW;
 	entry->perform = __obj_cow_perform;
-	entry->cleanup = __obj_cow_cleanup;
+	entry->rollback = __obj_cow_rollback;
 	entry->cow.open = open;
 	entry->cow.old = old;
 	entry->cow.new = new;
--- a/src/objstore/obj_txn.c	Sat Dec 17 14:03:31 2022 -0500
+++ b/src/objstore/obj_txn.c	Sat Dec 17 14:26:39 2022 -0500
@@ -75,7 +75,7 @@
 	return ret;
 }
 
-static void __obj_setattr_cleanup(struct txn *txn, struct txn_entry *entry)
+static void __obj_setattr_rollback(struct txn *txn, struct txn_entry *entry)
 {
 	struct objver *ver = entry->setattr.ver;
 
@@ -108,7 +108,7 @@
 	entry = txn_alloc_entry(txn);
 	entry->op = OP_SETATTR;
 	entry->perform = __obj_setattr_perform;
-	entry->cleanup = __obj_setattr_cleanup;
+	entry->rollback = __obj_setattr_rollback;
 	entry->setattr.ver = ver;
 	entry->setattr.old_attrs = ver->attrs;
 	entry->setattr.changed = valid;
@@ -181,7 +181,7 @@
 	return ret;
 }
 
-static void __obj_write_cleanup(struct txn *txn, struct txn_entry *entry)
+static void __obj_write_rollback(struct txn *txn, struct txn_entry *entry)
 {
 	/* drop the dirty pages */
 	page_inval_range(entry->write.ver, entry->write.pgno,
@@ -207,7 +207,7 @@
 	entry = txn_alloc_entry(txn);
 	entry->op = OP_WRITE;
 	entry->perform = __obj_write_perform;
-	entry->cleanup = __obj_write_cleanup;
+	entry->rollback = __obj_write_rollback;
 	entry->write.ver = ver;
 	entry->write.pgno = offset / PAGE_SIZE;
 	entry->write.pgcnt = p2roundup(len, PAGE_SIZE) / PAGE_SIZE;
--- a/src/objstore/txn.c	Sat Dec 17 14:03:31 2022 -0500
+++ b/src/objstore/txn.c	Sat Dec 17 14:26:39 2022 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2019-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
@@ -120,7 +120,7 @@
 		txn->entries[i].logged = false;
 		txn->entries[i].failed = false;
 		txn->entries[i].perform = NULL;
-		txn->entries[i].cleanup = NULL;
+		txn->entries[i].rollback = NULL;
 	}
 
 	return clone->ops->txn_begin(txn);
@@ -143,8 +143,8 @@
 				case OP_CREATE:
 				case OP_SETATTR:
 				case OP_WRITE:
-					if (entry->cleanup)
-						entry->cleanup(txn, entry);
+					if (entry->rollback)
+						entry->rollback(txn, entry);
 					break;
 			}
 		}