From patchwork Tue Apr 28 18:23:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FA85C83000 for ; Tue, 28 Apr 2020 18:58:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E90C4206A1 for ; Tue, 28 Apr 2020 18:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588100282; bh=zD789dP6I9c4Z+1f02WB1iPpEHekSNenlssybZAeuw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HVH/mGB5OGW8G59PDot/igkpwDT6bo/S0YZB4LpLQSzJVKbF28LLnD9J+hXBz6nxF ZHetegMD6lyyYPcesvsPJqyDDtfB454GXUx8AqPWYBQUcvcIgqkDtEqmpQnR6sJcdk B6BRf3R0V4OH46ijB78xV0nRs39Gckz4ozKC3gWU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729406AbgD1S3q (ORCPT ); Tue, 28 Apr 2020 14:29:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:43680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729401AbgD1S3p (ORCPT ); Tue, 28 Apr 2020 14:29:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D169E20730; Tue, 28 Apr 2020 18:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588098585; bh=zD789dP6I9c4Z+1f02WB1iPpEHekSNenlssybZAeuw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPVGPgtNOR+ZKsmw+WU5r1aveD4vlqav6Sds3xcFTKlUB9bfEfd87yE9vk9bawzgE RMCebL2QLtEQxnJG7EHQxEQAG9OUpyigl6YdfMiZ7O5fKcXMt+rWWJMre+OZ9XDmlL DVneptzOHaIa7DXUF8hlASkgGShME4CCPeW3sHoE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.6 044/167] block: fix busy device checking in blk_drop_partitions again Date: Tue, 28 Apr 2020 20:23:40 +0200 Message-Id: <20200428182230.648339986@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182225.451225420@linuxfoundation.org> References: <20200428182225.451225420@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Christoph Hellwig [ Upstream commit cb6b771b05c3026a85ed4817c1b87c5e6f41d136 ] The previous fix had an off by one in the bd_openers checking, counting the callers blkdev_get. Fixes: d3ef5536274f ("block: fix busy device checking in blk_drop_partitions") Reported-by: Qian Cai Signed-off-by: Christoph Hellwig Tested-by: Qian Cai Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/partition-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index 5f3b2a959aa51..ebe4c2e9834bd 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -468,7 +468,7 @@ int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev) if (!disk_part_scan_enabled(disk)) return 0; - if (bdev->bd_part_count || bdev->bd_openers) + if (bdev->bd_part_count || bdev->bd_openers > 1) return -EBUSY; res = invalidate_partition(disk, 0); if (res)