Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp914519rwe; Fri, 14 Apr 2023 11:20:43 -0700 (PDT) X-Google-Smtp-Source: AKy350aqZvGzMURUher6ec4SH8p02yOvh2BjWRLzbQLy4pR4uguSSNVruBu8kv7/S7NytCIw1Kyj X-Received: by 2002:a05:6a20:41e:b0:dc:4369:16a4 with SMTP id a30-20020a056a20041e00b000dc436916a4mr6458303pza.19.1681496443393; Fri, 14 Apr 2023 11:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681496443; cv=none; d=google.com; s=arc-20160816; b=Um3RgwxjOa0PTU2MXm/V326pR+/f7kbIZFMqqX33+NYbG9zLcX8Oq8kdL+fhJY5QBm K9IiAUmpKe1mhwjso8Ps8y55G+c0d0fYHYcoVIsISGQCU8Pz3bJJZQVGK4fN/2nLMHBK Xosrld7yPApZCcnGagBNV8DV9eLsMimk6BqJMwuCp7/TMmqUaBvhz2yqeCfD0qRtSA8M eJRtlRcY3+ceLzSwoe8OqmKzi1Fm+M/vSZmhcCGZRCdYxKA46JzaDD6o7XwbvWSY21P6 xVZ0mVnRTqJY5PJxFgxvpKSH4BiplDxtQyO+vauKTQ7vJh0fsaCbOuDnw/+DHpHN9Nc8 estA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7nJQ/Y9J49ZegPKB8YDx6kUTeaR5VGKNsyTpo7amzJY=; b=Cj/UPCx5p0kh2Kb0gZQ0Qb5CZEgmPC+FuTMbgJsGOmwq8+zaffpFaLBVjVnKL4pkJ3 YtoKUVovYRzw1G1cJOrP7rfYlFm7pkm7oErDwLLMijBzuWf9oB8t9HBvxOGw8pHiD/6n R0/AFBiC01XrSp+znJei2jPXAj98jrA08vVfqbVhcGeiUJ/FMw/IeXed+QO40dDGGb0R Y6zLutBOJbnmkY+cbr0p+O1zZ+l3xQL46nsyZ4rNdcohM2hNr5GvSfztDq5hOxRmmhZp l1SGhhrqiXdsA3JDJLuqAj5dyiVpPzf9leRDi5Z3KsuF2jzRPX7bw2VHLJ9zb/T2T7yl TaJw== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020aa79d86000000b0062578d18ba1si5037221pfq.54.2023.04.14.11.20.29; Fri, 14 Apr 2023 11:20:43 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbjDNSPg (ORCPT + 99 others); Fri, 14 Apr 2023 14:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbjDNSPd (ORCPT ); Fri, 14 Apr 2023 14:15:33 -0400 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143149010 for ; Fri, 14 Apr 2023 11:14:51 -0700 (PDT) Received: by mail-qv1-f47.google.com with SMTP id dw2so27828650qvb.11 for ; Fri, 14 Apr 2023 11:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681496090; x=1684088090; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7nJQ/Y9J49ZegPKB8YDx6kUTeaR5VGKNsyTpo7amzJY=; b=DArjUIATl22NdIIbPWU+uL+VQ3Y0Dn6h5p8ShbF7dI/zlgp3gTO2HZHILP4pBMvTXZ 1Y5ubApDQy5HBY4hOdqsVUZmUS3DgWy45BMVUjLtglm9iVOOYFTr9oHrtW4f7llNSIev 4mM9/xk4btbuwKE0E0ETeiVgRfWhYjQS3/ffKb1WpyLP64DG6f5QaVo0ZwB8FZeMvNFg PBctoBvxE9uiicN9SD+vrmNvsUx+b+fFR4Pxe94qLvDbuDape7T/xLPjrzgWrjyl6xSW Aw1ytsfj4jXlqXqHBonp2tlb8s+fVXIkQem9WvL+DCJkFfNxY4PnYIoxA4OvtWLtcXXH keCg== X-Gm-Message-State: AAQBX9dLmUGzTCf3wbt9b3jQUIHdfDBiC2D+ayVgX8cHzdx1lSby451r o2tqkKnwOz8TqkLINVyR+0oq X-Received: by 2002:ad4:5baf:0:b0:5ef:50ea:2914 with SMTP id 15-20020ad45baf000000b005ef50ea2914mr4886152qvq.22.1681496090079; Fri, 14 Apr 2023 11:14:50 -0700 (PDT) Received: from localhost (pool-68-160-166-30.bstnma.fios.verizon.net. [68.160.166.30]) by smtp.gmail.com with ESMTPSA id fb9-20020ad44f09000000b005e9a1409458sm1277586qvb.71.2023.04.14.11.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:14:49 -0700 (PDT) Date: Fri, 14 Apr 2023 14:14:48 -0400 From: Mike Snitzer To: Sarthak Kukreti , Joe Thornber Cc: Jens Axboe , Christoph Hellwig , Theodore Ts'o , "Michael S. Tsirkin" , sarthakkukreti@google.com, "Darrick J. Wong" , Jason Wang , Bart Van Assche , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, Andreas Dilger , Daniil Lunev , Stefan Hajnoczi , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Brian Foster , Alasdair Kergon Subject: Re: [PATCH v3 2/3] dm: Add support for block provisioning Message-ID: References: <20221229071647.437095-1-sarthakkukreti@chromium.org> <20230414000219.92640-1-sarthakkukreti@chromium.org> <20230414000219.92640-3-sarthakkukreti@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, Apr 14 2023 at 9:32P -0400, Joe Thornber wrote: > On Fri, Apr 14, 2023 at 7:52 AM Sarthak Kukreti > wrote: > > > Add support to dm devices for REQ_OP_PROVISION. The default mode > > is to passthrough the request to the underlying device, if it > > supports it. dm-thinpool uses the provision request to provision > > blocks for a dm-thin device. dm-thinpool currently does not > > pass through REQ_OP_PROVISION to underlying devices. > > > > For shared blocks, provision requests will break sharing and copy the > > contents of the entire block. > > > > I see two issue with this patch: > > i) You use get_bio_block_range() to see which blocks the provision bio > covers. But this function only returns > complete blocks that are covered (it was designed for discard). Unlike > discard, provision is not a hint so those > partial blocks will need to be provisioned too. > > ii) You are setting off multiple dm_thin_new_mapping operations in flight > at once. Each of these receives > the same virt_cell and frees it when it completes. So I think we have > multiple frees occuring? In addition you also > release the cell yourself in process_provision_cell(). Fixing this is not > trivial, you'll need to reference count the cells, > and aggregate the mapping operation results. > > I think it would be far easier to restrict the size of the provision bio to > be no bigger than one thinp block (as we do for normal io). This way dm > core can split the bios, chain the child bios rather than having to > reference count mapping ops, and aggregate the results. I happened to be looking at implementing WRITE_ZEROES support for DM thinp yesterday and reached the same conclussion relative to it (both of Joe's points above, for me "ii)" was: the dm-bio-prison-v1 range locking we do for discards needs work for other types of IO). We can work to make REQ_OP_PROVISION spanning multiple thinp blocks possible as follow-on optimization; but in the near-term DM thinp needs REQ_OP_PROVISION to be split on a thinp block boundary. This splitting can be assisted by block core in terms of a new 'provision_granularity' (which for thinp, it'd be set to the thinp blocksize). But I don't know that we need to go that far (I'm thinking its fine to have DM do the splitting it needs and only elevate related code to block core if/when needed in the future). DM core can take on conditionally imposing its max_io_len() to handle splitting REQ_OP_PROVISION as needed on a per-target basis. This DM core commit I've staged for 6.4 makes this quite a simple change: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-6.4&id=13f6facf3faeed34ca381aef4c9b153c7aed3972 So please rebase on linux-dm.git's dm-6.4 branch, and for REQ_OP_PROVISION dm.c:__process_abnormal_io() you'd add this: case REQ_OP_PROVISION: num_bios = ti->num_provision_bios; if (ti->max_provision_granularity) max_granularity = limits->max_provision_sectors; break; I'll reply again later today (to patch 2's actual code changes), because I caught at least one other thing worth mentioning. Thanks, Mike