From 7b62fa0c4b6577a2e702e972f71afbb5f0eb9556 Mon Sep 17 00:00:00 2001 From: adilger Date: Thu, 4 Mar 2004 08:10:13 +0000 Subject: [PATCH] Don't call the completion AST if we can already match this lock. We could fix some callers of obd_match() and ldlm_lock_match() to be a bit more efficient, but we won't right now. r=phil --- lustre/ldlm/ldlm_lock.c | 30 +++++++++++++++++++----------- lustre/liblustre/rw.c | 5 +++-- lustre/liblustre/super.c | 1 + 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 1234786..eb3c50c 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -676,22 +676,30 @@ int ldlm_lock_match(struct ldlm_namespace *ns, int flags, l_unlock(&ns->ns_lock); if (lock) { - struct l_wait_info lwi; ldlm_lock2handle(lock, lockh); - if (lock->l_completion_ast) - lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC, - NULL); + if (!(lock->l_flags & LDLM_FL_CAN_MATCH)) { + struct l_wait_info lwi; + if (lock->l_completion_ast) + lock->l_completion_ast(lock, + LDLM_FL_WAIT_NOREPROC, + NULL); - lwi = LWI_TIMEOUT_INTR(obd_timeout * HZ, NULL, NULL, NULL); + lwi = LWI_TIMEOUT_INTR(obd_timeout*HZ, NULL,NULL,NULL); - /* XXX FIXME see comment about CAN_MATCH in lustre_dlm.h */ - l_wait_event(lock->l_waitq, - (lock->l_flags & LDLM_FL_CAN_MATCH), &lwi); + /* XXX FIXME see comment on CAN_MATCH in lustre_dlm.h */ + l_wait_event(lock->l_waitq, + (lock->l_flags & LDLM_FL_CAN_MATCH), &lwi); + } } if (rc) - LDLM_DEBUG(lock, "matched"); - else - LDLM_DEBUG_NOLOCK("not matched"); + LDLM_DEBUG(lock, "matched ("LPU64" "LPU64")", + type == LDLM_PLAIN ? res_id->name[2] : + policy->l_extent.start, + type == LDLM_PLAIN ? res_id->name[3] : + policy->l_extent.end); + else if (!(flags & LDLM_FL_TEST_LOCK)) /* less verbose for test-only */ + LDLM_DEBUG_NOLOCK("not matched type %u mode %u res "LPU64"/"LPU64, + type, mode, res_id->name[0], res_id->name[1]); if (old_lock) LDLM_LOCK_PUT(old_lock); diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index 307dd46..8e5f59f 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -153,17 +153,18 @@ int llu_extent_lock(struct ll_file_data *fd, struct inode *inode, size_lock.end = OBD_OBJECT_EOF; /* XXX I bet we should be checking the lock ignore flags.. */ + /* FIXME use LDLM_FL_TEST_LOCK instead */ flags = LDLM_FL_CBPENDING | LDLM_FL_BLOCK_GRANTED; matched = obd_match(exp, lsm, LDLM_EXTENT, &size_lock, sizeof(size_lock), LCK_PR, &flags, inode, &match_lockh); - /* hey, alright, we hold a size lock that covers the size we + /* hey, alright, we hold a size lock that covers the size we * just found, its not going to change for a while.. */ if (matched == 1) { set_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags); obd_cancel(exp, lsm, LCK_PR, &match_lockh); - } + } RETURN(0); } diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 1e6a230..28b9e66 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -355,6 +355,7 @@ static int llu_have_md_lock(struct inode *inode) CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]); + /* FIXME use LDLM_FL_TEST_LOCK instead */ flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING; if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_PLAIN, NULL, 0, LCK_PR, &lockh)) { -- 1.8.3.1