Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1244930rwd; Thu, 8 Jun 2023 14:50:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Py5MkbLFo4XShOWgAL8qVaQDdXEepeCRxFCs93Nozq2nBQJrbEiFDSnikqGJ6b+LRGhv5 X-Received: by 2002:a17:90a:6848:b0:256:3188:7ee6 with SMTP id e8-20020a17090a684800b0025631887ee6mr4973949pjm.45.1686261041837; Thu, 08 Jun 2023 14:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686261041; cv=none; d=google.com; s=arc-20160816; b=iMApSpbTTcUAs0HiCzpjGKSq4PJ9NeFmxtniqRot6AakxaOAW2uXvLHBQFHuslwqsu hbzdh7LP574iEg3LrrjEApnPVGsGWtbN1fVORDaBCdSLdfrsgRiCmSoVxz1yiJ30NWRI N9XfVAUthNs0Ds6Gwlmzd+B6JwVopYu/BFTPM8ZhsQueM9AKONGQPMkRwPMcCM7hB0Tg z+GsSyX8Q0KDVXv/N+Fx+qD8v6HIYxqIap7HMCyw9wC9YS+ex8MUw6QBh2PqXDPwUD1j Y1Oh5FLolFafqRuCzo722nDERrJ0z4kq5toS21XZhQ7XP/6c8n4ZfUx0jNTbxzhO4igk +MDw== 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; bh=liAgCM+QUjk8WKzG6uC2H2ST/koBGGcMOvClrIQqatc=; b=ye5wNOl+5yXwDJpirzors3GHkK088Bm/9SVaXxB0CeGGpEP+0nXozFFb+v6Y0vFhKJ zqnfIXltSyzQa4KzQnTHNiGJrtTqgzY/uPJ5EZXyxS57iICJPBP/tz6xdEGvQ/R3O5g/ L0U9n3iw0gn4BExsAoOFzY5zeYOdH/XGr/zScwS/IroGDFYceIIiCdXw84dus0os2kiz sTNjihEj//ggpfSsFsyrB/xSAnGA3sAef3MH5hGc0Xijq6f+0QtGZx4pG43+aRqU4UDl PeEu49OVe0vAan3/HE89U/ugCOSFEpU1E/rujnODNUc5e1yp1AEHe3UkeNmnMqrOdv1P 9mqA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a71-20020a63904a000000b00530b1e7099dsi1525700pge.84.2023.06.08.14.50.22; Thu, 08 Jun 2023 14:50:41 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237040AbjFHVZk (ORCPT + 99 others); Thu, 8 Jun 2023 17:25:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236177AbjFHVZg (ORCPT ); Thu, 8 Jun 2023 17:25:36 -0400 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F2712D7B for ; Thu, 8 Jun 2023 14:24:50 -0700 (PDT) Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-75d57fdb014so98324685a.0 for ; Thu, 08 Jun 2023 14:24:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686259489; x=1688851489; 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=liAgCM+QUjk8WKzG6uC2H2ST/koBGGcMOvClrIQqatc=; b=XmCdSnB/jdcuKE5YX2jDFrwP60k35iUVre49vskJ3o17ELZmbaKxozkIYo5MFv10hB XmsrCuLvnIXkJIOJldwjKI10inMb9jycPcO49+ZJ6E7JgA3y+V/qVEpTm9xbXpflddh2 9cYFaKc/WmIANv3RSSY+HGJxM4iu0sdqWhNayufOGNF4ggBs5uMnMveKaaWtGuC/CEsj PPXicrFxiQhWZMb3obLTbhwO+eK6ybnyfcj/1HVmpgwKUjZk7of0+pG29MKZKLU5eDNF QR+VKpQ0Nl/Im2AK37Y3Htx2DNygzZ1fg9rth9/cERfNtYzrheC86/zweezkt8nsfS80 X5Og== X-Gm-Message-State: AC+VfDz89yBaXsGr6CpkxQlaa7ZQWPNIc94zOkXzrvNtUpVTprvn11x2 cYO03Zmw2NVO2vLhF+s7zX+M X-Received: by 2002:a05:6214:c88:b0:628:c4c8:4afb with SMTP id r8-20020a0562140c8800b00628c4c84afbmr3203617qvr.60.1686259489142; Thu, 08 Jun 2023 14:24:49 -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 g16-20020ac84690000000b003f8e6071e43sm669752qto.3.2023.06.08.14.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 14:24:48 -0700 (PDT) Date: Thu, 8 Jun 2023 17:24:47 -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=-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-ext4@vger.kernel.org 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. Mike