From 6474200f9082d0c2ceadb225578695e7e54d8dec Mon Sep 17 00:00:00 2001
From: vitaly <vitaly>
Date: Tue, 16 Oct 2007 20:19:29 +0000
Subject: [PATCH] Branch HEAD b=13693 i=adilger i=green

do not forget to cancel locally locks with invalid import;
do not cancel locks in ldlm_lock_list_put() when 0 locks are to be canceled;
---
 lustre/include/lustre_dlm.h | 5 +++--
 lustre/ldlm/ldlm_request.c  | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h
index 4680fabd12..49dcd79bb8 100644
--- a/lustre/include/lustre_dlm.h
+++ b/lustre/include/lustre_dlm.h
@@ -609,11 +609,12 @@ do {                                            \
         struct ldlm_lock *_lock, *_next;                        \
         int c = count;                                          \
         list_for_each_entry_safe(_lock, _next, head, member) {  \
+                if (c-- == 0)                                   \
+                        break;                                  \
                 list_del_init(&_lock->member);                  \
                 LDLM_LOCK_PUT(_lock);                           \
-                if (--c == 0)                                   \
-                        break;                                  \
         }                                                       \
+        LASSERT(c <= 0);                                        \
 })
 
 struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index 6d4f6721c8..b5ec3de195 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -891,7 +891,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels,
                 if (imp == NULL || imp->imp_invalid) {
                         CDEBUG(D_HA, "skipping cancel on invalid import %p\n",
                                imp);
-                        break;
+                        RETURN(count);
                 }
 
                 req = ptlrpc_prep_req(imp, LUSTRE_DLM_VERSION, LDLM_CANCEL, 2,
-- 
GitLab