async: Fix lack of boot-time console due to insufficient synchronization [Linux 2.6.30]

This Linux kernel change "async: Fix lack of boot-time console due to insufficient synchronization" is included in the Linux 2.6.30 release. This change is authored by Linus Torvalds <torvalds [at] linux-foundation.org> on Mon Jun 8 12:31:53 2009 -0700. The commit for this change in Linux stable tree is 3af968e (patch).

async: Fix lack of boot-time console due to insufficient synchronization

Our async work synchronization was broken by "async: make sure
independent async domains can't accidentally entangle" (commit
d5a877e8dd409d8c702986d06485c374b705d340), because it would report
the wrong lowest active async ID when there was both running and
pending async work.

This caused things like no being able to read the root filesystem,
resulting in missing console devices and inability to run 'init',
causing a boot-time panic.

This fixes it by properly returning the lowest pending async ID: if
there is any running async work, that will have a lower ID than any
pending work, and we should _not_ look at the pending work list.

There were alternative patches from Jaswinder and James, but this one
also cleans up the code by removing the pointless 'ret' variable and
the unnecesary testing for an empty list around 'for_each_entry()' (if
the list is empty, the for_each_entry() thing just won't execute).

Fixes-bug: http://bugzilla.kernel.org/show_bug.cgi?id=13474
Reported-and-tested-by: Chris Clayton <[email protected]>
Cc: Jaswinder Singh Rajput <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>

There are 15 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 kernel/async.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/kernel/async.c b/kernel/async.c
index 5054030..27235f5 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -92,23 +92,18 @@ struct async_entry {
 static async_cookie_t  __lowest_in_progress(struct list_head *running)
 {
    struct async_entry *entry;
-   async_cookie_t ret = next_cookie; /* begin with "infinity" value */

    if (!list_empty(running)) {
        entry = list_first_entry(running,
            struct async_entry, list);
-       ret = entry->cookie;
+       return entry->cookie;
    }

-   if (!list_empty(&async_pending)) {
-       list_for_each_entry(entry, &async_pending, list)
-           if (entry->running == running) {
-               ret = entry->cookie;
-               break;
-           }
-   }
+   list_for_each_entry(entry, &async_pending, list)
+       if (entry->running == running)
+           return entry->cookie;

-   return ret;
+   return next_cookie; /* "infinity" value */
 }

 static async_cookie_t  lowest_in_progress(struct list_head *running)

Leave a Reply

Your email address will not be published. Required fields are marked *