From 0fdbc45f7984995b636107bfa5ff41e28b7c446e Mon Sep 17 00:00:00 2001
From: zhanghc <zhanghc>
Date: Mon, 27 Oct 2008 01:14:36 +0000
Subject: [PATCH] Branch b1_6 handle "Unexpected: can't find mdc_open_data, but
 the close succeed, Please tell <http://bugzilla.lustre.org/>." printed in
 mdc_close in mdc_request.c b=17089 i=johann

---
 lustre/mds/handler.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 1a6ba925dc..7d4df5f4b7 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -424,6 +424,8 @@ static int mds_destroy_export(struct obd_export *export)
         struct lov_mds_md *lmm;
         __u32 lmm_sz, cookie_sz;
         struct llog_cookie *logcookies;
+        struct list_head closing_list;
+        struct mds_file_data *mfd, *n;
         int rc = 0;
         ENTRY;
 
@@ -454,19 +456,23 @@ static int mds_destroy_export(struct obd_export *export)
                 GOTO(out, rc = -ENOMEM);
         }
 
+        CFS_INIT_LIST_HEAD(&closing_list);
         spin_lock(&med->med_open_lock);
         while (!list_empty(&med->med_open_head)) {
                 struct list_head *tmp = med->med_open_head.next;
-                struct mds_file_data *mfd =
-                        list_entry(tmp, struct mds_file_data, mfd_list);
-                int lmm_size = lmm_sz;
-                umode_t mode = mfd->mfd_dentry->d_inode->i_mode;
-                __u64 valid = 0;
+                mfd = list_entry(tmp, struct mds_file_data, mfd_list);
 
                 /* Remove mfd handle so it can't be found again.
                  * We are consuming the mfd_list reference here. */
                 mds_mfd_unlink(mfd, 0);
-                spin_unlock(&med->med_open_lock);
+                list_add_tail(&mfd->mfd_list, &closing_list);
+        }
+        spin_unlock(&med->med_open_lock);
+
+        list_for_each_entry_safe(mfd, n, &closing_list, mfd_list) {
+                int lmm_size = lmm_sz;
+                umode_t mode = mfd->mfd_dentry->d_inode->i_mode;
+                __u64 valid = 0;
 
                 /* If you change this message, be sure to update
                  * replay_single:test_46 */
@@ -506,7 +512,6 @@ static int mds_destroy_export(struct obd_export *export)
                         valid &= ~OBD_MD_FLCOOKIE;
                 }
 
-                spin_lock(&med->med_open_lock);
         }
 
         OBD_FREE(logcookies, cookie_sz);
-- 
GitLab