Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1452439rwl; Wed, 12 Apr 2023 13:07:12 -0700 (PDT) X-Google-Smtp-Source: AKy350aj7Z+aJCBe9Y+dEd0da+lrqtzryhi0kNEZdF0JvV2Dza4QrXLUYDlskVxcU0wdMH0vVyjE X-Received: by 2002:a05:6a20:2d9f:b0:ec:206f:4e0 with SMTP id bf31-20020a056a202d9f00b000ec206f04e0mr542638pzb.42.1681330032488; Wed, 12 Apr 2023 13:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681330032; cv=none; d=google.com; s=arc-20160816; b=Jq/mhd4dc8WMYo+N9LjumDkPXu29w+Y4Ww4+mN1IFfIsA8F4dLzeefuzb3izakEAEb SjYBnqWXFxkuhhM7mo3eaKoHx+mKGKylk0mLUhcNOPpHVSIqVz8NxhtpCAnnXO0sjX0O 1LS5aam7xk3W44ZAZ8gEQrBHYnh5heSdRrCvDQjv4oLUMYPXy8iA3I2tFaGlU08oGd01 NtuZIjb9iJqr/pRD9pWj2LS0MGElbJB01CSvOnaZK4qafl6eUq5F/h2ZGrF3MK2xAgqt UOXVkUH0jhWDF/58xtZ3qcCxIy4wAP/UMdwdZoyYA1WxmYHC/g/puDMVzazIR6OwrUe+ 2jnw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=UloKvabmpDwvL37vn1PgpNCg+lQU3VLeRO5eeeDcUDE=; b=S0spZzhkVQj1dWbzlE3GydG+23pgPqjEME9jS+HIvC55LQR35Smx4fAy0rYVAcaJ6S Xb1/aLNGhjGjGXv6v3DnZlsAz9KGSfQ2UwXWJclFhqWD5mijoGHT8upwMFCcThcjNIcA AqdlmRzqk/9YKl9Cz0Xfp2kbxCRPR9PhWNIR+qUtcmC+4UrRAkKzAVNLshzAJlUqFE5z RHtiMHlcJMyQV5vqXn8/qUNE2D+R3TYsaKXuFR3HGpt5iyL/scuXercCjmiYtQMCYrCB 1LTh9otJBVhZ5V0DMqBz5v7yRZolXutKPOSwc+G1lLaBCM3RfDbGzoq771iinU6W0dz/ VavA== 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 g17-20020a63fa51000000b0050318a4a5casi5597599pgk.408.2023.04.12.13.07.01; Wed, 12 Apr 2023 13:07:12 -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 S229787AbjDLT7n (ORCPT + 99 others); Wed, 12 Apr 2023 15:59:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjDLT7m (ORCPT ); Wed, 12 Apr 2023 15:59:42 -0400 Received: from mx3.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE0402D55; Wed, 12 Apr 2023 12:59:40 -0700 (PDT) Received: from [192.168.1.190] (ip5b426bea.dynamic.kabel-deutschland.de [91.66.107.234]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: buczek) by mx.molgen.mpg.de (Postfix) with ESMTPSA id CD70C60027FEB; Wed, 12 Apr 2023 21:59:38 +0200 (CEST) Message-ID: <9d598566-5729-630e-5025-b4173cf307e4@molgen.mpg.de> Date: Wed, 12 Apr 2023 21:59:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v3 02/11] block: Block Device Filtering Mechanism Content-Language: en-US To: Sergei Shtepa , Christoph Hellwig Cc: axboe@kernel.dk, corbet@lwn.net, snitzer@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, kch@nvidia.com, martin.petersen@oracle.com, vkoul@kernel.org, ming.lei@redhat.com, gregkh@linuxfoundation.org, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <20230404140835.25166-1-sergei.shtepa@veeam.com> <20230404140835.25166-3-sergei.shtepa@veeam.com> <793db44e-9e6d-d118-3f88-cdbffc9ad018@molgen.mpg.de> <50d131e3-7528-2064-fbe6-65482db46ae4@veeam.com> From: Donald Buczek In-Reply-To: <50d131e3-7528-2064-fbe6-65482db46ae4@veeam.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 On 4/12/23 12:43, Sergei Shtepa wrote: > > > On 4/11/23 08:25, Christoph Hellwig wrote: >> Subject: >> Re: [PATCH v3 02/11] block: Block Device Filtering Mechanism >> From: >> Christoph Hellwig >> Date: >> 4/11/23, 08:25 >> >> To: >> Donald Buczek >> CC: >> Sergei Shtepa , axboe@kernel.dk, hch@infradead.org, corbet@lwn.net, snitzer@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, kch@nvidia.com, martin.petersen@oracle.com, vkoul@kernel.org, ming.lei@redhat.com, gregkh@linuxfoundation.org, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org >> >> >> On Sat, Apr 08, 2023 at 05:30:19PM +0200, Donald Buczek wrote: >>> Maybe detach the old filter and attach the new one instead? An atomic replace might be usefull and it wouldn't complicate the code to do that instead. If its the same filter, maybe just return success and don't go through ops->detach and ops->attach? >> I don't think a replace makes any sense. We might want multiple >> filters eventually, but unless we have a good use case for even just >> more than a single driver we can deal with that once needed. The >> interface is prepared to support multiple attached filters already. >> > > > Thank you Donald for your comment. It got me thinking. > > Despite the fact that only one filter is currently offered for the kernel, > I think that out-of-tree filters of block devices may appear very soon. > It would be good to think about it in advance. > And, I agree with Christophe, we would not like to redo the blk-filter interface > when new filters appear in the tree. > > We can consider a block device as a resource that two actor want to take over. > There are two possible behavioral strategies: > 1. If one owner occupies a resource, then for other actors, the ownership > request will end with a refusal. The owner will not lose his resource. > 2. Any actor can take away a resource from the owner and inform him about its > loss using a callback. > > I think the first strategy is safer. When calling ioctl BLKFILTER_ATTACH, the > kernel informs the actor that the resource is busy. > Of course, there is still an option to grab someone else's occupied resource. > To do this, he will have to call ioctl BLKFILTER_DETACH, specifying the name > of the filter that needs to be detached. It is assumed that such detached > should be performed by the same actor that attached it there. > > If we replace the owner at each ioctl BLKFILTER_ATTACH, then we can get a > situation of competition between two actors. At the same time, they won't > even get a message that something is going wrong. > > An example from life. The user compares different backup tools. Install one, > then another. Each uses its own filter (And why not? this is technically > possible). > With the first strategy, the second tool will make it clear to the user that > it cannot work, since the resource is already occupied by another. > The user will have to experiment first with one tool, uninstall it, and then > experiment with another. > With the second strategy, both tools will unload each other's filters. In the > best case, this will lead to disruption of their work. At a minimum, blksnap, > when detached, will reset the change tracker and each backup will perform a > full read of the block device. As a result, the user will receive distorted > data, the system will not work as planned, although there will be no error > message. I had a more complicated scenario in mind. For example, some kind of live migration from one block device to another, when you switch from the filter which clones from the source device to the target device to the filter which just redirects from the source device to the target device as the last step. OTOH, that may be a very distant vision. Plus, one single and simple filter, which redirects I/O into a DM stack, would be enough or better anyway to do the more complicated things using the DM features, which include atomic replacement and stacking and everything. I don't have a strong opinion. Best Donald -- Donald Buczek buczek@molgen.mpg.de Tel: +49 30 8413 1433