Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp356069rwl; Thu, 30 Mar 2023 17:31:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bExwqNdCjP99R2z9LLL0/04UAKyix5XnB9QoDLhyw7qKbm21G3mm6nWS1n6GQngILQvVBQ X-Received: by 2002:a17:906:1001:b0:93f:e5e4:8c13 with SMTP id 1-20020a170906100100b0093fe5e48c13mr15907401ejm.5.1680222673232; Thu, 30 Mar 2023 17:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680222673; cv=none; d=google.com; s=arc-20160816; b=J5czCsjLb51L8YOm3Nh6s9FM6jCnIDFVSRam4p6HZ9bKLEdqPJEmn6+ClvJ6oBpLFq yCm7G2GdJqJdeYT3fgQElY72oBGBbdnb7gJDOgZmknWyi4O4mrpWQqefJEyGwGRAsEGQ nF4QbpQFulF7mR4Il+Bswq0VXD9q3S39P3JpMqMvcowIJy5HlyuWlATYRMtppxLYgB3I fUFc147dHlAq1Enux68YEPHe8l0iWxDYSF93i0jnFxAcu2zrNeQv++t2TW6UogrDbmRb rsrY8GsElg/nkyrrMSZQSzxPlTGW0kZ2HynCTJwYYExNj6/oe/2XcpwmZKEiAP8VBBQY 3p5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=L/321qEfsdd6Li2EcEMfqC9Li7rtjZommEiuh2gRTto=; b=A2KEpHY9MM5ikoi5ewo41ipPL+j7WzcpzmrX+Rny54X6f9/GuKnAi60RURn7ELAf1V 2yd16D3Wa6FwC39ZEhvo221ZNqG/dhHSICzQrQ1V8c1DAZCzfSN6QP72Fe4e2UUyeKiM pMUdRxmf+CF1tf0308bnfJFuCtiZgTuE+9H9SclYwXTKT/Ib1NKLD9cMQjhtJkoaO0w3 cQDhApd65tDUS0o37MBYb0CE3KGOeFUVr8Lpc6FobdzkhyJpbYNak6y4wgQ5+/R8vAEM yVyLZ+FL0R4/txtrZFxuZBAEqjk1Aj4XW66cuWovuY5HJboJdA+F+MiP7GbBux1mnldF F1KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DZEf1xUJ; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a1709064e4200b008d0a9a403f8si769803ejw.796.2023.03.30.17.30.48; Thu, 30 Mar 2023 17:31:13 -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; dkim=pass header.i=@chromium.org header.s=google header.b=DZEf1xUJ; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbjCaA3F (ORCPT + 99 others); Thu, 30 Mar 2023 20:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjCaA24 (ORCPT ); Thu, 30 Mar 2023 20:28:56 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3ADDBDB for ; Thu, 30 Mar 2023 17:28:48 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id r11so83452796edd.5 for ; Thu, 30 Mar 2023 17:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1680222527; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=L/321qEfsdd6Li2EcEMfqC9Li7rtjZommEiuh2gRTto=; b=DZEf1xUJfTUEdgD3msGdVte+/jLWfThGevpfh0CnxibxN/P8QtCGkAJuFHfsgc0KrS /Axpy8WzWsImUTvrJb+u6GUWyv9JD94nUAwQ6xrZBGbpC2J87RDYe1WX/HDL/8uOKDfh ilMDEcNdDl9oxrv6U1AsvqEA2khFX179gVDgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680222527; h=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=L/321qEfsdd6Li2EcEMfqC9Li7rtjZommEiuh2gRTto=; b=4pyRLbQYu+hKXfkYpTqL59jY1eSjShKDPQ8Bbi+dYcqboLaTcKIAvuqwF67KzlFbgB V1T08qQ7gCmjjMluXwVkN5R7+dSErgF+hFNnbshWj377ltf9lV9TFuP8vWGM6Eswdnm1 EgOkgRgA4ahem+sTyqS7RXotlKqBzwfcV8Xkd/A/9mcf4J+R3JVmqfDELKVDYexVrFux w7ZVTbgLCkmxXOYcrpxJ7Tgjbq9h7rHCIatem3dTueKpe9Egt2HWTIb5RmDNA5FPO7DQ eY4jWRx5HeYAPWUXkpN43KVMB205klRPtuDiXxLfpihOlNyPsmoRt0KInkiCHECuIm6T xeYQ== X-Gm-Message-State: AAQBX9fm+3+yRYuzy7/+4I5OZ429UkRg4QJRQqzjB9eydXceEdZJfVnl ninlz5IGUAKTw1HrjnUw0jln1ya4MHOBEQcJjtmPjk2GLRULVLe+ X-Received: by 2002:a17:907:3e8b:b0:931:ce20:db6e with SMTP id hs11-20020a1709073e8b00b00931ce20db6emr14070290ejc.2.1680222526978; Thu, 30 Mar 2023 17:28:46 -0700 (PDT) MIME-Version: 1.0 References: <20221229081252.452240-1-sarthakkukreti@chromium.org> <20221229081252.452240-4-sarthakkukreti@chromium.org> In-Reply-To: From: Sarthak Kukreti Date: Thu, 30 Mar 2023 17:28:35 -0700 Message-ID: Subject: Re: [PATCH v2 3/7] fs: Introduce FALLOC_FL_PROVISION To: "Theodore Ts'o" Cc: "Darrick J. Wong" , sarthakkukreti@google.com, 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 , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Alasdair Kergon , Mike Snitzer , Christoph Hellwig , Brian Foster , Andreas Dilger , Bart Van Assche , Daniil Lunev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org On Thu, Jan 5, 2023 at 7:49 AM Theodore Ts'o wrote: > > On Wed, Jan 04, 2023 at 01:22:06PM -0800, Sarthak Kukreti wrote: > > > How expensive is this expected to be? Is this why you wanted a separate > > > mode flag? > > > > Yes, the exact latency will depend on the stacked block devices and > > the fragmentation at the allocation layers. > > > > I did a quick test for benchmarking fallocate() with an: > > A) ext4 filesystem mounted with 'noprovision' > > B) ext4 filesystem mounted with 'provision' on a dm-thin device. > > C) ext4 filesystem mounted with 'provision' on a loop device with a > > sparse backing file on the filesystem in (B). > > > > I tested file sizes from 512M to 8G, time taken for fallocate() in (A) > > remains expectedly flat at ~0.01-0.02s, but for (B), it scales from > > 0.03-0.4s and for (C) it scales from 0.04s-0.52s (I captured the exact > > time distribution in the cover letter > > https://marc.info/?l=linux-ext4&m=167230113520636&w=2) > > > > +0.5s for a 8G fallocate doesn't sound a lot but I think fragmentation > > and how the block device is layered can make this worse... > > If userspace uses fallocate(2) there are generally two reasons. > Either they **really** don't want to get the NOSPC, in which case > noprovision will not give them what they want unless we modify their > source code to add this new FALLOC_FL_PROVISION flag --- which may not > be possible if it is provided in a binary-only format (for example, > proprietary databases shipped by companies beginning with the letters > 'I' or 'O'). > > Or, they really care about avoiding fragmentation by giving a hint to > the file system that layout is important, and so **please** allocate > the space right away so that it is more likely that the space will be > laid out in a contiguous fashion. Of course, the moment you use > thin-provisioning this goes out the window, since even if the space is > contiguous on the dm-thin layer, on the underlying storage layer it is > likely that things will be fragmented to a fare-thee-well, and either > (a) you have a vast amount of flash to try to mitigate the performance > hit of using thin-provisioning (example, hardware thin-provisioning > such as EMC storage arrays), or (b) you really don't care about > performance since space savings is what you're going for. > > So.... because of the issue of changing the semantics of what > fallocate(2) will guarantee, unless programs are forced to change > their code to use this new FALLOC flag, I really am not very fond of > it. > > I suspect that using a mount option (which should default to > "provision"; if you want to break user API expectations, it should > require a mount option for the system administrator to explicitly OK > such a change), is OK. > Understood. I dropped the FALLOC flag from the series in v3, instead we now rely on the filesystem's mount/policy. > As far as the per-file mode --- I'm not convinced it's really > necessary. In general if you are using thin-provisioning file systems > tend to be used explicitly for one purpose, so adding the complexity > of doing it on a per-file basis is probably not really needed. That > being said, your existing prototype requires searching for the > extended attribute on every single file allocation, which is not a > great idea. On a system with SELinux enabled, every file will have an > xattr block, and requiring that it be searched on every file > allocation would be unfortunate. It would be better to check for the > xattr when the file is opened, and then setting a flag in the struct > file. However, it might be better to see if it there is a real demand > for such a feature before adding it. > Thanks for the feedback! On ChromeOS, we still have filesystems shared between applications, partly due to inertia of adoption. So, we have a few cases of needing to share the filesystem but with differing provisioning policy. One more idea that I've been exploring in this space and uses the above file-based mechanism is to use a 'provisioning disabled' fallocated file to make the apparent free space in the thinly provisioned filesystem match the space available in the thinpool. In theory, this prevents userspace applications from writing much more than what's available on the thinpool. In practice, it depends on the responsiveness of the service that monitors and resizes this 'storage balloon'. Best Sarthak > - Ted