From def97b46e0f904da28d50f1ee5ba91d4dbfb4d84 Mon Sep 17 00:00:00 2001
From: bobijam <bobijam>
Date: Tue, 5 Aug 2008 04:16:05 +0000
Subject: [PATCH] Branch HEAD b=16266 i=h.huang, shadow

add missing LPROCFS_ENTRY/EXIT markers in HEAD.
---
 lustre/include/lprocfs_status.h  |  6 ++++++
 lustre/obdclass/lprocfs_status.c | 10 +++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h
index 7df7596d95..7af1f351eb 100644
--- a/lustre/include/lprocfs_status.h
+++ b/lustre/include/lprocfs_status.h
@@ -542,6 +542,12 @@ extern struct rw_semaphore _lprocfs_lock;
                 return -ENODEV;                 \
         }                                       \
 } while(0)
+#define LPROCFS_WRITE_ENTRY()     do {  \
+        down_write(&_lprocfs_lock);     \
+} while(0)
+#define LPROCFS_WRITE_EXIT()      do {  \
+        up_write(&_lprocfs_lock);       \
+} while(0)
 
 /* You must use these macros when you want to refer to 
  * the import in a client obd_device for a lprocfs entry */
diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c
index bb4ab7f919..9b89a6b530 100644
--- a/lustre/obdclass/lprocfs_status.c
+++ b/lustre/obdclass/lprocfs_status.c
@@ -73,14 +73,18 @@ struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
 
         if (head == NULL)
                 return NULL;
+        LPROCFS_ENTRY();
 
         temp = head->subdir;
         while (temp != NULL) {
-                if (strcmp(temp->name, name) == 0)
+                if (strcmp(temp->name, name) == 0) {
+                        LPROCFS_EXIT();
                         return temp;
+                }
 
                 temp = temp->next;
         }
+        LPROCFS_EXIT();
         return NULL;
 }
 
@@ -324,6 +328,7 @@ void lprocfs_remove(struct proc_dir_entry **rooth)
 
         parent = root->parent;
         LASSERT(parent != NULL);
+        LPROCFS_WRITE_ENTRY(); /* search vs remove race */
 
         while (1) {
                 while (temp->subdir != NULL)
@@ -340,13 +345,12 @@ void lprocfs_remove(struct proc_dir_entry **rooth)
 
                 /* Now, the rm_entry->deleted flags is protected 
                  * by _lprocfs_lock. */
-                down_write(&_lprocfs_lock);
                 rm_entry->data = NULL;
                 remove_proc_entry(rm_entry->name, temp);
-                up_write(&_lprocfs_lock);
                 if (temp == parent)
                         break;
         }
+        LPROCFS_WRITE_EXIT();
 }
 
 void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
-- 
GitLab