Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5893rwd; Wed, 24 May 2023 13:14:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42RJqX6FOikSUW+6A9MM5Bg2aDP+uFyeZ4KD6VS5dlKgbEFqTCovuwdcSV8bVAC78l1QR6 X-Received: by 2002:a05:6a00:802:b0:64d:61f2:ca88 with SMTP id m2-20020a056a00080200b0064d61f2ca88mr4926857pfk.12.1684959272741; Wed, 24 May 2023 13:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684959272; cv=none; d=google.com; s=arc-20160816; b=lOSCmMbG7H4AfcZFSs1S/38isKIBaHxmuZy+UU9iTv3GDLZ1f3OPdZ54hsk5nx7Vsw /qqyjyd1Y/AP4EjBgY0cfM77nmxTrrxq5VqwSbuveB1+xM3tNTArAt0gKlPX02nIt3C7 AN4Dv+tadz2UEqABROGTeV8/CBFuKoZ2HZqavu3iyB8M+5FJ57nYzz0kwxKAS5ENveGs vuKgxctKUrpAIT26iiZHqPnxGonTZ6MsmfjoIJwKniCQ4X5ePp6GRUoJsegYRmYZVLYT QtvqOgC4/psYaFW2RBi3V78Wwct/PlkJHt3GUVKkOB8llbEylFu1kguxYjGvQiTlawCL 7xeg== 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=wc0lEJ6PvCd/xSxo1AL44vYdysUGzpOXm110SXEKBVE=; b=FHS/iZFMZKy6+EPI27p37aifp2j9BJLg1ogJPASoHyZPmSrP7gZD4W2sJHbubBiqna VXp9jhG91VqCCKx/uqhN9p23xNkSRDHWw2eOaG74ERbovnjJiKn48t47xFKldDmcybtn 7dzC1XxubGdnLhcyM20i1+3z7RGkisTNK1FTcsU/0QTHtuIC/gOzRhMje6q4mnSQrMyH B70+gNGXPukIET3kDUNDnJ6mMPmKvORwqQbJlOcCCG8uX6h1zykZJjjiCTniCN0d+KxB X6Ucr1bCZ1YoKE2A1fkdrJ/psouv8zJ+ArDBHo0CGRJ0mqDqxVJ+3lFNBAFVFKq0jjw4 WjQw== 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 p124-20020a622982000000b0063bcab61625si8885261pfp.178.2023.05.24.13.13.46; Wed, 24 May 2023 13:14: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; 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 S231494AbjEXUDf (ORCPT + 99 others); Wed, 24 May 2023 16:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbjEXUDf (ORCPT ); Wed, 24 May 2023 16:03:35 -0400 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2DBFC for ; Wed, 24 May 2023 13:02:52 -0700 (PDT) Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-75b2a2bf757so9791085a.2 for ; Wed, 24 May 2023 13:02:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684958571; x=1687550571; 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=wc0lEJ6PvCd/xSxo1AL44vYdysUGzpOXm110SXEKBVE=; b=EHKJUL2CV/G9/M3ehynyCRLOQFhPuuRFai6dwMQRs7kqwD33EqJAvtcsl/WNYz1Ss6 +4eHpcGE8qqV7qn9kaTq68aVSFBdp90DGmBo6KvBtrdb8B5loWsztEoXKhkmuJBDpWam U8FI9/Nd+9BeFyoVC/52Ld1BSTOX+ARBsojl0ZLoQxkbTO2Jp5BLmoVHk6+iuWvixm7H AM/FHpxPs+tp91BPvtbbnpGkrvq1JRn6QDyFuJftkjeqDLPAFiQnPLTDuDc6kUVICH7N XqyZVHCML+M0BDv6kLB6Umb1G3jSLbmYB0bidr8hf3iP0RL1fDdCH+9vykLN7E8uq7DL VJOw== X-Gm-Message-State: AC+VfDxN5+vvylZoeO2gRK0Mg2We/04c0b2XPYd5qtvVG5vDQOMW7VxE qkazto7tYVVXMNnWZq+QHxoL X-Received: by 2002:ae9:d60e:0:b0:75b:23a1:3671 with SMTP id r14-20020ae9d60e000000b0075b23a13671mr9242472qkk.50.1684958571318; Wed, 24 May 2023 13:02:51 -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 v20-20020a05620a123400b0074d60b697a6sm3496740qkj.12.2023.05.24.13.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 13:02:50 -0700 (PDT) Date: Wed, 24 May 2023 16:02:49 -0400 From: Mike Snitzer To: Dave Chinner Cc: Jens Axboe , linux-block@vger.kernel.org, Theodore Ts'o , Stefan Hajnoczi , "Michael S. Tsirkin" , "Darrick J. Wong" , Brian Foster , Bart Van Assche , linux-kernel@vger.kernel.org, Joe Thornber , Christoph Hellwig , dm-devel@redhat.com, Andreas Dilger , Sarthak Kukreti , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Jason Wang , Alasdair Kergon Subject: Re: [PATCH v7 0/5] Introduce provisioning primitives Message-ID: References: <20230518223326.18744-1-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 Tue, May 23 2023 at 8:40P -0400, Dave Chinner wrote: > On Tue, May 23, 2023 at 11:26:18AM -0400, Mike Snitzer wrote: > > On Tue, May 23 2023 at 10:05P -0400, Brian Foster wrote: > > > On Mon, May 22, 2023 at 02:27:57PM -0400, Mike Snitzer wrote: > > > ... since I also happen to think there is a potentially interesting > > > development path to make this sort of reserve pool configurable in terms > > > of size and active/inactive state, which would allow the fs to use an > > > emergency pool scheme for managing metadata provisioning and not have to > > > track and provision individual metadata buffers at all (dealing with > > > user data is much easier to provision explicitly). So the space > > > inefficiency thing is potentially just a tradeoff for simplicity, and > > > filesystems that want more granularity for better behavior could achieve > > > that with more work. Filesystems that don't would be free to rely on the > > > simple/basic mechanism provided by dm-thin and still have basic -ENOSPC > > > protection with very minimal changes. > > > > > > That's getting too far into the weeds on the future bits, though. This > > > is essentially 99% a dm-thin approach, so I'm mainly curious if there's > > > sufficient interest in this sort of "reserve mode" approach to try and > > > clean it up further and have dm guys look at it, or if you guys see any > > > obvious issues in what it does that makes it potentially problematic, or > > > if you would just prefer to go down the path described above... > > > > The model that Dave detailed, which builds on REQ_PROVISION and is > > sticky (by provisioning same blocks for snapshot) seems more useful to > > me because it is quite precise. That said, it doesn't account for > > hard requirements that _all_ blocks will always succeed. > > Hmmm. Maybe I'm misunderstanding the "reserve pool" context here, > but I don't think we'd ever need a hard guarantee from the block > device that every write bio issued from the filesystem will succeed > without ENOSPC. > > If the block device can provide a guarantee that a provisioned LBA > range is always writable, then everything else is a filesystem level > optimisation problem and we don't have to involve the block device > in any way. All we need is a flag we can ready out of the bdev at > mount time to determine if the filesystem should be operating with > LBA provisioning enabled... > > e.g. If we need to "pre-provision" a chunk of the LBA space for > filesystem metadata, we can do that ahead of time and track the > pre-provisioned range(s) in the filesystem itself. > > In XFS, That could be as simple as having small chunks of each AG > reserved to metadata (e.g. start with the first 100MB) and limiting > all metadata allocation free space searches to that specific block > range. When we run low on that space, we pre-provision another 100MB > chunk and then allocate all metadata out of that new range. If we > start getting ENOSPC to pre-provisioning, then we reduce the size of > the regions and log low space warnings to userspace. If we can't > pre-provision any space at all and we've completely run out, we > simply declare ENOSPC for all incoming operations that require > metadata allocation until pre-provisioning succeeds again. This is basically saying the same thing but: It could be that the LBA space is fragmented and so falling back to the smallest region size (that matches the thinp block size) would be the last resort? Then if/when thinp cannot even service allocating a new free thin block, dm-thinp will transition to out-of-data-space mode. > This is built entirely on the premise that once proactive backing > device provisioning fails, the backing device is at ENOSPC and we > have to wait for that situation to go away before allowing new data > to be ingested. Hence the block device really doesn't need to know > anything about what the filesystem is doing and vice versa - The > block dev just says "yes" or "no" and the filesystem handles > everything else. Yes. > It's worth noting that XFS already has a coarse-grained > implementation of preferred regions for metadata storage. It will > currently not use those metadata-preferred regions for user data > unless all the remaining user data space is full. Hence I'm pretty > sure that a pre-provisioning enhancment like this can be done > entirely in-memory without requiring any new on-disk state to be > added. > > Sure, if we crash and remount, then we might chose a different LBA > region for pre-provisioning. But that's not really a huge deal as we > could also run an internal background post-mount fstrim operation to > remove any unused pre-provisioning that was left over from when the > system went down. This would be the FITRIM with extension you mention below? Which is a filesystem interface detail? So dm-thinp would _not_ need to have new state that tracks "provisioned but unused" block? Nor would the block layer need an extra discard flag for a new class of "provisioned" blocks. If XFS tracked this "provisioned but unused" state, dm-thinp could just discard the block like its told. Would be nice to avoid dm-thinp needing to track "provisioned but unused". That said, dm-thinp does still need to know if a block was provisioned (given our previous designed discussion, to allow proper guarantees from this interface at snapshot time) so that XFS and other filesystems don't need to re-provision areas they already pre-provisioned. However, it may be that if thinp did track "provisioned but unused" it'd be useful to allow snapshots to share provisioned blocks that were never used. Meaning, we could then avoid "breaking sharing" at snapshot-time for "provisioned but unused" blocks. But allowing this "optimization" undercuts the gaurantee that XFS needs for thinp storage that allows snapshots... SO, I think I answered my own question: thinp doesnt need to track "provisioned but unused" blocks but we must always ensure snapshots inherit provisoned blocks ;) > Further, managing shared pool exhaustion doesn't require a > reservation pool in the backing device and for the filesystems to > request space from it. Filesystems already have their own reserve > pools via pre-provisioning. If we want the filesystems to be able to > release that space back to the shared pool (e.g. because the shared > backing pool is critically short on space) then all we need is an > extension to FITRIM to tell the filesystem to also release internal > pre-provisioned reserves. So by default FITRIM will _not_ discard provisioned blocks. Only if a flag is used will it result in discarding provisioned blocks. My dwelling on this is just double-checking that the > Then the backing pool admin (person or automated daemon!) can simply > issue a trim on all the filesystems in the pool and spce will be > returned. Then filesystems will ask for new pre-provisioned space > when they next need to ingest modifications, and the backing pool > can manage the new pre-provisioning space requests directly.... > > Hence I think if we get the basic REQ_PROVISION overwrite-in-place > guarantees defined and implemented as previously outlined, then we > don't need any special coordination between the fs and block devices > to avoid fatal ENOSPC issues with sparse and/or snapshot capable > block devices... > > As a bonus, if we can implement the guarantees in dm-thin/-snapshot > and have a filesystem make use of it, then we also have a reference > implementation to point at device vendors and standards > associations.... Yeap. Thanks, Mike