From 744fe412fa101609a38f7ccc77efc4f1c540e008 Mon Sep 17 00:00:00 2001 From: Di Wang Date: Wed, 13 Sep 2017 00:53:13 +0000 Subject: [PATCH] LU-9840 lod: add ldo_dir_stripe_loaded Add ldo_dir_stripe_loaded flag to avoid loading stripes mulitple times especcially for non-stripe directory. Change-Id: Ia9360aac9e24706e401184c75fae4ec7f8ec46d9 Signed-off-by: Di Wang Reviewed-on: https://review.whamcloud.com/28962 Tested-by: Jenkins Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Fan Yong --- lustre/lod/lod_internal.h | 4 +++- lustre/lod/lod_lov.c | 14 +++++++++++--- lustre/lod/lod_object.c | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index 7468c76..bfb3660 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -285,7 +285,9 @@ struct lod_object { __u32 ldo_dir_hash_type; /* Is a slave stripe of striped directory? */ __u32 ldo_dir_slave_stripe:1, - ldo_dir_striped:1; + ldo_dir_striped:1, + /* the stripe has been loaded */ + ldo_dir_stripe_loaded:1; /* * default striping is not cached, so this field is * invalid after create, make sure it's used by diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 3fb0f2e..08d5ce7 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -1346,7 +1346,7 @@ static bool lod_striping_loaded(struct lod_object *lo) return true; if (S_ISDIR(lod2lu_obj(lo)->lo_header->loh_attr)) { - if (lo->ldo_stripe != NULL) + if (lo->ldo_stripe != NULL || lo->ldo_dir_stripe_loaded) return true; /* Never load LMV stripe for slaves of striped dir */ @@ -1400,9 +1400,15 @@ int lod_load_striping_locked(const struct lu_env *env, struct lod_object *lo) lo->ldo_comp_cached = 1; } else if (S_ISDIR(lod2lu_obj(lo)->lo_header->loh_attr)) { rc = lod_get_lmv_ea(env, lo); - if (rc < (typeof(rc))sizeof(struct lmv_mds_md_v1)) + if (rc < (typeof(rc))sizeof(struct lmv_mds_md_v1)) { + /* Let's set stripe_loaded to avoid further + * stripe loading especially for non-stripe directory, + * which can hurt performance. (See LU-9840) + */ + if (rc == 0) + lo->ldo_dir_stripe_loaded = 1; GOTO(out, rc = rc > 0 ? -EINVAL : rc); - + } buf->lb_buf = info->lti_ea_store; buf->lb_len = info->lti_ea_store_size; if (rc == sizeof(struct lmv_mds_md_v1)) { @@ -1423,6 +1429,8 @@ int lod_load_striping_locked(const struct lu_env *env, struct lod_object *lo) * let's parse it and create in-core objects for the stripes */ rc = lod_parse_dir_striping(env, lo, buf); + if (rc == 0) + lo->ldo_dir_stripe_loaded = 1; } out: RETURN(rc); diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index cedac80..c008ee7 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -1897,6 +1897,7 @@ static int lod_prep_md_striped_create(const struct lu_env *env, stripe[i] = dto; } + lo->ldo_dir_stripe_loaded = 1; lo->ldo_dir_striped = 1; lo->ldo_stripe = stripe; lo->ldo_dir_stripe_count = i; @@ -5193,6 +5194,7 @@ void lod_object_free_striping(const struct lu_env *env, struct lod_object *lo) OBD_FREE(lo->ldo_stripe, j); lo->ldo_stripe = NULL; lo->ldo_dir_stripes_allocated = 0; + lo->ldo_dir_stripe_loaded = 0; lo->ldo_dir_stripe_count = 0; } else if (lo->ldo_comp_entries != NULL) { for (i = 0; i < lo->ldo_comp_cnt; i++) { -- 1.8.3.1