Whamcloud - gitweb
LU-5130 lod: Do not merge attr for striped directory 41/10841/6
authorWang Di <di.wang@intel.com>
Thu, 26 Jun 2014 06:49:27 +0000 (23:49 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 8 Jul 2014 15:29:33 +0000 (15:29 +0000)
Does not need to merge attributes in lod_attr_get(),
because client will merge attributes itself for striped
directory (see lmv_merge_attr()), and also there are no
logic in MDD will reply on directory nlink/size/time.

Besides lod_attr_get is in the path of object initialization,
mdd_object_start()->mdd_la_get()->lod_attr_get(), if it tries
to get attribute from other MDTs, and if other MDTs are not
ready yet, it will cause unnecessary failures for object
initialization.

Change-Id: I56395a40fcd82142f99228a0776b5b7338c633ac
Signed-off-by: Wang Di <di.wang@intel.com>
Reviewed-on: http://review.whamcloud.com/10841
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c

index 25cc60d..d6dc2e5 100644 (file)
@@ -757,62 +757,11 @@ static int lod_attr_get(const struct lu_env *env,
                        struct lu_attr *attr,
                        struct lustre_capa *capa)
 {
-       struct lod_object *lo = lod_dt_obj(dt);
-       int i;
-       int rc;
-       ENTRY;
-
-       rc = dt_attr_get(env, dt_object_child(dt), attr, capa);
-       if (!S_ISDIR(dt->do_lu.lo_header->loh_attr) || rc != 0)
-               RETURN(rc);
-
-       rc = lod_load_striping_locked(env, lo);
-       if (rc)
-               RETURN(rc);
-
-       if (lo->ldo_stripenr == 0)
-               RETURN(rc);
-
-       attr->la_nlink = 2;
-       attr->la_size = 0;
-       for (i = 0; i < lo->ldo_stripenr; i++) {
-               struct lu_attr *sub_attr = &lod_env_info(env)->lti_attr;
-
-               LASSERT(lo->ldo_stripe[i]);
-               if (dt_object_exists(lo->ldo_stripe[i]))
-                       continue;
-
-               rc = dt_attr_get(env, lo->ldo_stripe[i], sub_attr, capa);
-               if (rc != 0)
-                       break;
-
-               /* -2 for . and .. on each stripe */
-               if (sub_attr->la_valid & LA_NLINK && attr->la_valid & LA_NLINK)
-                       attr->la_nlink += sub_attr->la_nlink - 2;
-               if (sub_attr->la_valid & LA_SIZE && attr->la_valid & LA_SIZE)
-                       attr->la_size += sub_attr->la_size;
-
-               if (sub_attr->la_valid & LA_ATIME &&
-                   attr->la_valid & LA_ATIME &&
-                   attr->la_atime < sub_attr->la_atime)
-                       attr->la_atime = sub_attr->la_atime;
-
-               if (sub_attr->la_valid & LA_CTIME &&
-                   attr->la_valid & LA_CTIME &&
-                   attr->la_ctime < sub_attr->la_ctime)
-                       attr->la_ctime = sub_attr->la_ctime;
-
-               if (sub_attr->la_valid & LA_MTIME &&
-                   attr->la_valid & LA_MTIME &&
-                   attr->la_mtime < sub_attr->la_mtime)
-                       attr->la_mtime = sub_attr->la_mtime;
-       }
-
-       CDEBUG(D_INFO, DFID" stripe_count %d nlink %u size "LPU64"\n",
-              PFID(lu_object_fid(&dt->do_lu)), lo->ldo_stripenr,
-              attr->la_nlink, attr->la_size);
-
-       RETURN(rc);
+       /* Note: for striped directory, client will merge attributes
+        * from all of the sub-stripes see lmv_merge_attr(), and there
+        * no MDD logic depend on directory nlink/size/time, so we can
+        * always use master inode nlink and size for now. */
+       return dt_attr_get(env, dt_object_child(dt), attr, capa);
 }
 
 /**