From 43195560a3310b6778b0457a24b1573d23391e80 Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 22 Jun 2006 21:54:22 +0000 Subject: [PATCH] lu_object_put(): fix defect: passing wrong object to lu_object_free() --- lustre/obdclass/lu_object.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 9844e06..f4aafe07 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -52,10 +52,12 @@ void lu_object_put(const struct lu_context *ctxt, struct lu_object *o) { struct lu_object_header *top; struct lu_site *site; + struct lu_object *orig; int kill_it; top = o->lo_header; site = o->lo_dev->ld_site; + orig = o; kill_it = 0; spin_lock(&site->ls_guard); if (-- top->loh_ref == 0) { @@ -93,7 +95,7 @@ void lu_object_put(const struct lu_context *ctxt, struct lu_object *o) * Object was already removed from hash and lru above, can * kill it. */ - lu_object_free(ctxt, o); + lu_object_free(ctxt, orig); } EXPORT_SYMBOL(lu_object_put); @@ -248,6 +250,22 @@ int lu_object_print(const struct lu_context *ctx, } EXPORT_SYMBOL(lu_object_print); +/* + * Check object consistency. + */ +int lu_object_invariant(const struct lu_object *o) +{ + struct lu_object_header *top; + + top = o->lo_header; + list_for_each_entry(o, &top->loh_layers, lo_linkage) { + if (o->lo_ops->loo_object_invariant != NULL && + !o->lo_ops->loo_object_invariant(o)) + return 0; + } + return 1; +} +EXPORT_SYMBOL(lu_object_invariant); static struct lu_object *htable_lookup(struct lu_site *s, const struct hlist_head *bucket, -- 1.8.3.1