From patchwork Thu Sep 15 16:48:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarthak Kukreti X-Patchwork-Id: 12978257 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 0CAA8ECAAD8 for ; Fri, 16 Sep 2022 08:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663317902; 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=oTscLhiCGbX5/TV0fdqupNv+s879c9BtoJlZKyrHeFc=; b=R3jduqTvKzRx/ZrkztojEDiqJceSKrIQ0vsD5DUQ2Cl+ylS6wDRbt41mDU0j8nAbBeWFBp EHM/IsQ6Eg6QXnDYZ8uH4DzxUr0hGb0a2mOy0O+0U9LPEuW79imptgn5Sn6Mr9abifdQen CCQHyusI5uQkPPzxvApDX/Fvquz+RMI= 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-60-ks6xqm7AO0SYp5pvlvmfrA-1; Fri, 16 Sep 2022 04:45:00 -0400 X-MC-Unique: ks6xqm7AO0SYp5pvlvmfrA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF37E29A8AED; Fri, 16 Sep 2022 08:44:58 +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 BF4F92087440; Fri, 16 Sep 2022 08:44:58 +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 3BB0F1946A6B; Fri, 16 Sep 2022 08:44:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 255B91946586 for ; Thu, 15 Sep 2022 16:48:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0ABA840C6EC3; Thu, 15 Sep 2022 16:48:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06D2B40C6EC2 for ; Thu, 15 Sep 2022 16:48:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 E0EDB8027FD for ; Thu, 15 Sep 2022 16:48:50 +0000 (UTC) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-269-N7NX-JztOxuAwPsZuu1zyA-1; Thu, 15 Sep 2022 12:48:49 -0400 X-MC-Unique: N7NX-JztOxuAwPsZuu1zyA-1 Received: by mail-pf1-f175.google.com with SMTP id u132so18629346pfc.6 for ; Thu, 15 Sep 2022 09:48:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=8C9PF5fV/n/yVA3OaBrI0F0iBecyk+zvR56xPQZ3IDQ=; b=JxvzpA/JXai9d+wV8WqasGU8JdG20lS7OiBxwZ34X9geychP+pnOvlTC328bf9x6B9 AAOW5wjvBr+WfCLBGG3EXoEVbzdRNVnpkXCVMSuxhJzZ7Qcc9LE3VGazpGNIVjDv0gfV uI1YotyIBLhaCHUyENDvApozNZRi7fivf7YcNUk56JYsANmJuen2FUzzgL2Sd0MgTFW5 Dn5KT9E8R1DKaVF/MVAdsVvk9C2TpL+53WdeV019RSwO9Dm33435q+FflNBbHloiDANo YKPuk+1pPy0iLAGuFM6wNftRluUG6IGmWciIxwQIoPh+C+n/D02tpx1DttHT30xfZtlq DhGg== X-Gm-Message-State: ACrzQf3vyHfp8LdIrgqalxLW6qbRD1BtJSqnH/XBd5co67ZWk+22CmJP uHatgPUwDLSN7o48AEohKnpKS7zo64fxdg== X-Google-Smtp-Source: AMsMyM74NUJEGoCBWxXp6ovjj8HVrZVtuoYCAa5cO2wk9AivcidhyvEFeO548cRZFdt3fQKWpEtWLA== X-Received: by 2002:a05:6a00:1691:b0:53b:3f2c:3257 with SMTP id k17-20020a056a00169100b0053b3f2c3257mr882622pfc.21.1663260527748; Thu, 15 Sep 2022 09:48:47 -0700 (PDT) Received: from sarthakkukreti-glaptop.hsd1.ca.comcast.net ([2601:647:4200:b5b0:3af2:34b2:a98a:a652]) by smtp.gmail.com with ESMTPSA id o4-20020a170902bcc400b00177ee563b6dsm13174970pls.33.2022.09.15.09.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 09:48:46 -0700 (PDT) From: Sarthak Kukreti X-Google-Original-From: Sarthak Kukreti To: dm-devel@redhat.com, linux-block@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Date: Thu, 15 Sep 2022 09:48:22 -0700 Message-Id: <20220915164826.1396245-5-sarthakkukreti@google.com> In-Reply-To: <20220915164826.1396245-1-sarthakkukreti@google.com> References: <20220915164826.1396245-1-sarthakkukreti@google.com> MIME-Version: 1.0 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.2 X-Mailman-Approved-At: Fri, 16 Sep 2022 08:44:55 +0000 Subject: [dm-devel] [PATCH RFC 4/8] 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 , Gwendal Grignou , Theodore Ts'o , Sarthak Kukreti , "Michael S . Tsirkin" , Jason Wang , Bart Van Assche , Mike Snitzer , Evan Green , Andreas Dilger , Daniil Lunev , Stefan Hajnoczi , Paolo Bonzini , Alasdair Kergon Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Sarthak Kukreti 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. Signed-off-by: Sarthak Kukreti --- block/fops.c | 7 ++++++- include/linux/falloc.h | 3 ++- include/uapi/linux/falloc.h | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/block/fops.c b/block/fops.c index b90742595317..a436a7596508 100644 --- a/block/fops.c +++ b/block/fops.c @@ -605,7 +605,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) @@ -661,6 +662,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..a0e506255b20 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_ */