Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1059397rwn; Thu, 15 Sep 2022 09:50:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dJ5F26i415kxLM1mzfIMwBv8m3NvST4TTWd8heEPLZqDrCf44DXksEkkN2QXf8tQtEXbn X-Received: by 2002:aa7:cdd2:0:b0:44e:be4d:3231 with SMTP id h18-20020aa7cdd2000000b0044ebe4d3231mr645591edw.296.1663260626132; Thu, 15 Sep 2022 09:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663260626; cv=none; d=google.com; s=arc-20160816; b=S5vWt6tC1nRmYC9t5ASL8CcMCtuXcwoHpopg+artzOkj6L4x78CGtvObjN/gwUllI9 iwwB3Lh9vIT/KtFwVbtzvQDLZQM44jYNucGgdmnq9Fzb2N7xA9uBc81jbc6C23Rq6A0i YsPfpq5DMSMog4e02Y8xYpttb4rcq3/5lxW1pdfJXIy2sEGINd97ChbbtitV5cBslsqM RXPOKX45eMLkzIAX8kekWHFL/5lD4fbYqdzyeDdCxnMZEHaQc8OLeOVFSStgmSEIJTyl Vquv+oLPiv6DSyXioaRqBcIh95aTVlEYpe14o0z/qXP3FL3bO6/AgXeDV/HWMTUkz5DO 3WkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8C9PF5fV/n/yVA3OaBrI0F0iBecyk+zvR56xPQZ3IDQ=; b=R0gmD+YOG9w+wp1w7yj+mat0PhFbNWKH5QzbP5mWj9Pox4s+dFuOT27xMPPfv1gGEJ 4Hh0yv5YHWAgLYjfGRTnssu6W/e6xCyjFymIlmDAo67Nt1C3DHhyxb5IEPHLmewYFRNM +qqK0AuwBZ5aC6A2nUQM+gjElqWOCm66dnjyFLAJr+8X0KHC+8okJTwYCfEdZaMtC0FO FN4vRdzpz+kUVAh/jtpSpxdmy/ogS40yRh0tLS/yr6fBRaLZCb7df1l34yJ06T80kcp6 Tk+XtVdaIURrqaShUn76d1KTcAbeKpxCTvjOqbJSn/s/nEAPJtab8bT25DdRaDq7n7OJ KFlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j9UNt0Pd; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz30-20020a1709077d9e00b0073d786c730fsi16598067ejc.237.2022.09.15.09.50.01; Thu, 15 Sep 2022 09:50:26 -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; dkim=pass header.i=@chromium.org header.s=google header.b=j9UNt0Pd; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbiIOQtC (ORCPT + 99 others); Thu, 15 Sep 2022 12:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiIOQs6 (ORCPT ); Thu, 15 Sep 2022 12:48:58 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D3994EE2 for ; Thu, 15 Sep 2022 09:48:48 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id 9so7538964pfz.12 for ; Thu, 15 Sep 2022 09:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8C9PF5fV/n/yVA3OaBrI0F0iBecyk+zvR56xPQZ3IDQ=; b=j9UNt0PdafuY8eG1vCRzjZeZim0lhfvAaWOmUVbnBHmUWqdPZZ3auOQ0xlsq4Yg25G ssysjc8iJfcpwF872sxTnDKV+At5Lq1lz2NHw7y/c/HRgBxSyb3/AQ8kCSa9CzRaimvX fDowBy/9vfz+mH7HubnE6gAWlEVC/vOtMbAIU= 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=QhW+1xAZZ1leWyV+LkMMunLnc3rURjJUmTjuE6yBBW3LRe5QC7Yc+G3snlgOfROBbx g339EqUQ2f98BDUW1GcXO5IDGUhQsyL4KZnaOesiaf3VM6EEMOUIp/cpeEYveigLoKt9 eM6xdKS6N5aoO58/L98iYiD0f0N7Ys5t29jeE74oiKp+dhgxeo5eRio59hvMCHEqeDVK WkFJaTsnT0n5u9BeDCy5cOh46nC8UGSYQWd74/9FhjW10I1F0AgYpjw9im0DkL6f0VPs 12BmlA8/+jo9PksjE5wwZRpvNXWkrzNVuZLHfHA4W+EuJcXygmiMIy/zaHVNR9gJ2LbM 3X7Q== X-Gm-Message-State: ACrzQf2A1KP8wC/HuFwvycUrSZEyk98+fpdCY1sQV0prl0XDOVVQ58SZ DAXCt4G8GMAjbpcOQw7suBJr3g== 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 Cc: Jens Axboe , "Michael S . Tsirkin" , Jason Wang , Paolo Bonzini , Stefan Hajnoczi , Alasdair Kergon , Mike Snitzer , Theodore Ts'o , Andreas Dilger , Bart Van Assche , Daniil Lunev , Evan Green , Gwendal Grignou , Sarthak Kukreti Subject: [PATCH RFC 4/8] fs: Introduce FALLOC_FL_PROVISION Date: Thu, 15 Sep 2022 09:48:22 -0700 Message-Id: <20220915164826.1396245-5-sarthakkukreti@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220915164826.1396245-1-sarthakkukreti@google.com> References: <20220915164826.1396245-1-sarthakkukreti@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 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_ */ -- 2.31.0