Skip to content

Commit

Permalink
block_dev: always serialize exclusive open attempts
Browse files Browse the repository at this point in the history
bd_prepare_to_claim() incorrectly allowed multiple attempts for
exclusive open to progress in parallel if the attempting holders are
identical.  This triggered BUG_ON() as reported in the following bug.

  https://bugzilla.kernel.org/show_bug.cgi?id=16393

__bd_abort_claiming() is used to finish claiming blocks and doesn't
work if multiple openers are inside a claiming block.  Allowing
multiple parallel open attempts to continue doesn't gain anything as
those are serialized down in the call chain anyway.  Fix it by always
allowing only single open attempt in a claiming block.

This problem can easily be reproduced by adding a delay after
bd_prepare_to_claim() and attempting to mount two partitions of a
disk.

stable: only applicable to v2.6.35

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Aug 4, 2010
1 parent d9b68e5 commit e75aa85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ static int bd_prepare_to_claim(struct block_device *bdev,
if (!bd_may_claim(bdev, whole, holder))
return -EBUSY;

/* if someone else is claiming, wait for it to finish */
if (whole->bd_claiming && whole->bd_claiming != holder) {
/* if claiming is already in progress, wait for it to finish */
if (whole->bd_claiming) {
wait_queue_head_t *wq = bit_waitqueue(&whole->bd_claiming, 0);
DEFINE_WAIT(wait);

Expand Down

0 comments on commit e75aa85

Please sign in to comment.