This is a note to let you know that I've just added the patch titled

    aio: wake all waiters when destroying ctx

to the 2.6.32-longterm tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/longterm/longterm-queue-2.6.32.git;a=summary

The filename of the patch is:
     aio-wake-all-waiters-when-destroying-ctx.patch
and it can be found in the queue-2.6.32 subdirectory.

If you, or anyone else, feels it should not be added to the 2.6.32 longterm 
tree,
please let <[email protected]> know about it.


>From e91f90bb0bb10be9cc8efd09a3cf4ecffcad0db1 Mon Sep 17 00:00:00 2001
From: Roland Dreier <[email protected]>
Date: Tue, 22 Mar 2011 16:35:10 -0700
Subject: aio: wake all waiters when destroying ctx

From: Roland Dreier <[email protected]>

commit e91f90bb0bb10be9cc8efd09a3cf4ecffcad0db1 upstream.

The test program below will hang because io_getevents() uses
add_wait_queue_exclusive(), which means the wake_up() in io_destroy() only
wakes up one of the threads.  Fix this by using wake_up_all() in the aio
code paths where we want to make sure no one gets stuck.

        // t.c -- compile with gcc -lpthread -laio t.c

        #include <libaio.h>
        #include <pthread.h>
        #include <stdio.h>
        #include <unistd.h>

        static const int nthr = 2;

        void *getev(void *ctx)
        {
                struct io_event ev;
                io_getevents(ctx, 1, 1, &ev, NULL);
                printf("io_getevents returned\n");
                return NULL;
        }

        int main(int argc, char *argv[])
        {
                io_context_t ctx = 0;
                pthread_t thread[nthr];
                int i;

                io_setup(1024, &ctx);

                for (i = 0; i < nthr; ++i)
                        pthread_create(&thread[i], NULL, getev, ctx);

                sleep(1);

                io_destroy(ctx);

                for (i = 0; i < nthr; ++i)
                        pthread_join(thread[i], NULL);

                return 0;
        }

Signed-off-by: Roland Dreier <[email protected]>
Reviewed-by: Jeff Moyer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 fs/aio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/fs/aio.c
+++ b/fs/aio.c
@@ -497,7 +497,7 @@ static inline void really_put_req(struct
        ctx->reqs_active--;
 
        if (unlikely(!ctx->reqs_active && ctx->dead))
-               wake_up(&ctx->wait);
+               wake_up_all(&ctx->wait);
 }
 
 static void aio_fput_routine(struct work_struct *data)
@@ -1219,7 +1219,7 @@ static void io_destroy(struct kioctx *io
         * by other CPUs at this point.  Right now, we rely on the
         * locking done by the above calls to ensure this consistency.
         */
-       wake_up(&ioctx->wait);
+       wake_up_all(&ioctx->wait);
        put_ioctx(ioctx);       /* once for the lookup */
 }
 


Patches currently in longterm-queue-2.6.32 which might be from 
[email protected] are

/home/gregkh/linux/longterm/longterm-queue-2.6.32/queue-2.6.32/aio-wake-all-waiters-when-destroying-ctx.patch

_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable

Reply via email to