staging/lustre: Only set INTERRUPTIBLE state before calling schedule
authorOleg Drokin <green@linuxhacker.ru>
Sat, 16 May 2015 07:38:31 +0000 (03:38 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 00:29:44 +0000 (09:29 +0900)
In __l_wait_event the condition could be a complicated function that does
allocations and other potentialy blocking activities, so it sohuld
not be called in a task state other than RUNNABLE

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre_lib.h

index bf135630c39a78d3d70b7d1ad14a92eb61d7c11e..43ee9f0eb4d47f801a8f99acc4bdc41e7294899e 100644 (file)
@@ -549,19 +549,13 @@ do {                                                                         \
                __blocked = cfs_block_sigsinv(0);                             \
                                                                               \
        for (;;) {                                                           \
-               unsigned       __wstate;                                       \
-                                                                              \
-               __wstate = info->lwi_on_signal != NULL &&                     \
-                          (__timeout == 0 || __allow_intr) ?             \
-                       TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;             \
-                                                                              \
-               set_current_state(TASK_INTERRUPTIBLE);           \
-                                                                              \
                if (condition)                                           \
                        break;                                           \
                                                                               \
+               set_current_state(TASK_INTERRUPTIBLE);                         \
+                                                                              \
                if (__timeout == 0) {                                     \
-                       schedule();                                             \
+                       schedule();                                            \
                } else {                                                       \
                        long interval = info->lwi_interval?       \
                                             min_t(long,             \
@@ -582,6 +576,8 @@ do {                                                                           \
                        }                                                     \
                }                                                             \
                                                                               \
+               set_current_state(TASK_RUNNING);                               \
+                                                                              \
                if (condition)                                           \
                        break;                                           \
                if (cfs_signal_pending()) {                                 \
@@ -605,7 +601,6 @@ do {                                                                           \
                                                                               \
        cfs_restore_sigs(__blocked);                                       \
                                                                               \
-       set_current_state(TASK_RUNNING);                               \
        remove_wait_queue(&wq, &__wait);                                           \
 } while (0)