From patchwork Wed Aug 4 15:59:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 60868 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id F35A4B70A5 for ; Thu, 5 Aug 2010 01:59:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755831Ab0HDP70 (ORCPT ); Wed, 4 Aug 2010 11:59:26 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:61231 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755607Ab0HDP7W (ORCPT ); Wed, 4 Aug 2010 11:59:22 -0400 Received: by bwz1 with SMTP id 1so2473180bwz.19 for ; Wed, 04 Aug 2010 08:59:20 -0700 (PDT) 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=hoJGsS1vP4ZhnUB7+2JY2+f2F31yZ2ogDS6OTAPCgjw=; b=I8bwCDq8n5ilpPT6w/9OrA4ILI+EtD2zKcoo0iucQMnC1lkNSw9L9qhz7dqB8AHOrB xyjLPDhi4KEna7k3wytP6S4X+1ygMr/5PN/8m/OWnZv9Zi6f/qlZr63Zyq46P5rssXjk 6xQdfpUO62kwcyUKGNtWVTtNJWDNlL7oDqkeI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=Ic1KHoxe571FggKnH2zelvFw4JRyWGSXUJRWCO/46JvCsVnWQU9GuVCQBjbmAIX36L A93TgTccqEczL6CtYm02BNebDFGHuMB20lyfUIoA88pPlamVzlYYX+RFeGUipRnOVWho F1HH/ZxKzhm+GyU4C8i0mM2YDrIONfXIf+yok= Received: by 10.204.13.72 with SMTP id b8mr6091815bka.190.1280937560234; Wed, 04 Aug 2010 08:59:20 -0700 (PDT) Received: from htj.dyndns.org ([130.75.117.88]) by mx.google.com with ESMTPS id s17sm6049640bkx.18.2010.08.04.08.59.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 04 Aug 2010 08:59:19 -0700 (PDT) Received: from [127.0.0.2] (htj.dyndns.org [127.0.0.2]) by htj.dyndns.org (Postfix) with ESMTPSA id 96AB61CC0555; Wed, 4 Aug 2010 17:59:39 +0200 (CEST) Message-ID: <4C598E6B.7050405@gmail.com> Date: Wed, 04 Aug 2010 17:59:39 +0200 From: Tejun Heo User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1 MIME-Version: 1.0 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 Subject: [PATCH RESEND block#for-2.6.36] block_dev: always serialize exclusive open attempts References: <2dWFdr9kTFM.A.P0D.spXVMB@chimera> <4C56F30D.3020304@kernel.org> In-Reply-To: <4C56F30D.3020304@kernel.org> X-Enigmail-Version: 1.1.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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: Markus Trippelsdorf Cc: stable@kernel.org --- Oops, had the wrong reported-by credit. Updated. Thanks. fs/block_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);