Skip to content

Commit

Permalink
as-iosched: fix double locking bug in as_merged_requests()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jens Axboe committed Jan 30, 2008
1 parent 5b10ca1 commit 149a051
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions block/as-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 149a051

Please sign in to comment.