From 2e62c8ecafc93ffb87ebba924ee5b8f61e4ad157 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 29 Mar 2013 11:15:16 -0500 Subject: [PATCH] LU-3059 lu: shrink lu_object by 8 bytes on x86_64 Remove the lo_depth member from struct lu_object. This field is never set and only read in lu_object_print(). Remove the lo_flags member. This field was only used in lu_object_alloc() and can be replaced with an on-stack mask to keep trace of which layers have been allocated. Signed-off-by: John L. Hammond Change-Id: I998cfda0234f4c418227c9ba640850a78ca7893e Reviewed-on: http://review.whamcloud.com/5890 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/lu_object.h | 19 -------- lustre/obdclass/lu_object.c | 104 ++++++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 67 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 85dcbfa..bd0e58d 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -398,17 +398,6 @@ static inline int lu_device_is_md(const struct lu_device *d) } /** - * Flags for the object layers. - */ -enum lu_object_flags { - /** - * this flags is set if lu_object_operations::loo_object_init() has - * been called for this layer. Used by lu_object_alloc(). - */ - LU_OBJECT_ALLOCATED = (1 << 0) -}; - -/** * Common object attributes. */ struct lu_attr { @@ -485,14 +474,6 @@ struct lu_object { * Linkage into list of all layers. */ cfs_list_t lo_linkage; - /** - * Depth. Top level layer depth is 0. - */ - int lo_depth; - /** - * Flags from enum lu_object_flags. - */ - __u32 lo_flags; /** * Link to the device, for debugging. */ diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index ba45a0d..cb2da24 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -195,16 +195,18 @@ EXPORT_SYMBOL(lu_object_unhash); * struct lu_device_operations definition. */ static struct lu_object *lu_object_alloc(const struct lu_env *env, - struct lu_device *dev, - const struct lu_fid *f, - const struct lu_object_conf *conf) -{ - struct lu_object *scan; - struct lu_object *top; - cfs_list_t *layers; - int clean; - int result; - ENTRY; + struct lu_device *dev, + const struct lu_fid *f, + const struct lu_object_conf *conf) +{ + struct lu_object *scan; + struct lu_object *top; + cfs_list_t *layers; + unsigned int init_mask = 0; + unsigned int init_flag; + int clean; + int result; + ENTRY; /* * Create top-level object slice. This will also create @@ -221,25 +223,29 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, */ 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; - cfs_list_for_each_entry(scan, layers, lo_linkage) { - if (scan->lo_flags & LU_OBJECT_ALLOCATED) - continue; - clean = 0; - scan->lo_header = top->lo_header; - result = scan->lo_ops->loo_object_init(env, scan, conf); - if (result != 0) { - lu_object_free(env, top); - RETURN(ERR_PTR(result)); - } - scan->lo_flags |= LU_OBJECT_ALLOCATED; - } - } while (!clean); + + do { + /* + * Call ->loo_object_init() repeatedly, until no more new + * object slices are created. + */ + clean = 1; + init_flag = 1; + cfs_list_for_each_entry(scan, layers, lo_linkage) { + if (init_mask & init_flag) + goto next; + clean = 0; + scan->lo_header = top->lo_header; + result = scan->lo_ops->loo_object_init(env, scan, conf); + if (result != 0) { + lu_object_free(env, top); + RETURN(ERR_PTR(result)); + } + init_mask |= init_flag; +next: + init_flag <<= 1; + } + } while (!clean); cfs_list_for_each_entry_reverse(scan, layers, lo_linkage) { if (scan->lo_ops->loo_object_start != NULL) { @@ -486,28 +492,30 @@ EXPORT_SYMBOL(lu_object_header_print); * Print human readable representation of the \a o to the \a printer. */ void lu_object_print(const struct lu_env *env, void *cookie, - lu_printer_t printer, const struct lu_object *o) + lu_printer_t printer, const struct lu_object *o) { - static const char ruler[] = "........................................"; - struct lu_object_header *top; - int depth; + static const char ruler[] = "........................................"; + struct lu_object_header *top; + int depth = 4; - top = o->lo_header; - lu_object_header_print(env, cookie, printer, top); - (*printer)(env, cookie, "{ \n"); - cfs_list_for_each_entry(o, &top->loh_layers, lo_linkage) { - depth = o->lo_depth + 4; + top = o->lo_header; + lu_object_header_print(env, cookie, printer, top); + (*printer)(env, cookie, "{\n"); - /* - * print `.' \a depth times followed by type name and address - */ - (*printer)(env, cookie, "%*.*s%s@%p", depth, depth, ruler, - o->lo_dev->ld_type->ldt_name, o); - if (o->lo_ops->loo_object_print != NULL) - o->lo_ops->loo_object_print(env, cookie, printer, o); - (*printer)(env, cookie, "\n"); - } - (*printer)(env, cookie, "} header@%p\n", top); + cfs_list_for_each_entry(o, &top->loh_layers, lo_linkage) { + /* + * print `.' \a depth times followed by type name and address + */ + (*printer)(env, cookie, "%*.*s%s@%p", depth, depth, ruler, + o->lo_dev->ld_type->ldt_name, o); + + if (o->lo_ops->loo_object_print != NULL) + (*o->lo_ops->loo_object_print)(env, cookie, printer, o); + + (*printer)(env, cookie, "\n"); + } + + (*printer)(env, cookie, "} header@%p\n", top); } EXPORT_SYMBOL(lu_object_print); -- 1.8.3.1