Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1381331rwd; Thu, 8 Jun 2023 17:33:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zw4ltD2KttqxEfee26qN5cfdk7uJjR7QVcz3W7pBdwF89g65imqpiyIwXBqQSG7ednFeN X-Received: by 2002:a05:6358:c420:b0:129:f892:377a with SMTP id ff32-20020a056358c42000b00129f892377amr3105368rwb.13.1686270809643; Thu, 08 Jun 2023 17:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686270809; cv=none; d=google.com; s=arc-20160816; b=RMNAjLxYoXaX5PrpGDG/Lc9m2Fjp1//RuF/jnsDOXDxlqH7YVgoZ0DP14cvWVKdsSE baWyCGgvZvpe1qmhxnM+xbYc0n14RzC7ZKdc6rkU6U4P79lKdouJls8BJPooRXP4z9IW Zw0YReb56xVFwqz5P+rvPTrPQO4clRhf0QGvu9u22FctzDmPu9FzDLz2zEStNZANidgk 8gw2dSCAjHsXcLnf+w1QKihcQK+tWHd/ilLDCCGOIXfKbdVxe/QNw+SWHci7jnFl/7rv v7UQ4lDCLtGyHIDV/mxvjXCIbEHvlT3c7wKlWuxcYoUyieCMhiE6p9AwhrLi1h3O/V1l lCpg== 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=dZ0yORwAdXDCRd2fZyWQ1kLxeAr//tPmWz4kXkYhyTs=; b=lBzTNTxJJ6b3R74Lo01+i4qSDxitrwFIT0YIaPPgrT79zZRRh/X3ze7YxiFQmQdOu2 FlMIEmyVqjsQLKxZm+ny0yByDcd62/3TlKtC73//nwORFeSw5xLvh9QkHtYsuUVPRACu g2eO82m1IfgkoRdHAEw0apl+UcgTy58Q3J+wmgNHnDOgYJmTFJN/brtwTKyH7z/QCBhE n2DAXqIRVREgNIYph/ZCesxL/YaePgvTEc3Btu5gS2Jld9urLmN0BA7oy+8ubNl6jJR5 Q/iCvclI+AVJWIwFg969pQFlec7q2b3XEYWDVjGgJLH/j2puy5RjYgJcBNivp0Hhy0IE 981w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hXPJ4Mq2; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q141-20020a632a93000000b005341d2aa9dfsi1781789pgq.622.2023.06.08.17.33.16; Thu, 08 Jun 2023 17:33:29 -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=@redhat.com header.s=mimecast20190719 header.b=hXPJ4Mq2; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234171AbjFIA3P (ORCPT + 99 others); Thu, 8 Jun 2023 20:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233006AbjFIA3O (ORCPT ); Thu, 8 Jun 2023 20:29:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9B22115 for ; Thu, 8 Jun 2023 17:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686270505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dZ0yORwAdXDCRd2fZyWQ1kLxeAr//tPmWz4kXkYhyTs=; b=hXPJ4Mq2xmy0Wx5QK6P8mfWuLURkfbMnA8j5/3Jt4knvnW72dtCqgaPgHfS/Og8Qhj8TSA kPenl8lmBHwS2ugNNPbk6/1FASkTbN0tyg6bw8XO9onELBgON11SSfveaXGDFzxX4+2T6O /6lJBPOntyTfFHGe0B7qgKUi57CkE88= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-438-uqWmRud8NzyYY0KVjvLeOw-1; Thu, 08 Jun 2023 20:28:19 -0400 X-MC-Unique: uqWmRud8NzyYY0KVjvLeOw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-75d8e5ddc93so150408585a.0 for ; Thu, 08 Jun 2023 17:28:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686270498; x=1688862498; h=in-reply-to: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=dZ0yORwAdXDCRd2fZyWQ1kLxeAr//tPmWz4kXkYhyTs=; b=C3mt6Y5XRqt6lmnvzlIpEzGUo82cQjqs0idQp0Jq/xLB50I8PzoITgvp4/nlxlwmIB vJDO5xzOOJnthRu02Cp7kHbuc4pha31up23hdBoYH8Z1fzq+uJj/482QWwjUT4g5+rxs cTiFhBy6Wora+T5ljOPkbFQj5PoxguAJyOLPT8PTdgT8fYobu+XFHvSbmKP7bpZ7erVQ 0AW565ewF2KC7zJiTBijHxaMJxZ6ct+p35ozz01tBynBdr1d/H8AMBK3mP6gmYwSGo7J 2w21EOoomTsgykWxa0iQLQl54AEaHJqg6ZH/ucFt7bCDOri04qW8MtHrYdZA19Qvz1nv tt+w== X-Gm-Message-State: AC+VfDy+6NzQEEhv38BL9/bYKdnEzOdFt0jKRj049LP5IE1jYdQbdMYK PjfFqLVV+mFyIljlym8j3v2C27i1CW1Bj6RGtU6H/V6sE+bDRSd71E7NMjGBj0YROnbP9ZBDsvW agdzQFOtHThFp79+i2c8F X-Received: by 2002:a05:620a:2810:b0:75b:23a1:830c with SMTP id f16-20020a05620a281000b0075b23a1830cmr6973242qkp.7.1686270498614; Thu, 08 Jun 2023 17:28:18 -0700 (PDT) X-Received: by 2002:a05:620a:2810:b0:75b:23a1:830c with SMTP id f16-20020a05620a281000b0075b23a1830cmr6973236qkp.7.1686270498360; Thu, 08 Jun 2023 17:28:18 -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 m14-20020a05620a13ae00b0075da00ef114sm693183qki.46.2023.06.08.17.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 17:28:17 -0700 (PDT) Date: Thu, 8 Jun 2023 20:28:16 -0400 From: Mike Snitzer To: Sarthak Kukreti , Joe Thornber , Brian Foster 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 , Alasdair Kergon Subject: Re: [PATCH v7 4/5] dm-thin: Add REQ_OP_PROVISION support Message-ID: References: <20230518223326.18744-1-sarthakkukreti@chromium.org> <20230518223326.18744-5-sarthakkukreti@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 Thu, Jun 08 2023 at 5:24P -0400, Mike Snitzer wrote: > On Fri, May 19 2023 at 11:23P -0400, > Mike Snitzer wrote: > > > On Thu, May 18 2023 at 6:33P -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 | 74 +++++++++++++++++++++++++++++++++++++++++--- > > > 1 file changed, 70 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c > > > index 2b13c949bd72..f1b68b558cf0 100644 > > > --- a/drivers/md/dm-thin.c > > > +++ b/drivers/md/dm-thin.c > > > @@ -1245,8 +1247,8 @@ static int io_overlaps_block(struct pool *pool, struct bio *bio) > > > > > > static int io_overwrites_block(struct pool *pool, struct bio *bio) > > > { > > > - return (bio_data_dir(bio) == WRITE) && > > > - io_overlaps_block(pool, bio); > > > + return (bio_data_dir(bio) == WRITE) && io_overlaps_block(pool, bio) && > > > + bio_op(bio) != REQ_OP_PROVISION; > > > } > > > > > > static void save_and_set_endio(struct bio *bio, bio_end_io_t **save, > > > @@ -1394,6 +1396,9 @@ static void schedule_zero(struct thin_c *tc, dm_block_t virt_block, > > > m->data_block = data_block; > > > m->cell = cell; > > > > > > + if (bio && bio_op(bio) == REQ_OP_PROVISION) > > > + m->bio = bio; > > > + > > > /* > > > * If the whole block of data is being overwritten or we are not > > > * zeroing pre-existing data, we can issue the bio immediately. > > > > This doesn't seem like the best way to address avoiding passdown of > > provision bios (relying on process_prepared_mapping's implementation > > that happens to do the right thing if m->bio set). Doing so cascades > > into relying on complete_overwrite_bio() happening to _not_ actually > > being specific to "overwrite" bios. > > > > I don't have a better suggestion yet but will look closer. Just think > > this needs to be formalized a bit more rather than it happening to > > "just work". > > > > Cc'ing Joe to see what he thinks too. This is something we can clean > > up with a follow-on patch though, so not a show-stopper for this > > series. > > I haven't circled back to look close enough at this but > REQ_OP_PROVISION bios _are_ being passed down to the thin-pool's > underlying data device. > > Brian Foster reported that if he issues a REQ_OP_PROVISION to a thin > device after a snapshot (to break sharing), it'll fail with > -EOPNOTSUPP (response is from bio being passed down to device that > doesn't support it). I was able to reproduce with: > > # fallocate --offset 0 --length 1048576 /dev/test/thin > # lvcreate -n snap --snapshot test/thin > > # fallocate --offset 0 --length 1048576 /dev/test/thin > fallocate: fallocate failed: Operation not supported > > But reports success when retried: > # fallocate --offset 0 --length 1048576 /dev/test/thin > # echo $? > 0 > > It's somewhat moot in that Joe will be reimplementing handling for > REQ_OP_PROVISION _but_ in the meantime it'd be nice to have a version > of this patch that doesn't error (due to passdown of REQ_OP_PROVISION) > when breaking sharing. Primarily so the XFS guys (Dave and Brian) can > make progress. > > I'll take a closer look tomorrow but figured I'd let you know. This fixes the issue for me (causes process_prepared_mapping to end the bio without REQ_OP_PROVISION passdown). But like I said above back on May 19: needs cleanup to make it less of a hack for the REQ_OP_PROVISION case. At a minimum complete_overwrite_bio() would need renaming. diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 43a6702f9efe..434a3b37af2f 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -1324,6 +1324,9 @@ static void schedule_copy(struct thin_c *tc, dm_block_t virt_block, m->data_block = data_dest; m->cell = cell; + if (bio_op(bio) == REQ_OP_PROVISION) + m->bio = bio; + /* * quiesce action + copy action + an extra reference held for the * duration of this function (we may need to inc later for a