[PATCH 1/2] Add a 'cleanup' function to objhash object operations

Dan Smith danms at us.ibm.com
Tue Sep 15 09:52:10 PDT 2009


This patch adds a 'cleanup' function to the object operations structure,
which is called during objhash teardown before the final reference is
dropped.  It provides a way to perform some object cleanup when checkpoint
or restart operation is finished, in scenarios where the final reference
count cannot be anticipated.

Signed-off-by: Dan Smith <danms at us.ibm.com>
---
 checkpoint/objhash.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c
index a410346..9750483 100644
--- a/checkpoint/objhash.c
+++ b/checkpoint/objhash.c
@@ -34,6 +34,7 @@ struct ckpt_obj_ops {
 	int (*ref_users)(void *ptr);
 	int (*checkpoint)(struct ckpt_ctx *ctx, void *ptr);
 	void *(*restore)(struct ckpt_ctx *ctx);
+	void (*cleanup)(void *ptr);
 };
 
 struct ckpt_obj {
@@ -399,6 +400,8 @@ static void obj_hash_clear(struct ckpt_obj_hash *obj_hash)
 
 	for (i = 0; i < CKPT_OBJ_HASH_TOTAL; i++) {
 		hlist_for_each_entry_safe(obj, n, t, &h[i], hash) {
+			if (obj->ops->cleanup)
+				obj->ops->cleanup(obj->ptr);
 			obj->ops->ref_drop(obj->ptr);
 			kfree(obj);
 		}
-- 
1.6.2.5



More information about the Containers mailing list