From mboxrd@z Thu Jan 1 00:00:00 1970 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=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 30C0EC43603 for ; Tue, 17 Dec 2019 18:04:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EB7320684 for ; Tue, 17 Dec 2019 18:04:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728062AbfLQSEd (ORCPT ); Tue, 17 Dec 2019 13:04:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:55584 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbfLQSEc (ORCPT ); Tue, 17 Dec 2019 13:04:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0BFBAAFE0; Tue, 17 Dec 2019 18:04:31 +0000 (UTC) From: Michal Suchanek To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Michal Suchanek Subject: [PATCH] bdev: reset first_open when looping in __blkget_dev Date: Tue, 17 Dec 2019 19:04:28 +0100 Message-Id: <20191217180428.8868-1-msuchanek@suse.de> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 69bf2fb6f7cd..17e1231d5246 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; -- 2.23.0