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().
*/
{
struct lu_object *scan;
struct lu_object *top;
+ struct list_head *layers;
int clean;
int result;
* 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;
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);
}