From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63F18C4708D for ; Wed, 4 Jan 2023 16:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672851019; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=d47TEPBFicBpTcpO4VIWTd+H/WCRF532gyhC/Gjywk4=; b=QFFfKnuZI2ckab1CsSAHti9IBvq87BHCxAWUlLOCrkfvHXlT7y6/lK4MBz/OtTObJSegB2 /aHRp2j2SwXIJhjouvOO0c91HEWQNAuVkctYbxAmo+eVsODTpvzRKsa0TXxjwJKagJQWEU UlBYtJEBkfUTgFDcG5+W4LDBefUuYB8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-464-Zvz_CBRVOv-IutXrWHQnCw-1; Wed, 04 Jan 2023 11:50:15 -0500 X-MC-Unique: Zvz_CBRVOv-IutXrWHQnCw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3FC338149B3; Wed, 4 Jan 2023 16:50:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 001B5492B06; Wed, 4 Jan 2023 16:50:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CF74D194658C; Wed, 4 Jan 2023 16:50:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A52DA1946589 for ; Wed, 4 Jan 2023 16:50:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 782EF40C2004; Wed, 4 Jan 2023 16:50:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70D9740C2064 for ; Wed, 4 Jan 2023 16:50:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5557585A588 for ; Wed, 4 Jan 2023 16:50:08 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-hRz2ZMJVPsek1CQUR7-paA-1; Wed, 04 Jan 2023 11:50:04 -0500 X-MC-Unique: hRz2ZMJVPsek1CQUR7-paA-1 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE6B1617A7; Wed, 4 Jan 2023 16:39:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48E66C433D2; Wed, 4 Jan 2023 16:39:55 +0000 (UTC) Date: Wed, 4 Jan 2023 08:39:54 -0800 From: "Darrick J. Wong" To: Sarthak Kukreti Message-ID: References: <20221229081252.452240-1-sarthakkukreti@chromium.org> <20221229081252.452240-4-sarthakkukreti@chromium.org> MIME-Version: 1.0 In-Reply-To: <20221229081252.452240-4-sarthakkukreti@chromium.org> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Subject: Re: [dm-devel] [PATCH v2 3/7] fs: Introduce FALLOC_FL_PROVISION X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , Christoph Hellwig , Theodore Ts'o , "Michael S. Tsirkin" , sarthakkukreti@google.com, Jason Wang , Bart Van Assche , Mike Snitzer , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, Andreas Dilger , Daniil Lunev , Stefan Hajnoczi , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Brian Foster , Alasdair Kergon Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, Dec 29, 2022 at 12:12:48AM -0800, Sarthak Kukreti wrote: > FALLOC_FL_PROVISION is a new fallocate() allocation mode that > sends a hint to (supported) thinly provisioned block devices to > allocate space for the given range of sectors via REQ_OP_PROVISION. > > The man pages for both fallocate(2) and posix_fallocate(3) describe > the default allocation mode as: > > ``` > The default operation (i.e., mode is zero) of fallocate() > allocates the disk space within the range specified by offset and len. > ... > subsequent writes to bytes in the specified range are guaranteed > not to fail because of lack of disk space. > ``` > > For thinly provisioned storage constructs (dm-thin, filesystems on sparse > files), the term 'disk space' is overloaded and can either mean the apparent > disk space in the filesystem/thin logical volume or the true disk > space that will be utilized on the underlying non-sparse allocation layer. > > The use of a separate mode allows us to cleanly disambiguate whether fallocate() > causes allocation only at the current layer (default mode) or whether it propagates > allocations to underlying layers (provision mode) Why is it important to make this distinction? The outcome of fallocate is supposed to be that subsequent writes do not fail with ENOSPC. In my (fs developer) mind, REQ_OP_PROVISION simply an extra step to be taken after allocating file blocks. If you *don't* add this API flag and simply bake the REQ_OP_PROVISION call into mode 0 fallocate, then the new functionality can be added (or even backported) to existing kernels and customers can use it immediately. If you *do*, then you get to wait a few years for developers to add it to their codebases only after enough enterprise distros pick up a new kernel to make it worth their while. > for thinly provisioned filesystems/ > block devices. For devices that do not support REQ_OP_PROVISION, both these > allocation modes will be equivalent. Given the performance cost of sending provision > requests to the underlying layers, keeping the default mode as-is allows users to > preserve existing behavior. How expensive is this expected to be? Is this why you wanted a separate mode flag? --D > Signed-off-by: Sarthak Kukreti > --- > block/fops.c | 15 +++++++++++---- > include/linux/falloc.h | 3 ++- > include/uapi/linux/falloc.h | 8 ++++++++ > 3 files changed, 21 insertions(+), 5 deletions(-) > > diff --git a/block/fops.c b/block/fops.c > index 50d245e8c913..01bde561e1e2 100644 > --- a/block/fops.c > +++ b/block/fops.c > @@ -598,7 +598,8 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) > > #define BLKDEV_FALLOC_FL_SUPPORTED \ > (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | \ > - FALLOC_FL_ZERO_RANGE | FALLOC_FL_NO_HIDE_STALE) > + FALLOC_FL_ZERO_RANGE | FALLOC_FL_NO_HIDE_STALE | \ > + FALLOC_FL_PROVISION) > > static long blkdev_fallocate(struct file *file, int mode, loff_t start, > loff_t len) > @@ -634,9 +635,11 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, > filemap_invalidate_lock(inode->i_mapping); > > /* Invalidate the page cache, including dirty pages. */ > - error = truncate_bdev_range(bdev, file->f_mode, start, end); > - if (error) > - goto fail; > + if (mode != FALLOC_FL_PROVISION) { > + error = truncate_bdev_range(bdev, file->f_mode, start, end); > + if (error) > + goto fail; > + } > > switch (mode) { > case FALLOC_FL_ZERO_RANGE: > @@ -654,6 +657,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, > error = blkdev_issue_discard(bdev, start >> SECTOR_SHIFT, > len >> SECTOR_SHIFT, GFP_KERNEL); > break; > + case FALLOC_FL_PROVISION: > + error = blkdev_issue_provision(bdev, start >> SECTOR_SHIFT, > + len >> SECTOR_SHIFT, GFP_KERNEL); > + break; > default: > error = -EOPNOTSUPP; > } > diff --git a/include/linux/falloc.h b/include/linux/falloc.h > index f3f0b97b1675..b9a40a61a59b 100644 > --- a/include/linux/falloc.h > +++ b/include/linux/falloc.h > @@ -30,7 +30,8 @@ struct space_resv { > FALLOC_FL_COLLAPSE_RANGE | \ > FALLOC_FL_ZERO_RANGE | \ > FALLOC_FL_INSERT_RANGE | \ > - FALLOC_FL_UNSHARE_RANGE) > + FALLOC_FL_UNSHARE_RANGE | \ > + FALLOC_FL_PROVISION) > > /* on ia32 l_start is on a 32-bit boundary */ > #if defined(CONFIG_X86_64) > diff --git a/include/uapi/linux/falloc.h b/include/uapi/linux/falloc.h > index 51398fa57f6c..2d323d113eed 100644 > --- a/include/uapi/linux/falloc.h > +++ b/include/uapi/linux/falloc.h > @@ -77,4 +77,12 @@ > */ > #define FALLOC_FL_UNSHARE_RANGE 0x40 > > +/* > + * FALLOC_FL_PROVISION acts as a hint for thinly provisioned devices to allocate > + * blocks for the range/EOF. > + * > + * FALLOC_FL_PROVISION can only be used with allocate-mode fallocate. > + */ > +#define FALLOC_FL_PROVISION 0x80 > + > #endif /* _UAPI_FALLOC_H_ */ > -- > 2.37.3 > -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel