From: nikita Date: Wed, 16 Aug 2006 15:40:56 +0000 (+0000) Subject: lu: add ->loo_object_start() method called late during object allocation. It can... X-Git-Tag: v1_8_0_110~486^2~1159 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=014181770731416d3f31c073146cee00cac2e900;p=fs%2Flustre-release.git lu: add ->loo_object_start() method called late during object allocation. It can be used to perform initialization depending on lower layers --- diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 447738a..3c1103b 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -169,6 +169,13 @@ struct lu_object_operations { int (*loo_object_init)(const struct lu_context *ctx, struct lu_object *o); /* + * Called (in top-to-bottom order) during object allocation after all + * layers were allocated and initialized. Can be used to perform + * initialization depending on lower layers. + */ + int (*loo_object_start)(const struct lu_context *ctx, + struct lu_object *o); + /* * Called before ->loo_object_free() to signal that object is being * destroyed. Dual to ->loo_object_init(). */ diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index fa60c02..862fe2b 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -111,6 +111,7 @@ static struct lu_object *lu_object_alloc(const struct lu_context *ctxt, { struct lu_object *scan; struct lu_object *top; + struct list_head *layers; int clean; int result; @@ -128,14 +129,14 @@ static struct lu_object *lu_object_alloc(const struct lu_context *ctxt, * after this point. */ top->lo_header->loh_fid = *f; + layers = &top->lo_header->loh_layers; do { /* * Call ->loo_object_init() repeatedly, until no more new * object slices are created. */ clean = 1; - list_for_each_entry(scan, - &top->lo_header->loh_layers, lo_linkage) { + list_for_each_entry(scan, layers, lo_linkage) { if (scan->lo_flags & LU_OBJECT_ALLOCATED) continue; clean = 0; @@ -148,6 +149,17 @@ static struct lu_object *lu_object_alloc(const struct lu_context *ctxt, scan->lo_flags |= LU_OBJECT_ALLOCATED; } } while (!clean); + + list_for_each_entry_reverse(scan, layers, lo_linkage) { + if (scan->lo_ops->loo_object_start != NULL) { + result = scan->lo_ops->loo_object_start(ctxt, scan); + if (result != 0) { + lu_object_free(ctxt, top); + RETURN(ERR_PTR(result)); + } + } + } + s->ls_stats.s_created ++; RETURN(top); }