Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2800480rwd; Wed, 14 Jun 2023 07:30:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4OG+wraesqNa6/mbFZIrsIG8nEb0ZFh7X/vtz3wjWsYJf7+3McjweyyBV3kmgV8XX++ZT0 X-Received: by 2002:a05:6402:194:b0:518:7d0d:298 with SMTP id r20-20020a056402019400b005187d0d0298mr1601151edv.38.1686753042711; Wed, 14 Jun 2023 07:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753042; cv=none; d=google.com; s=arc-20160816; b=X1WSa/jnffvKq2aik84dQQYAjse/nwZB+gijUBpBBen5ANOyncXspsaM5pQi51nXG8 YzcCv/EAbwH2D4+P3DrHEEwDNxB1Mr6hzfKMPju6UjHjYFxJndVevszDDLfnn3SKj/5V tZzz3dc6xV4js5nSMyd6REak7cD8A32dNRjJ7eYdnK+/NvkiH4Ak62tMYsBy3zUZZawZ 1kR2kFI4B0mQ/rUv8+h/yi/J9KBTTf38a4V3hqN+bROdPGQoBKSYJVYfSFkGbtOHUed0 mj51x+d0Z22OxgL6fOmjI92hAxvS7OGUe0l6CX6ZXFLXEd00M7SEynGAHqXZ+iDzQIEY lOSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7zKVnjvzit87w4LvMJMfhzArUJCjxSyS9z+9JMuufv0=; b=BKq/X/3K1sR0qwG4+5tk1qITQTIyOFqhYPJau6w13UZvQ1HLN1TDyi2zr9iSlRXyHB x0FPYeO9/dCAu1jvzbk1PtuX4pHQ/jd3zoxsxRZs/sC7JzOtBYiU89R4/A1qbEc6E2R5 kO9L3c+j539uZNWR1gkIe0vEPUFIKfv8BvtihOEUMnt81RE6yknXmFQMMNKLSu6NvxFt J5OMIAp8P81O45qj6bGFxz6VUIIkITwJnTlRjWS0N2+5B7J2DJ7VkPTS+3x9wVvOk+3d TTajheAcA942GIVLOJpy0S1dnJG/9gzgRNQILfLVuuC9GmaLwk0RS1x4ItpEz2Ycd0Fr rg6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=tEAtQCHh; 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 a9-20020a50e709000000b00516a1f2c89fsi9220477edn.677.2023.06.14.07.30.07; Wed, 14 Jun 2023 07:30:42 -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; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=tEAtQCHh; 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 S245401AbjFNOHl (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245366AbjFNOHe (ORCPT ); Wed, 14 Jun 2023 10:07:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB713172E; Wed, 14 Jun 2023 07:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7zKVnjvzit87w4LvMJMfhzArUJCjxSyS9z+9JMuufv0=; b=tEAtQCHhfR4Vb3SCSgPJ0NazMr isWCiYg7499DEFizrwQiervPnffzp/TurF1vFQCf0XGRCc0yT6KucKJdx7pNy093snkYZxYFo1kOl WBdEHOihJKfaEA3PrmEFokNco80EXoNE6C4Gey9Vctt/U6iVvaM5X3bE1hWwV6coGWAx8nNWZLG3d FARfb2/mVfruNpVGZ9s54BUq8BNfgXC/tzbVoYvJQTWzBussVf7prhn0fcW85KCSJbcm0Oc4wmdRD CRfOsZ7lqiWHsmVTInHiN7qreFJAjBZyjO4//29ctzD4K2VHCv64Iu2vQHlFtwbmWYwK83cEM8n8I QyAy5xzw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q9R9Y-00BrUL-2D; Wed, 14 Jun 2023 14:07:16 +0000 Date: Wed, 14 Jun 2023 07:07:16 -0700 From: Christoph Hellwig To: Sergei Shtepa Cc: Christoph Hellwig , Dave Chinner , axboe@kernel.dk, corbet@lwn.net, snitzer@kernel.org, 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 Subject: Re: [PATCH v5 04/11] blksnap: header file of the module interface Message-ID: References: <20230612135228.10702-1-sergei.shtepa@veeam.com> <20230612135228.10702-5-sergei.shtepa@veeam.com> <733f591e-0e8f-8668-8298-ddb11a74df81@veeam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <733f591e-0e8f-8668-8298-ddb11a74df81@veeam.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, Jun 14, 2023 at 11:26:20AM +0200, Sergei Shtepa wrote: > This code worked quite successfully for the veeamsnap module, on the > basis of which blksnap was created. Indeed, such an allocation of an > area on a block device using a file does not look safe. > > We've already discussed this with Donald Buczek . > Link: https://github.com/veeam/blksnap/issues/57#issuecomment-1576569075 > And I have planned work on moving to a more secure ioctl in the future. > Link: https://github.com/veeam/blksnap/issues/61 > > Now, thanks to Dave, it becomes clear to me how to solve this problem best. > swapfile is a good example of how to do it right. I don't actually think swapfile is a very good idea, in fact the Linux swap code in general is not a very good place to look for inspirations :) IFF the usage is always to have a whole file for the diff storage the over all API is very simple - just pass a fd to the kernel for the area, and then use in-kernel direct I/O on it. Now if that file should also be able to reside on the same file system that the snapshot is taken of things get a little more complicated, because writes to it also need to automatically set the BIO_REFFED flag. I have some ideas for that and will share some draft code with you.