Whamcloud - gitweb
b=19706 porting patch for master.
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status.c
index 2a5d742..a6981db 100644 (file)
@@ -92,9 +92,9 @@ struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
 {
         struct proc_dir_entry *temp;
 
-        LPROCFS_ENTRY();
+        LPROCFS_SRCH_ENTRY();
         temp = __lprocfs_srch(head, name);
-        LPROCFS_EXIT();
+        LPROCFS_SRCH_EXIT();
         return temp;
 }
 
@@ -401,9 +401,23 @@ void lprocfs_remove(struct proc_dir_entry **rooth)
                          "0x%p  %s/%s len %d\n", rm_entry, temp->name,
                          rm_entry->name, (int)strlen(rm_entry->name));
 
+#ifdef HAVE_PROCFS_USERS
+                /* if procfs uses user count to synchronize deletion of
+                 * proc entry, there is no protection for rm_entry->data,
+                 * then lprocfs_fops_read and lprocfs_fops_write maybe
+                 * call proc_dir_entry->read_proc (or write_proc) with
+                 * proc_dir_entry->data == NULL, then cause kernel Oops.
+                 * see bug19706 for detailed information */
+
+                /* procfs won't free rm_entry->data if it isn't a LINK,
+                 * and Lustre won't use rm_entry->data if it is a LINK */
+                if (S_ISLNK(rm_entry->mode))
+                        rm_entry->data = NULL;
+#else
                 /* Now, the rm_entry->deleted flags is protected
                  * by _lprocfs_lock. */
                 rm_entry->data = NULL;
+#endif
                 remove_proc_entry(rm_entry->name, temp);
                 if (temp == parent)
                         break;