From: Jens Axboe Date: Tue, 29 Jan 2008 21:25:18 +0000 (+0100) Subject: as-iosched: fix double locking bug in as_merged_requests() X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=149a051f82d2b3860fe32fa182dbc83a66274894;p=openwrt%2Fstaging%2Fblogic.git as-iosched: fix double locking bug in as_merged_requests() 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 Signed-off-by: Jens Axboe --- diff --git a/block/as-iosched.c b/block/as-iosched.c index b201d16a7102..96036846a001 100644 --- a/block/as-iosched.c +++ b/block/as-iosched.c @@ -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); + } } }