From patchwork Tue Nov 26 19:54:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Suchanek X-Patchwork-Id: 11263009 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 25D2914ED for ; Tue, 26 Nov 2019 19:55:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03C7320684 for ; Tue, 26 Nov 2019 19:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727277AbfKZTzS (ORCPT ); Tue, 26 Nov 2019 14:55:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:40240 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727006AbfKZTyp (ORCPT ); Tue, 26 Nov 2019 14:54:45 -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 7661CB0B8; Tue, 26 Nov 2019 19:54:43 +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 rebase 06/10] bdev: reset first_open when looping in __blkget_dev Date: Tue, 26 Nov 2019 20:54:25 +0100 Message-Id: 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 ee63c2732fa2..545bb6c8848a 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1560,7 +1560,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; @@ -1580,6 +1580,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;