Whamcloud - gitweb
Branch HEAD
authorbobijam <bobijam>
Tue, 5 Aug 2008 04:16:05 +0000 (04:16 +0000)
committerbobijam <bobijam>
Tue, 5 Aug 2008 04:16:05 +0000 (04:16 +0000)
b=16266
i=h.huang, shadow

add missing LPROCFS_ENTRY/EXIT markers in HEAD.

lustre/include/lprocfs_status.h
lustre/obdclass/lprocfs_status.c

index 7df7596..7af1f35 100644 (file)
@@ -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 */
index bb4ab7f..9b89a6b 100644 (file)
@@ -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)