From: nasf Date: Mon, 5 Sep 2011 04:48:00 +0000 (+0800) Subject: ORNL-23 avoid unnecessary CMD lock contention in LMV X-Git-Tag: 2.1.51~16 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=277b0ac0a9aa0cc3e78862c9b10a4f88e77c22d0;p=fs%2Flustre-release.git ORNL-23 avoid unnecessary CMD lock contention in LMV 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 Reviewed-on: http://review.whamcloud.com/1226 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/lmv/lmv_internal.h b/lustre/lmv/lmv_internal.h index dda0a68..a2c67ad 100644 --- a/lustre/lmv/lmv_internal.h +++ b/lustre/lmv/lmv_internal.h @@ -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); } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index e0d896d..d2df3ca 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -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)); diff --git a/lustre/lmv/lmv_object.c b/lustre/lmv/lmv_object.c index e5d459b..60631c8 100644 --- a/lustre/lmv/lmv_object.c +++ b/lustre/lmv/lmv_object.c @@ -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); }