]> err.no Git - linux-2.6/commitdiff
as-iosched: fix double locking bug in as_merged_requests()
authorJens Axboe <jens.axboe@oracle.com>
Tue, 29 Jan 2008 21:25:18 +0000 (22:25 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 30 Jan 2008 08:11:10 +0000 (09:11 +0100)
If the two requests belong to the same io context, we will attempt
to lock the same lock twice. But swapping contexts is pointless in
that case, so just check for rioc == nioc before doing the double
lock and copy.

Tested-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/as-iosched.c

index b201d16a71020f1261a42bc56ac36a9915da16ad..96036846a0017505691060d62734afc0dcad9529 100644 (file)
@@ -1275,9 +1275,13 @@ static void as_merged_requests(struct request_queue *q, struct request *req,
                         * Don't copy here but swap, because when anext is
                         * removed below, it must contain the unused context
                         */
-                       double_spin_lock(&rioc->lock, &nioc->lock, rioc < nioc);
-                       swap_io_context(&rioc, &nioc);
-                       double_spin_unlock(&rioc->lock, &nioc->lock, rioc < nioc);
+                       if (rioc != nioc) {
+                               double_spin_lock(&rioc->lock, &nioc->lock,
+                                                               rioc < nioc);
+                               swap_io_context(&rioc, &nioc);
+                               double_spin_unlock(&rioc->lock, &nioc->lock,
+                                                               rioc < nioc);
+                       }
                }
        }