[PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_wi_sched_destroy

2017-05-31 Thread Jia-Ju Bai
The driver may sleep under a spin lock, and the function call path is:
cfs_wi_sched_destroy (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 
---
 drivers/staging/lustre/lnet/libcfs/workitem.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c 
b/drivers/staging/lustre/lnet/libcfs/workitem.c
index dbc2a9b..e0424f6 100644
--- a/drivers/staging/lustre/lnet/libcfs/workitem.c
+++ b/drivers/staging/lustre/lnet/libcfs/workitem.c
@@ -302,11 +302,12 @@ static int cfs_wi_scheduler(void *arg)
return;
}
 
-   LASSERT(!list_empty(>ws_list));
sched->ws_stopping = 1;
 
spin_unlock(_wi_data.wi_glock);
 
+   LASSERT(!list_empty(>ws_list));
+
i = 2;
wake_up_all(>ws_waitq);
 
-- 
1.7.9.5




[PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_wi_sched_destroy

2017-05-31 Thread Jia-Ju Bai
The driver may sleep under a spin lock, and the function call path is:
cfs_wi_sched_destroy (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 
---
 drivers/staging/lustre/lnet/libcfs/workitem.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c 
b/drivers/staging/lustre/lnet/libcfs/workitem.c
index dbc2a9b..e0424f6 100644
--- a/drivers/staging/lustre/lnet/libcfs/workitem.c
+++ b/drivers/staging/lustre/lnet/libcfs/workitem.c
@@ -302,11 +302,12 @@ static int cfs_wi_scheduler(void *arg)
return;
}
 
-   LASSERT(!list_empty(>ws_list));
sched->ws_stopping = 1;
 
spin_unlock(_wi_data.wi_glock);
 
+   LASSERT(!list_empty(>ws_list));
+
i = 2;
wake_up_all(>ws_waitq);
 
-- 
1.7.9.5