Whamcloud - gitweb
ORNL-23 avoid unnecessary CMD lock contention in LMV
authornasf <yong.fan@whamcloud.com>
Mon, 5 Sep 2011 04:48:00 +0000 (12:48 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Oct 2011 04:51:11 +0000 (00:51 -0400)
There are some redundant lock operations in LMV layer which is only
useful under old CMD mode. We should avoid those lock operations to
reduce unnecessary lock contention.

Change-Id: I2ad1ba728da39ce69b0e521ab3a992dd2b253f2e
Signed-off-by: nasf <yong.fan@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1226
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lmv/lmv_internal.h
lustre/lmv/lmv_obd.c
lustre/lmv/lmv_object.c

index dda0a68..a2c67ad 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
@@ -135,7 +138,7 @@ void lmv_object_free(struct lmv_object *obj);
 struct lmv_object *lmv_object_get(struct lmv_object *obj);
 
 struct lmv_object *lmv_object_find(struct obd_device *obd,
-                                  const struct lu_fid *fid);
+                                   const struct lu_fid *fid);
 
 struct lmv_object *lmv_object_find_lock(struct obd_device *obd,
                                        const struct lu_fid *fid);
@@ -231,12 +234,14 @@ lmv_get_target(struct lmv_obd *lmv, mdsno_t mds)
 static inline struct lmv_tgt_desc *
 lmv_find_target(struct lmv_obd *lmv, const struct lu_fid *fid)
 {
-        mdsno_t mds;
+        mdsno_t mds = 0;
         int rc;
 
-        rc = lmv_fld_lookup(lmv, fid, &mds);
-        if (rc)
-                return ERR_PTR(rc);
+        if (lmv->desc.ld_tgt_count > 1) {
+                rc = lmv_fld_lookup(lmv, fid, &mds);
+                if (rc)
+                        return ERR_PTR(rc);
+        }
 
         return lmv_get_target(lmv, mds);
 }
index e0d896d..d2df3ca 100644 (file)
@@ -3043,7 +3043,7 @@ int lmv_intent_getattr_async(struct obd_export *exp,
         struct obd_device       *obd = exp->exp_obd;
         struct lmv_obd          *lmv = &obd->u.lmv;
         struct lmv_object       *obj;
-        struct lmv_tgt_desc     *tgt;
+        struct lmv_tgt_desc     *tgt = NULL;
         int                      rc;
         int                      sidx;
         ENTRY;
@@ -3052,36 +3052,21 @@ int lmv_intent_getattr_async(struct obd_export *exp,
         if (rc)
                 RETURN(rc);
 
-        if (!fid_is_sane(&op_data->op_fid2)) {
+        if (op_data->op_namelen) {
                 obj = lmv_object_find(obd, &op_data->op_fid1);
-                if (obj && op_data->op_namelen) {
-                        sidx = raw_name2idx(obj->lo_hashtype,
-                                            obj->lo_objcount,
+                if (obj) {
+                        sidx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
                                             (char *)op_data->op_name,
                                             op_data->op_namelen);
                         op_data->op_fid1 = obj->lo_stripes[sidx].ls_fid;
-                        tgt = lmv_get_target(lmv,
-                                             obj->lo_stripes[sidx].ls_mds);
-                        CDEBUG(D_INODE,
-                               "Choose slave dir ("DFID") -> mds #%d\n",
-                               PFID(&op_data->op_fid1), tgt->ltd_idx);
-                } else {
-                        tgt = lmv_find_target(lmv, &op_data->op_fid1);
-                }
-                if (obj)
+                        tgt = lmv_get_target(lmv, obj->lo_stripes[sidx].ls_mds);
                         lmv_object_put(obj);
-        } else {
-                op_data->op_fid1 = op_data->op_fid2;
-                tgt = lmv_find_target(lmv, &op_data->op_fid2);
-                op_data->op_bias = MDS_CROSS_REF;
-                /*
-                 * Unfortunately, we have to lie to MDC/MDS to retrieve
-                 * attributes llite needs.
-                */
-                if (minfo->mi_it.it_op & IT_LOOKUP)
-                        minfo->mi_it.it_op = IT_GETATTR;
+                }
         }
 
+        if (tgt == NULL)
+                tgt = lmv_find_target(lmv, &op_data->op_fid1);
+
         if (IS_ERR(tgt))
                 RETURN(PTR_ERR(tgt));
 
index e5d459b..60631c8 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
@@ -241,15 +244,19 @@ static struct lmv_object *__lmv_object_find(struct obd_device *obd, const struct
         return NULL;
 }
 
-struct lmv_object *lmv_object_find(struct obd_device *obd, 
+struct lmv_object *lmv_object_find(struct obd_device *obd,
                                    const struct lu_fid *fid)
 {
-        struct lmv_object       *obj;
+        struct lmv_obd          *lmv = &obd->u.lmv;
+        struct lmv_object       *obj = NULL;
         ENTRY;
 
-        cfs_spin_lock(&obj_list_lock);
-        obj = __lmv_object_find(obd, fid);
-        cfs_spin_unlock(&obj_list_lock);
+        /* For single MDT case, lmv_object list is always empty. */
+        if (lmv->desc.ld_tgt_count > 1) {
+                cfs_spin_lock(&obj_list_lock);
+                obj = __lmv_object_find(obd, fid);
+                cfs_spin_unlock(&obj_list_lock);
+        }
 
         RETURN(obj);
 }