From patchwork Thu Nov 21 17:13:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Suchanek X-Patchwork-Id: 11256607 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E97D4138C for ; Thu, 21 Nov 2019 17:14:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9E06206DA for ; Thu, 21 Nov 2019 17:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbfKUROS (ORCPT ); Thu, 21 Nov 2019 12:14:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:54128 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727097AbfKURNl (ORCPT ); Thu, 21 Nov 2019 12:13:41 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 37411B2D5; Thu, 21 Nov 2019 17:13:40 +0000 (UTC) From: Michal Suchanek To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Cc: Michal Suchanek , Jonathan Corbet , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , Eric Biggers , "J. Bruce Fields" , Mauro Carvalho Chehab , Benjamin Coddington , Ming Lei , Chaitanya Kulkarni , Bart Van Assche , Damien Le Moal , Hou Tao , Pavel Begunkov , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jan Kara , Hannes Reinecke , "Ewan D. Milne" , Christoph Hellwig , Matthew Wilcox Subject: [PATCH v4 06/10] bdev: reset first_open when looping in __blkget_dev Date: Thu, 21 Nov 2019 18:13:13 +0100 Message-Id: <3d315cdc2847db0942168ef3df920acb55b9e5fd.1574355709.git.msuchanek@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org It is not clear that no other thread cannot open the block device when __blkget_dev drops it and loop to restart label. Reset first_open to false when looping. Signed-off-by: Michal Suchanek --- fs/block_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 9c073dbdc1b0..a3083fbada8b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1525,7 +1525,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) int ret; int partno; int perm = 0; - bool first_open = false; + bool first_open; if (mode & FMODE_READ) perm |= MAY_READ; @@ -1545,6 +1545,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) restart: ret = -ENXIO; + first_open = false; disk = bdev_get_gendisk(bdev, &partno); if (!disk) goto out;