Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1653958
| From | Jia-Ju Bai <baijiaju1990@163.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_percpt_lock and cfs_percpt_unlock |
| Date | 2017-05-31 10:20 +0200 |
| Message-ID | <tN71f-2f2-17@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
The driver may sleep under a spin lock, and the function call path is:
cfs_percpt_lock/cfs_percpt_unlock (acquire the lock by spin_lock)
LASSERT
lbug_with_loc
libcfs_debug_dumplog
schedule and kthread_run --> may sleep
To fix it, all "LASSERT" is placed out of the spin_lock and spin_unlock.
Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
drivers/staging/lustre/lnet/libcfs/libcfs_lock.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
index 1967b97c..a2ce092f 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
@@ -113,9 +113,10 @@ struct cfs_percpt_lock *
/* exclusive lock request */
for (i = 0; i < ncpt; i++) {
+ if (!i)
+ LASSERT(!pcl->pcl_locked);
spin_lock(pcl->pcl_locks[i]);
if (!i) {
- LASSERT(!pcl->pcl_locked);
/* nobody should take private lock after this
* so I wouldn't starve for too long time
*/
@@ -141,11 +142,11 @@ struct cfs_percpt_lock *
}
for (i = ncpt - 1; i >= 0; i--) {
- if (!i) {
- LASSERT(pcl->pcl_locked);
+ if (!i)
pcl->pcl_locked = 0;
- }
spin_unlock(pcl->pcl_locks[i]);
+ if (!i)
+ LASSERT(pcl->pcl_locked);
}
}
EXPORT_SYMBOL(cfs_percpt_unlock);
--
1.7.9.5
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_percpt_lock and cfs_percpt_unlock Jia-Ju Bai <baijiaju1990@163.com> - 2017-05-31 10:20 +0200
csiph-web