diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 7df7596d95adf3fae89806dd1678a17bc60655ce..7af1f351ebb4a75dfec164e1e5c38662b2c613f0 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 bb4ab7f9191d4862c49cb0f47fa5d6729a941f88..9b89a6b5308fad5ca0121010eb61703accc2c533 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)