Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5435172rwl; Tue, 21 Mar 2023 19:19:25 -0700 (PDT) X-Google-Smtp-Source: AK7set/4UKWhWqd5TZFRMjNx/1PM3cfj4Djg4bYPSZ6j2gyRwulizlYJoF9LlImGwlmSmgWTQ8MQ X-Received: by 2002:a17:90a:414f:b0:23d:1bef:8594 with SMTP id m15-20020a17090a414f00b0023d1bef8594mr4241832pjg.1.1679451565686; Tue, 21 Mar 2023 19:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679451565; cv=none; d=google.com; s=arc-20160816; b=rKsOSWcCfj5ehiAgPz4DFJen2GGMIh/JclJi5hg1Xg9/QccbG4HCsAJ5MElJ09JHyv Mar002g6ZwIgsst3A0p5EX9VKR/UAtGCFfTFUtbL/U9t6OtTTpbSNtEUJiK7P0DI6HW9 gXVH9A+FXwR2Z5G7KtoXBcmg8Y+N4tAV6t46eJpCNJiXGmbNB05fZ9Om7APCgWNf3XQO fD6IT68CB53LDPNTa3Qa+mmRMJ8ozaulSen9pp6hjjAhjkSW7ZSUxkVJTxv0GX+mlkkE 0/BHtNrSOvDWR3s/J9d+vqRyMYWey1ftVd4lFKB9pcOhRtL5z0xUKKbpDwxQqdBTT7r6 oL5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=+S2Gs9ngfZxzjUnEA9Wl4NrjUKtlZajykZ2FGWr+0GA=; b=Wh751EeKUZ9867KZsKsSqAiKw1PG6xCFLz4l5ROMpW5DKyi4jj3SRvE4x8PxYECSE4 QtbaTVVWj7RiNoMmmHoRW42ddiZBzQF/deysJFy3aCFJUqAy6g+lM08dunml9AJupKKZ uQfCkNKmS70eV497d4SSrw6FK6aOpbcMpoM1SfMTZyiGDbxqkZYMU5aeaps8gTRsqm8n lXmh7I7umTXr8SFzeI2aPypqLUZIhvaWKwnshWW4yybUvMi80KTYcW1vCulK1msFTXbe Xlk4Mdm9eWR/ADlHioj1JGzAaCvppjJDtzBiZn679pM7I/ohmmqAXUAuiZlDE9VoC0lh toMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a17090ab30400b00235dc16de3asi84165pjr.16.2023.03.21.19.19.12; Tue, 21 Mar 2023 19:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjCVCPk (ORCPT + 99 others); Tue, 21 Mar 2023 22:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbjCVCPh (ORCPT ); Tue, 21 Mar 2023 22:15:37 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B52059E7C; Tue, 21 Mar 2023 19:15:35 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PhBrz187Mz4f3wYW; Wed, 22 Mar 2023 10:15:31 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP3 (Coremail) with SMTP id _Ch0CgDHcyHCZBpkrJxfFQ--.38182S3; Wed, 22 Mar 2023 10:15:32 +0800 (CST) Subject: Re: [PATCH -next 0/2] block: fix scan partition for exclusively open device again To: Yu Kuai , Ming Lei Cc: jack@suse.cz, hare@suse.de, hch@infradead.org, axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, Changhui Zhong , "yukuai (C)" References: <20230217022200.3092987-1-yukuai1@huaweicloud.com> <5facd7c1-fa90-99ff-bd08-cdf67fe6c1ab@huaweicloud.com> From: Yu Kuai Message-ID: Date: Wed, 22 Mar 2023 10:15:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <5facd7c1-fa90-99ff-bd08-cdf67fe6c1ab@huaweicloud.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: _Ch0CgDHcyHCZBpkrJxfFQ--.38182S3 X-Coremail-Antispam: 1UD129KBjvJXoWxGw4xJr47JFyrWFW5GrW8tFb_yoW5WrW3pF 97JF45tFWq9ryxC34jv3ZrWw15Kw47XryfWry3Gr1Iy39Ivr9IqrWktrZ8WryYqrZ5Wr1Y gF15JFyfXw18ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9214x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rWUJVWr Zr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYx BIdaVFxhVjvjDU0xZFpf9x0JUZa9-UUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.0 required=5.0 tests=NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, 在 2023/03/22 10:02, Yu Kuai 写道: > Hi, > > 在 2023/03/22 9:34, Ming Lei 写道: >> On Wed, Mar 22, 2023 at 09:26:07AM +0800, Yu Kuai wrote: >>> Hi, >>> >>> 在 2023/03/21 19:43, Ming Lei 写道: >>>> On Fri, Feb 17, 2023 at 10:21:58AM +0800, Yu Kuai wrote: >>>>> From: Yu Kuai >>>>> >>>>> Changes from RFC: >>>>>    - remove the patch to factor out GD_NEED_PART_SCAN >>>>> >>>>> Yu Kuai (2): >>>>>     block: Revert "block: Do not reread partition table on exclusively >>>>>       open device" >>>>>     block: fix scan partition for exclusively open device again >>>> >>>> Hi Yu kuai, >>>> >>>> Looks the original issue starts to re-appear now with the two patches: >>>> >>>> https://lore.kernel.org/linux-block/20221130135344.2ul4cyfstfs3znxg@quack3/ >>>> >>>> >>>> And underlying disk partition and raid partition can be observed at the >>>> same time. >>>> >>>> Can you take a look? >>> Yes, thanks for the report. I realize that sda1 adn sdb1 is created >>> while raid open sda and sdb excl, and I think this problem should exist >>> before this patchset. >> >> Looks not reproduced before applying your two patches, that is exactly >> what Jan >> tried to fix with 36369f46e917 ("block: Do not reread partition table >> on exclusively open device"). > > Hi, Ming > > I just tried your test with this patchset reverted, and I can still > reporduce the problem myself. Oops, I forgot to revert the first patch. It's right the problem can't be reporduced. > > raid only open this device excl, and disk_scan_partitions is not called: > > md_import_device >  blkdev_get_by_devo > > I need to add some debuginfo to figure out how GD_NEED_PART_SCAN is set > for sda after raid is stopped. And this should explain why sda1 is > created. I found how GD_NEED_PART_SCAN is set now, in patch 2, this is set before bd_prepare_to_claim, so preciously faild part scan will still set this bit, and following patch shold fix this problem: diff --git a/block/genhd.c b/block/genhd.c index 08bb1a9ec22c..2487c9452b94 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -368,7 +368,6 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode) if (disk->open_partitions) return -EBUSY; - set_bit(GD_NEED_PART_SCAN, &disk->state); /* * If the device is opened exclusively by current thread already, it's * safe to scan partitons, otherwise, use bd_prepare_to_claim() to @@ -381,6 +380,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode) return ret; } + set_bit(GD_NEED_PART_SCAN, &disk->state); bdev = blkdev_get_by_dev(disk_devt(disk), mode & ~FMODE_EXCL, NULL); if (IS_ERR(bdev)) ret = PTR_ERR(bdev); > > Thanks, > Kuai >> >> The issue is reported by Changhui's block regression test. >> >> >> Thanks, >> Ming >> >> >> . >> > > > . >