From 999a8f1f0f9ab1a47843b4fa24ff88e5afd894b2 Mon Sep 17 00:00:00 2001 From: nasf Date: Mon, 7 Mar 2011 23:23:42 +0800 Subject: [PATCH] ORNL-2 Enable OBD_CONNECT_ATTRFID supporting on lustre-2.x To drop redundant MDS-side RPC for root object revalidation when stats each item for traversing directory based on absolute path. Signed-off-by: nasf Change-Id: I5f7c7755b4142ac1f23c66517e5919c1398e15b8 Reviewed-on: http://review.whamcloud.com/302 Tested-by: Hudson Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 2 +- lustre/llite/file.c | 3 +++ lustre/mdt/mdt_handler.c | 37 ++++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 0ea1fdb..cfbcbe0 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1082,7 +1082,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); #define MDT_CONNECT_SUPPORTED (OBD_CONNECT_RDONLY | OBD_CONNECT_VERSION | \ OBD_CONNECT_ACL | OBD_CONNECT_XATTR | \ OBD_CONNECT_IBITS | OBD_CONNECT_JOIN | \ - OBD_CONNECT_NODEVOH |/* OBD_CONNECT_ATTRFID |*/\ + OBD_CONNECT_NODEVOH | OBD_CONNECT_ATTRFID | \ OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \ OBD_CONNECT_RMT_CLIENT | \ OBD_CONNECT_RMT_CLIENT_FORCE | \ diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 7107e81..d2c7bb2 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2168,6 +2168,9 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, exp = ll_i2mdexp(inode); + /* XXX: Enable OBD_CONNECT_ATTRFID to reduce unnecessary getattr RPC. + * But under CMD case, it caused some lock issues, should be fixed + * with new CMD ibits lock. See bug 12718 */ if (exp->exp_connect_flags & OBD_CONNECT_ATTRFID) { struct lookup_intent oit = { .it_op = IT_GETATTR }; struct md_op_data *op_data; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 9ec7267..c411615 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -984,10 +984,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, LDLM_LOCK_PUT(lock); rc = 0; } else { - struct md_attr *ma; relock: - ma = &info->mti_attr; - OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_RESEND, obd_timeout*2); mdt_lock_handle_init(lhc); mdt_lock_reg_init(lhc, LCK_PR); @@ -999,21 +996,27 @@ relock: GOTO(out_child, rc = -ESTALE); } - ma->ma_valid = 0; - ma->ma_need = MA_INODE; - rc = mo_attr_get(info->mti_env, next, ma); - if (unlikely(rc != 0)) - GOTO(out_child, rc); + if (!(child_bits & MDS_INODELOCK_UPDATE)) { + struct md_attr *ma = &info->mti_attr; - /* If the file has not been changed for some time, we return - * not only a LOOKUP lock, but also an UPDATE lock and this - * might save us RPC on later STAT. For directories, it also - * let negative dentry starts working for this dir. */ - if (ma->ma_valid & MA_INODE && - ma->ma_attr.la_valid & LA_CTIME && - info->mti_mdt->mdt_namespace->ns_ctime_age_limit + - ma->ma_attr.la_ctime < cfs_time_current_sec()) - child_bits |= MDS_INODELOCK_UPDATE; + ma->ma_valid = 0; + ma->ma_need = MA_INODE; + rc = mo_attr_get(info->mti_env, + mdt_object_child(child), ma); + if (unlikely(rc != 0)) + GOTO(out_child, rc); + + /* If the file has not been changed for some time, we + * return not only a LOOKUP lock, but also an UPDATE + * lock and this might save us RPC on later STAT. For + * directories, it also let negative dentry starts + * working for this dir. */ + if (ma->ma_valid & MA_INODE && + ma->ma_attr.la_valid & LA_CTIME && + info->mti_mdt->mdt_namespace->ns_ctime_age_limit + + ma->ma_attr.la_ctime < cfs_time_current_sec()) + child_bits |= MDS_INODELOCK_UPDATE; + } rc = mdt_object_lock(info, child, lhc, child_bits, MDT_CROSS_LOCK); -- 1.8.3.1