Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3989685imw; Thu, 7 Jul 2022 10:45:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVhZUGC1uEx/UmAZkkNFIksV7hOZLoC1yYgnPaukfE8n69CMHJzec/c3rX2bMeKaXt36gF X-Received: by 2002:a05:6402:3593:b0:43a:a259:2518 with SMTP id y19-20020a056402359300b0043aa2592518mr1338694edc.117.1657215934526; Thu, 07 Jul 2022 10:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657215934; cv=none; d=google.com; s=arc-20160816; b=B9cFc/J5REWN8CUYdpo0CLk5n3nAW64lmS3NJJD3wHm4y57uqiR6GthMf0KNI+aTp3 m2XmXmNmHDqWJNoERu5q9uZTPcDH3bXr1FX2JIo6wSGGW3Hl43ka9KfiVxos7nNpUVKz U16fRfJLL9OtJ8Md8Zmchd0+rux8oZlrR5TWuzphBTPZo52xWR6P9pdo6bg0/1KwORQA zRAm4zujW7PTaKDVCxj+imqXnOAZXmPA/UIBpDvURpfegsmiaNp2upb0Qpo5cmVT4qRO y6Y9+MCwtN0rkzwG72HOhF4q/QDsTevj1uln6PaP1IitahM3snval+QtQn9m3IhHe/ft FcnA== 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=TMaNklIdIcP+MFN2zwCG5jiftF6l+7/4HlhjYmCCffE=; b=ZMbQHqkL1zy6+p9QD4Lej+tnsP23li4b5EYgpXISDp146Gkgy6y/WT9xbe8NGL1psg zsdW7ciO+QqZCZpz/bl3L/ayS4ACJKNPrv0rAWqGo7yTNYzEGx5caGZOF9GFX6AqoxLe GOxN+mhsSkHmLqZ9s7bLpNpfq3Sl5jJywYKEKNw9CWIY5nZRz0K3gQwgGzI1b71ff1JB 4GMAHreGnyZGEf2Cz6prePSjDQ/0jWMe03QZD4kNZ9qKuYmjGsV1UU+XXtbIN4PXLV4H 4fwJBPpwHU4IGD96ecgw4PfL/lQz41Y+QbfZ/qtqyFp/JdaOEOCZz91rn+hGfAiyFjnv rKYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Sn0j+sa3; 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 o8-20020a170906974800b00722e1f93942si2789523ejy.333.2022.07.07.10.45.08; Thu, 07 Jul 2022 10:45:34 -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=Sn0j+sa3; 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 S235937AbiGGRdb (ORCPT + 99 others); Thu, 7 Jul 2022 13:33:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235347AbiGGRd3 (ORCPT ); Thu, 7 Jul 2022 13:33:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A1301095; Thu, 7 Jul 2022 10:33:26 -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=TMaNklIdIcP+MFN2zwCG5jiftF6l+7/4HlhjYmCCffE=; b=Sn0j+sa3jhLQ0ziIexYmJgHUPF ipH5TffoQhAW/RMhlhDR63Y1dQ/gQr6C/IjgyLZut5m8YWccvybkG2lt8sGbx4r8QgBYxATJMrQVq 9wqoMr8wbfVeht7o45vHjxRhg5cf/jER3KIA96iyL/yKONUDDwhsxgkgZy6lxw2ySmwo5djC8vTEi v3W0b/A3Hj/VHwKxiRddE6dgdmyD7hMm94HFh1vu4gMPoDJgEfjlY1pGm0hiR0wwcS7gSxFTd0mDE wRxUej3+v58daNyzNsBCv7ZXsNeKePVHHQIveb1MR+LiChvdfC6umxQM2DYVzhicvbsTp+ciiRXrv TQNIE1GA==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9VNU-00HENG-U1; Thu, 07 Jul 2022 17:33:24 +0000 Date: Thu, 7 Jul 2022 10:33:24 -0700 From: Christoph Hellwig To: Sergei Shtepa Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/20] block, blksnap: functions and structures for performing block I/O operations Message-ID: References: <1655135593-1900-1-git-send-email-sergei.shtepa@veeam.com> <1655135593-1900-12-git-send-email-sergei.shtepa@veeam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1655135593-1900-12-git-send-email-sergei.shtepa@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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 > +#define SECTORS_IN_PAGE (PAGE_SIZE / SECTOR_SIZE) This can use PAGE_SECTORS from blk_types.h > + > +struct bio_set diff_io_bioset = { 0 }; No need to initialize global variables to 0. > + // Allocate both bios > + opf = diff_io->is_write ? REQ_OP_WRITE : REQ_OP_READ; > + gfp = GFP_NOIO | (is_nowait ? GFP_NOWAIT : 0); > + > + bio = bio_alloc_bioset(diff_region->bdev, nr_iovecs, > + opf | REQ_SYNC | REQ_IDLE | REQ_FUA, REQ_FUA on reads does not make sense. > + submit_bio_noacct(bio); > + > + // Submit flush bio > + bio_set_flag(flush_bio, BIO_FILTERED); > + flush_bio->bi_end_io = diff_io_endio; > + flush_bio->bi_private = diff_io; > + flush_bio->bi_iter.bi_sector = 0; > + submit_bio_noacct(flush_bio); And a separate flush for reads seems odd and probably wrong here. And for writes REQ_FUA already ensuresyour write went to disk. Do you also need to flush all previous data? In which case you probably want a single bio with REQ_PREFLUSH and REQ_FUA instead of submitting two separate bios here.