Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7832169rwp; Wed, 19 Jul 2023 00:31:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHsvIzYpu6hejBKsltPMT8aHACxZcdeTQbjXbjJGmmm64f5YLSAtAyfQSSoQk8DQJCfKmmr X-Received: by 2002:a05:6a20:8f09:b0:131:47f7:e80d with SMTP id b9-20020a056a208f0900b0013147f7e80dmr1737266pzk.23.1689751910533; Wed, 19 Jul 2023 00:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689751910; cv=none; d=google.com; s=arc-20160816; b=z2P8CVUSRC2WIwKmK8TFwFYW0gp5XSY2t7cF2QLxU6yD3Wv18RCQ1btaPuAbNGK7Lo 8/Sq95N5HAJ5w1aC012saAnR579IcDE6TIIPT7hwiZh2EmECwO1eG/ZJ57hidrim3+9M 6GOhDfqH2E8de6SkHHVWDiA05jsn9cDZBBjhj0SobLG/ZEb4rG5HnvhCyttGPryB6BNe 0IMFwSZsuNFzoQ1y1I1IqneVLc7BXN7yNYD5pCS1CWjAVeyZb98PhE6qAWlFOTCDrMtM AU3aDFy7bdkhI6ppQI1BrME3Ev1SzGxlmtXzB6n2UEOUcviswgvY4Q13NY6bkhk5HE/K 5IcA== 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=3zvh1kr8zHRhutIwakXd44lmStx5S2IhHRzXK3fhDQQ=; fh=pYSQ45ex9LTgjR66AxxysrSAurZaSepeL+Kd3Z1TYe4=; b=pVAOZIIby4UkuyBWAlweiXK6Mr3RapCH8ff4k2MJpoe+qnKXYiO/rIeIhwlt8GIpB1 SjVxNnXEjPLpynyAYx2cVQ0LBqaRG5vzKXAoEShhg62o9YO/WHa9A58uDZ21DzK2GBJr LA1L8cANGTJ8PF07940puXFLEjR9qE8IwPZ4QuvuEfuATknkp+OL5iYIU1XYwX4SZRm1 KmC8lZCMLyfbyd1nUWH9HCZexpMVGr/nsP72pGkVMLtXL14iJ3J9ay1XTaX6ByAAUqlC X/LMFKEji718xf2K/65lAnqHsCt0WJCfKUw1pGxdxfmkM/XXMXMWkV7SsMxf3nwdRyo0 GIsA== 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 t5-20020a655545000000b005578c6a7645si3078074pgr.69.2023.07.19.00.31.36; Wed, 19 Jul 2023 00:31:50 -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 S230040AbjGSH3E (ORCPT + 99 others); Wed, 19 Jul 2023 03:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjGSH3B (ORCPT ); Wed, 19 Jul 2023 03:29:01 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883B1E47; Wed, 19 Jul 2023 00:28:58 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R5S9f6Wthz4f3prY; Wed, 19 Jul 2023 15:28:54 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgBnHbG1kLdkjRJCOQ--.49626S3; Wed, 19 Jul 2023 15:28:55 +0800 (CST) Subject: Re: [PATCH v5 02/11] block: Block Device Filtering Mechanism To: Sergei Shtepa , Yu Kuai , axboe@kernel.dk, hch@infradead.org, corbet@lwn.net, snitzer@kernel.org Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, willy@infradead.org, dlemoal@kernel.org, linux@weissschuh.net, jack@suse.cz, ming.lei@redhat.com, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Donald Buczek , "yukuai (C)" References: <20230612135228.10702-1-sergei.shtepa@veeam.com> <20230612135228.10702-3-sergei.shtepa@veeam.com> <90f79cf3-86a2-02c0-1887-d3490f9848bb@veeam.com> <686b9999-c903-cff1-48ba-21324031da17@veeam.com> From: Yu Kuai Message-ID: <8257903a-1905-49c5-bed4-d15ca06c6d3b@huaweicloud.com> Date: Wed, 19 Jul 2023 15:28:53 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBnHbG1kLdkjRJCOQ--.49626S3 X-Coremail-Antispam: 1UD129KBjvJXoWxuFWxWr43XF17tw4kZr18Krg_yoW7tF1rpF yYga1qkr4kGr1Skwnrt3W7ua4rt395Jr1F9r15J34rCr98KrnIgw43t3yY93WDZr4vka4Y vr4ag34xt34DA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9F14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E 3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcS sGvfC2KfnxnUUI43ZEXa7VUbQVy7UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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/07/19 0:33, Sergei Shtepa 写道: > > > On 7/18/23 14:32, Yu Kuai wrote: >> Subject: >> Re: [PATCH v5 02/11] block: Block Device Filtering Mechanism >> From: >> Yu Kuai >> Date: >> 7/18/23, 14:32 >> >> To: >> Sergei Shtepa , Yu Kuai , axboe@kernel.dk, hch@infradead.org, corbet@lwn.net, snitzer@kernel.org >> CC: >> viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, willy@infradead.org, dlemoal@kernel.org, linux@weissschuh.net, jack@suse.cz, ming.lei@redhat.com, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Donald Buczek , "yukuai (C)" >> >> >> Hi, >> >> 在 2023/07/18 19:25, Sergei Shtepa 写道: >>> Hi. >>> >>> On 7/18/23 03:37, Yu Kuai wrote: >>>> Subject: >>>> Re: [PATCH v5 02/11] block: Block Device Filtering Mechanism >>>> From: >>>> Yu Kuai >>>> Date: >>>> 7/18/23, 03:37 >>>> >>>> To: >>>> Sergei Shtepa , Yu Kuai , axboe@kernel.dk, hch@infradead.org, corbet@lwn.net, snitzer@kernel.org >>>> CC: >>>> viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, willy@infradead.org, dlemoal@kernel.org, linux@weissschuh.net, jack@suse.cz, ming.lei@redhat.com, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Donald Buczek , "yukuai (C)" >>>> >>>> >>>> Hi, >>>> >>>> 在 2023/07/17 22:39, Sergei Shtepa 写道: >>>>> >>>>> >>>>> On 7/11/23 04:02, Yu Kuai wrote: >>>>>> bdev_disk_changed() is not handled, where delete_partition() and >>>>>> add_partition() will be called, this means blkfilter for partiton will >>>>>> be removed after partition rescan. Am I missing something? >>>>> >>>>> Yes, when the bdev_disk_changed() is called, all disk block devices >>>>> are deleted and new ones are re-created. Therefore, the information >>>>> about the attached filters will be lost. This is equivalent to >>>>> removing the disk and adding it back. >>>>> >>>>> For the blksnap module, partition rescan will mean the loss of the >>>>> change trackers data. If a snapshot was created, then such >>>>> a partition rescan will cause the snapshot to be corrupted. >>>>> >>>> >>>> I haven't review blksnap code yet, but this sounds like a problem. >>> >>> I can't imagine a case where this could be a problem. >>> Partition rescan is possible only if the file system has not been >>> mounted on any of the disk partitions. Ioctl BLKRRPART will return >>> -EBUSY. Therefore, during normal operation of the system, rescan is >>> not performed. >>> And if the file systems have not been mounted, it is possible that >>> the disk partition structure has changed or the disk in the media >>> device has changed. In this case, it is better to detach the >>> filter, otherwise it may lead to incorrect operation of the module. >>> >>> We can add prechange/postchange callback functions so that the >>> filter can track rescan process. But at the moment, this is not >>> necessary for the blksnap module. >> >> So you mean that blkfilter is only used for the case that partition >> is mounted? (Or you mean that partition is opened) >> >> Then, I think you mean that filter should only be used for the partition >> that is opended? Otherwise, filter can be gone at any time since >> partition rescan can be gone. >> >> //user >> 1. attach filter >>         // other context rescan partition >> 2. mount fs >> // user will found filter is gone. > > Mmm... The fact is that at the moment the user of the filter is the > blksnap module. There are no other filter users yet. The blksnap module > solves the problem of creating snapshots, primarily for backup purposes. > Therefore, the main use case is to attach a filter for an already running > system, where all partitions are marked up, file systems are mounted. > > If the server is being serviced, during which the disk is being > re-partitioned, then disabling the filter is normal. In this case, the > change tracker will be reset, and at the next backup, the filter will be > attached again. Thanks for the explanation, I was thinking that blkshap can replace dm-snapshot. Thanks, Kuai > > But if I were still solving the problem of saving the filter when rescanning, > then it is necessary to take into account the UUID and name of the partition > (struct partition_meta_info). It is unacceptable that due to a change in the > structure of partitions, the filter is attached to another partition by mistake. > The changed() callback would also be good to add so that the filter receives > a notification that the block device has been updated. > > But I'm not sure that this should be done, since if some code is not used in > the kernel, then it should not be in the kernel. > >> >> Thanks, >> Kuai >> >>> >>> Therefore, I will refrain from making changes for now. >>> >>>> >>>> possible solutions I have in mind: >>>> >>>> 1. Store blkfilter for each partition from bdev_disk_changed() before >>>> delete_partition(), and add blkfilter back after add_partition(). >>>> >>>> 2. Store blkfilter from gendisk as a xarray, and protect it by >>>> 'open_mutex' like 'part_tbl', block_device can keep the pointer to >>>> reference blkfilter so that performance from fast path is ok, and the >>>> lifetime of blkfiter can be managed separately. >>>> >>>>> There was an idea to do filtering at the disk level, >>>>> but I abandoned it. >>>>> . >>>>> >>>> I think it's better to do filtering at the partition level as well. >>>> >>>> Thanks, >>>> Kuai >>>> >>> . >>> >> > . >