Whamcloud - gitweb
LU-9840 lod: add ldo_dir_stripe_loaded 62/28962/3
authorDi Wang <di.wang@intel.com>
Wed, 13 Sep 2017 00:53:13 +0000 (00:53 +0000)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 21 Sep 2017 06:13:59 +0000 (06:13 +0000)
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 <di.wang@intel.com>
Reviewed-on: https://review.whamcloud.com/28962
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
lustre/lod/lod_internal.h
lustre/lod/lod_lov.c
lustre/lod/lod_object.c

index 7468c76..bfb3660 100644 (file)
@@ -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
index 3fb0f2e..08d5ce7 100644 (file)
@@ -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);
index cedac80..c008ee7 100644 (file)
@@ -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++) {