Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9336090rwr; Thu, 11 May 2023 13:25:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QSG2DjQ7hFqLVSjbEQ0VRpSt9eGv6rX5nkdGM98pSYmu3iQ0H5ko7VF2JwXBmQtOcAU7/ X-Received: by 2002:a05:6a00:1a89:b0:63f:1037:cc24 with SMTP id e9-20020a056a001a8900b0063f1037cc24mr26914708pfv.32.1683836732478; Thu, 11 May 2023 13:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683836732; cv=none; d=google.com; s=arc-20160816; b=BMSYJLC+nDW6cO0xc5emc7V8xRJNMTmCZHaLCRpYqxbAm3f/2+RTHiWEkDhpgqwmRt CW74QDJBiatizIbRY3qNp/pzSNveNQjGWRKzA5EiCOf0Lou3Rltv9M9xnvUoA2pmnUAb 5B+XakuZQOm72tU2TiD/sPxCAMjOmy29S85AIBefQf8TNf7HR4nEnnI0kND7jDRJr0eN YPQryJUXM/olzxhgy5ptCyxYthpmE62vG9IPdLFha65j0LWbSUrDsCQk1yoXq20QDzzC 7VqFfArmLXOs2OTX7iC4V8DfmZKf7JQ7Yci7yoUdhJPgxpE/r7E89SYxcp81SSk+pIqQ A46A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=U8xH7zGQzzRbqK6D4Oqhm3xKHhC25ViGnrUjwC/gsSw=; b=oUKyzvWz6ohovwlVpm274rkbSPpsyNXVKSrylxz0SILra0ehiSoquqzlIFB36Jgqlr LAYIYJMas3/tTv4a9XaNsXgBnEmJyj2TqrFQYA6Bg0/tfk9uO9RPftwUpuSYRmxut9tS 95vrdLp9j6UD5rUEDt146qjK/hP2xBZjPsgtGRX2Im34qfsJK8SOBx+u2Cns6dfkOV9a dPKU8PSMgNSr/0eZbkQmhCBbw9oP7lIueJs/4UHwG0VZdFKI9kGRsH4horybu+VMtIEg RP/sKP3Sd9yvhr9fznB/KbbHUCbCV3u+rpW7iXIO13e3Qnvo0rCtVtldm6cBFiv/Darf 2/Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MW5xkfBK; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r144-20020a632b96000000b0052c5a49b7a4si7527657pgr.542.2023.05.11.13.25.13; Thu, 11 May 2023 13:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@chromium.org header.s=google header.b=MW5xkfBK; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239608AbjEKUDk (ORCPT + 99 others); Thu, 11 May 2023 16:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239601AbjEKUDi (ORCPT ); Thu, 11 May 2023 16:03:38 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 169E96599 for ; Thu, 11 May 2023 13:03:36 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-50bc4bc2880so14078601a12.2 for ; Thu, 11 May 2023 13:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683835414; x=1686427414; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=U8xH7zGQzzRbqK6D4Oqhm3xKHhC25ViGnrUjwC/gsSw=; b=MW5xkfBKg7R27pQpq6VOVNVFJBGddm5iGtOfa0k1cfyLC9VX049iC1rmEI6Fl/GVrk 7KKp7M8jRu3u4zh+yk6X15HS11ERm6dMK4kr50yDNyZFYvNqTYalyzCbsc1AAdQimZEp nSfhnGrqTLLb7MBOSSUVZ5FhH2Rqs6nIRmhZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683835414; x=1686427414; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U8xH7zGQzzRbqK6D4Oqhm3xKHhC25ViGnrUjwC/gsSw=; b=dlCQ9dFmUwSKvu55NVCUgtwyjYB/CpXCReL4b78RyfTMVZ4eCIB9Hb4TGil1v953QY Fx0L0nt+k0zj7A8yUC5aHUHPErhrEsgBtrkuDCKmFIpI/2BAzpexcQforEfMVq5a7gen GynGvJsPWewr2pJdST/MKoCwAhozgDds7OD2gBiLO6KZ4d2MhsZaV8AQzccwfZnGJUw+ xQXmzf2sthxffWY3J5xfLYqOml/QoOyvhQr5cG+wCe3c/Z9uqGcEa8feJMiGzBTFjfp1 fuzBQJe+g39Im9EwOu3Rkqb9SSC49aebGFcC8+dzgoNvWPforNHChCdRXRukPzDJbgwq XEew== X-Gm-Message-State: AC+VfDzuIV8qimsL/Zm/EreQSDxa1F9P7eK6BH6cfINvVqZGam3S9eA8 ekSJnW2xXx5ecU1+32EtIj2/KLlYNox+Hkb4YYuVDw== X-Received: by 2002:a17:907:9694:b0:969:ba95:a3a0 with SMTP id hd20-20020a170907969400b00969ba95a3a0mr12334138ejc.23.1683835414423; Thu, 11 May 2023 13:03:34 -0700 (PDT) MIME-Version: 1.0 References: <20230420004850.297045-1-sarthakkukreti@chromium.org> <20230506062909.74601-1-sarthakkukreti@chromium.org> <20230506062909.74601-5-sarthakkukreti@chromium.org> In-Reply-To: From: Sarthak Kukreti Date: Thu, 11 May 2023 13:03:23 -0700 Message-ID: Subject: Re: [PATCH v6 4/5] dm-thin: Add REQ_OP_PROVISION support To: Mike Snitzer Cc: dm-devel@redhat.com, linux-block@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe , "Theodore Ts'o" , "Michael S. Tsirkin" , "Darrick J. Wong" , Jason Wang , Bart Van Assche , Christoph Hellwig , Andreas Dilger , Stefan Hajnoczi , Brian Foster , Alasdair Kergon Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-ext4@vger.kernel.org On Tue, May 9, 2023 at 9:58=E2=80=AFAM Mike Snitzer wr= ote: > > On Sat, May 06 2023 at 2:29P -0400, > Sarthak Kukreti wrote: > > > 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. Additionally, if 'skip_block_zeroing' > > is not set, dm-thin will opt to zero out the entire range as a part > > of provisioning. > > > > Signed-off-by: Sarthak Kukreti > > --- > > drivers/md/dm-thin.c | 70 +++++++++++++++++++++++++++++++++++++++++--- > > 1 file changed, 66 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c > > index 2b13c949bd72..3f94f53ac956 100644 > > --- a/drivers/md/dm-thin.c > > +++ b/drivers/md/dm-thin.c > > @@ -274,6 +274,7 @@ struct pool { > > > > process_bio_fn process_bio; > > process_bio_fn process_discard; > > + process_bio_fn process_provision; > > > > process_cell_fn process_cell; > > process_cell_fn process_discard_cell; > > @@ -913,7 +914,8 @@ static void __inc_remap_and_issue_cell(void *contex= t, > > struct bio *bio; > > > > while ((bio =3D bio_list_pop(&cell->bios))) { > > - if (op_is_flush(bio->bi_opf) || bio_op(bio) =3D=3D REQ_OP= _DISCARD) > > + if (op_is_flush(bio->bi_opf) || bio_op(bio) =3D=3D REQ_OP= _DISCARD || > > + bio_op(bio) =3D=3D REQ_OP_PROVISION) > > bio_list_add(&info->defer_bios, bio); > > else { > > inc_all_io_entry(info->tc->pool, bio); > > @@ -1245,8 +1247,8 @@ static int io_overlaps_block(struct pool *pool, s= truct bio *bio) > > > > static int io_overwrites_block(struct pool *pool, struct bio *bio) > > { > > - return (bio_data_dir(bio) =3D=3D WRITE) && > > - io_overlaps_block(pool, bio); > > + return (bio_data_dir(bio) =3D=3D WRITE) && io_overlaps_block(pool= , bio) && > > + bio_op(bio) !=3D REQ_OP_PROVISION; > > } > > > > static void save_and_set_endio(struct bio *bio, bio_end_io_t **save, > > @@ -1953,6 +1955,51 @@ static void provision_block(struct thin_c *tc, s= truct bio *bio, dm_block_t block > > } > > } > > > > +static void process_provision_bio(struct thin_c *tc, struct bio *bio) > > +{ > > + int r; > > + struct pool *pool =3D tc->pool; > > + dm_block_t block =3D get_bio_block(tc, bio); > > + struct dm_bio_prison_cell *cell; > > + struct dm_cell_key key; > > + struct dm_thin_lookup_result lookup_result; > > + > > + /* > > + * If cell is already occupied, then the block is already > > + * being provisioned so we have nothing further to do here. > > + */ > > + build_virtual_key(tc->td, block, &key); > > + if (bio_detain(pool, &key, bio, &cell)) > > + return; > > + > > + if (tc->requeue_mode) { > > + cell_requeue(pool, cell); > > + return; > > + } > > + > > + r =3D dm_thin_find_block(tc->td, block, 1, &lookup_result); > > + switch (r) { > > + case 0: > > + if (lookup_result.shared) { > > + process_shared_bio(tc, bio, block, &lookup_result= , cell); > > + } else { > > + bio_endio(bio); > > + cell_defer_no_holder(tc, cell); > > + } > > + break; > > + case -ENODATA: > > + provision_block(tc, bio, block, cell); > > + break; > > + > > + default: > > + DMERR_LIMIT("%s: dm_thin_find_block() failed: error =3D %= d", > > + __func__, r); > > + cell_defer_no_holder(tc, cell); > > + bio_io_error(bio); > > + break; > > + } > > +} > > + > > static void process_cell(struct thin_c *tc, struct dm_bio_prison_cell = *cell) > > { > > int r; > > @@ -2228,6 +2275,8 @@ static void process_thin_deferred_bios(struct thi= n_c *tc) > > > > if (bio_op(bio) =3D=3D REQ_OP_DISCARD) > > pool->process_discard(tc, bio); > > + else if (bio_op(bio) =3D=3D REQ_OP_PROVISION) > > + pool->process_provision(tc, bio); > > else > > pool->process_bio(tc, bio); > > > > @@ -2579,6 +2628,7 @@ static void set_pool_mode(struct pool *pool, enum= pool_mode new_mode) > > dm_pool_metadata_read_only(pool->pmd); > > pool->process_bio =3D process_bio_fail; > > pool->process_discard =3D process_bio_fail; > > + pool->process_provision =3D process_bio_fail; > > pool->process_cell =3D process_cell_fail; > > pool->process_discard_cell =3D process_cell_fail; > > pool->process_prepared_mapping =3D process_prepared_mappi= ng_fail; > > @@ -2592,6 +2642,7 @@ static void set_pool_mode(struct pool *pool, enum= pool_mode new_mode) > > dm_pool_metadata_read_only(pool->pmd); > > pool->process_bio =3D process_bio_read_only; > > pool->process_discard =3D process_bio_success; > > + pool->process_provision =3D process_bio_fail; > > pool->process_cell =3D process_cell_read_only; > > pool->process_discard_cell =3D process_cell_success; > > pool->process_prepared_mapping =3D process_prepared_mappi= ng_fail; > > @@ -2612,6 +2663,7 @@ static void set_pool_mode(struct pool *pool, enum= pool_mode new_mode) > > pool->out_of_data_space =3D true; > > pool->process_bio =3D process_bio_read_only; > > pool->process_discard =3D process_discard_bio; > > + pool->process_provision =3D process_bio_fail; > > pool->process_cell =3D process_cell_read_only; > > pool->process_prepared_mapping =3D process_prepared_mappi= ng; > > set_discard_callbacks(pool); > > @@ -2628,6 +2680,7 @@ static void set_pool_mode(struct pool *pool, enum= pool_mode new_mode) > > dm_pool_metadata_read_write(pool->pmd); > > pool->process_bio =3D process_bio; > > pool->process_discard =3D process_discard_bio; > > + pool->process_provision =3D process_provision_bio; > > pool->process_cell =3D process_cell; > > pool->process_prepared_mapping =3D process_prepared_mappi= ng; > > set_discard_callbacks(pool); > > @@ -2749,7 +2802,8 @@ static int thin_bio_map(struct dm_target *ti, str= uct bio *bio) > > return DM_MAPIO_SUBMITTED; > > } > > > > - if (op_is_flush(bio->bi_opf) || bio_op(bio) =3D=3D REQ_OP_DISCARD= ) { > > + if (op_is_flush(bio->bi_opf) || bio_op(bio) =3D=3D REQ_OP_DISCARD= || > > + bio_op(bio) =3D=3D REQ_OP_PROVISION) { > > thin_defer_bio_with_throttle(tc, bio); > > return DM_MAPIO_SUBMITTED; > > } > > @@ -3396,6 +3450,9 @@ static int pool_ctr(struct dm_target *ti, unsigne= d int argc, char **argv) > > pt->adjusted_pf =3D pt->requested_pf =3D pf; > > ti->num_flush_bios =3D 1; > > ti->limit_swap_bios =3D true; > > + ti->num_provision_bios =3D 1; > > + ti->provision_supported =3D true; > > + ti->max_provision_granularity =3D true; > > > > /* > > * Only need to enable discards if the pool should pass > > @@ -4114,6 +4171,8 @@ static void pool_io_hints(struct dm_target *ti, s= truct queue_limits *limits) > > * The pool uses the same discard limits as the underlying data > > * device. DM core has already set this up. > > */ > > + > > + limits->max_provision_sectors =3D pool->sectors_per_block; > > } > > > > static struct target_type pool_target =3D { > > @@ -4288,6 +4347,9 @@ static int thin_ctr(struct dm_target *ti, unsigne= d int argc, char **argv) > > ti->max_discard_granularity =3D true; > > } > > > > + ti->num_provision_bios =3D 1; > > + ti->provision_supported =3D true; > > + > > We need this in thin_ctr: ti->max_provision_granularity =3D true; > > More needed in the thin target than thin-pool; otherwise provision bio > issued to thin devices won't be split appropriately. But I do think > its fine to set in both thin_ctr and pool_ctr. > > Otherwise, looks good. > Thanks! I'll add it to the next iteration (in addition to any other feedback that's added to v6). Given that this series covers multiple subsystems, would there be a preferred way of queueing this for merge? Best Sarthak > Thanks, > Mike