From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: [PATCH block#for-2.6.36] block_dev: always serialize exclusive open attempts Date: Wed, 04 Aug 2010 17:40:59 +0200 Message-ID: <4C598A0B.9000301@gmail.com> References: <2dWFdr9kTFM.A.P0D.spXVMB@chimera> <4C56F30D.3020304@kernel.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=Ypx6uDhBgQANb0TazLpnpRXR5bhHvNS4N99qNj8abDQ=; b=ILuGA2fZ1N/SNgz264Yo9g5qF3Ti4zs36hRbvySMYhh07OnGj0KqrvmwdGMJiCbZG/ Z03yEom5xj1q09Inm4rrD+XGxjBn1jFbVy3+vfeLUmQmeOQqLw+TUk2Mvs0PlL20TMBM 23/2/lxXw7NdKTavJnKaGUYkxArimcO1H/t2s= In-Reply-To: <4C56F30D.3020304@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Jens Axboe Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Maciej Rutecki , Andrew Morton , Kernel Testers List , Network Development , Linux ACPI , Linux PM List , Linux SCSI List , Linux Wireless List , DRI , Linus Torvalds , stable@kernel.org, Maciej Rutecki 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 Reported-by: Maciej Rutecki Cc: stable@kernel.org --- fs/block_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 99d6af8..b3171fb 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -681,8 +681,8 @@ retry: 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);