From 71d0ea0dbc93203945a42c3bba8de429a3dd6d02 Mon Sep 17 00:00:00 2001
From: green <green>
Date: Sun, 16 Dec 2007 04:18:25 +0000
Subject: [PATCH] b=14379 r=adilger,vitaly

Properly find out duplicate locks when comparing newly receiwed server locks.
mds_open cannot use accmode because it is affected by owneroverride flag
---
 lustre/ChangeLog        | 9 +++++++++
 lustre/ldlm/ldlm_lock.c | 2 +-
 lustre/mds/mds_open.c   | 4 ++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 96b7a52406..2da7baedc7 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -156,6 +156,15 @@ Details    : Directly associate cached pages to lock that protect those pages,
              this allows us to quickly find what pages to write and remove
 	     once lock callback is received.
 
+Severity   : normal
+Bugzilla   : 14379
+Description: Too many locks accumulating on client during NFS usage
+Details    : mds_open improperly used accmode to find out access mode to a
+             file. Also mdc_intent_lock logic to find out if we already have
+	     lock similar to just received was flawed since introduction of
+	     skiplists - locks are now added to the front of the granted
+	     queue.
+
 --------------------------------------------------------------------------------
 
 2007-12-07         Cluster File Systems, Inc. <info@clusterfs.com>
diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c
index a9996267de..977ff9ab0c 100644
--- a/lustre/ldlm/ldlm_lock.c
+++ b/lustre/ldlm/ldlm_lock.c
@@ -919,7 +919,7 @@ static struct ldlm_lock *search_queue(struct list_head *queue,
                 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
 
                 if (lock == old_lock)
-                        break;
+                        continue;
 
                 /* llite sometimes wants to match locks that will be
                  * canceled when their users drop, but we allow it to match
diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c
index 7c50196f35..d038f111c3 100644
--- a/lustre/mds/mds_open.c
+++ b/lustre/mds/mds_open.c
@@ -1151,9 +1151,9 @@ found_child:
 
         /* We cannot use acc_mode here, because it is zeroed in case of
            creating a file, so we get wrong lockmode */
-        if (accmode(dchild->d_inode, rec->ur_flags) & MAY_WRITE)
+        if (rec->ur_flags & FMODE_WRITE)
                 child_mode = LCK_CW;
-        else if (accmode(dchild->d_inode, rec->ur_flags) & MAY_EXEC)
+        else if (rec->ur_flags & MDS_FMODE_EXEC)
                 child_mode = LCK_PR;
         else
                 child_mode = LCK_CR;
-- 
GitLab