Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5654129rwl; Thu, 29 Dec 2022 00:17:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtJrvRWaBngDXBYrbaKtvrD48VPMzv5W/dsNfY8fWWzKKfYeX3DQdZ8bINU9XrtVlUcZKyS X-Received: by 2002:a17:907:6f13:b0:819:2756:e090 with SMTP id sy19-20020a1709076f1300b008192756e090mr21441689ejc.50.1672301846424; Thu, 29 Dec 2022 00:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672301846; cv=none; d=google.com; s=arc-20160816; b=SrCvNWleDzrelGWCEcsSSovIumREbyYEwKs4rjcuzp4HMAV78GQ7ioe8yaFUgFthrT 0/fHPB3mhpZmBbPVSC6pbv1s1Tp+oG31XRxlqcuYq6XBlUi1bN+apK9xf1rVmVRDS2RF fFkVx4BlWEsOYpMqPOHcshE1PuOWxLI4TdGFAh5uEBjV7HeI38sLOy22zowuvXr/2vIM ChBhgMGB5k2/dvpbExmZWpy6YbIq2BOIvp298vWTP5oDkcYdymC7ZU77EIe9ajciyyWs xxul/a3L/ac9ereA/O4FTsuh4sNtOQBlasBHavOKyMga0ePtpPXuHsPiByoispUy1D3T GrQg== 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=Vv5x1KdmMeVtIhlp3zKOKF7sZVF7KRZLRJQbPD3QKT4=; b=u+Ln0TTaRI6teH1wF5l/nFxwgIcQ6khzCycvDesMBJc/dXnxn7q7z0nOYQFKuaEY/L mGpEfHT0TTY002jJUPaRYclmU4ziV7//svqIzhzGU7lPEpAbQCbPHM2rPRroVtPV5j/K FU132dRzj5g0N8KwlsiwHAwekQd7S6Vbkz5i/R5yDaAfKpYPEBwrCnM7UHT4ZowbosOt 7XMsfNuAOfYVhlbB3mpvwtWRmiLaj+KNIom2YeKL2iXxD0LnbT9ysqhdXtjgMhAmSSTy HgZUrXJ0M3QprQo9+UFJVtQhN5idzq1Ppllj4IsLMP46lugZDGx9b41Ap51ntsP0NIWS giSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T05xc0ET; 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 nb14-20020a1709071c8e00b0082b4565362bsi15306489ejc.371.2022.12.29.00.17.02; Thu, 29 Dec 2022 00:17:26 -0800 (PST) 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=T05xc0ET; 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 S233023AbiL2IO2 (ORCPT + 99 others); Thu, 29 Dec 2022 03:14:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233090AbiL2INa (ORCPT ); Thu, 29 Dec 2022 03:13:30 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ED4813D41 for ; Thu, 29 Dec 2022 00:13:13 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id s7so18289024plk.5 for ; Thu, 29 Dec 2022 00:13:13 -0800 (PST) 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 :message-id:reply-to; bh=Vv5x1KdmMeVtIhlp3zKOKF7sZVF7KRZLRJQbPD3QKT4=; b=T05xc0ET+ovYWIL5pcnCM2gTG/W0v/0OqHvEwFkZjoBf10OqF0ArlagciQllVNzMtn GIrm+w7+DEYMtu0OMfltv5BLAP1xPtYnbtZ4WfOOVblA64a9OsheTZbsH52zOo8QN0Sp hWwPftBw+HDztRSuSQCbaldwNxaNhj1AdbITs= 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:message-id:reply-to; bh=Vv5x1KdmMeVtIhlp3zKOKF7sZVF7KRZLRJQbPD3QKT4=; b=YDvuZC1EuV1b0Rm8c8BFWimBEoNpWrUHdj4BhoVpGNYsblJXkqmY0wzOcR7+tb+xsI eU0iZDCLRP9vPwSp5qLzNFgdR/+DCcy3Mk2Iw3B6NGdxHKbW2XeOGXeQ+co7VtlcUKZe faOwd/v4Tz2rqjJrB1GfqzlAt2Uawhsz8Nq/vpqNKL8SUNfasiOYThYBymPXOor9LVCu 74rEtRyu1VmtZmkXjuHVq36e3cOvBgdQiYgUukpBAbByc/RcpECd77QO7LbAucUuQquL ZxQLnW92e98AlWYou9qbTCYgZZG1OVBLQCfPWTvOURFuCx7PPebKQHXAxs/4HL/oZ+gJ XHjA== X-Gm-Message-State: AFqh2kqDW503oFlNsqsyP5c8+lbHhODSqCyLwybBV3sDt5FYutf++N46 tuhU4fN1bJk/Mz6Xppz/ceJ27w== X-Received: by 2002:a17:902:a70c:b0:189:dcc3:e4a1 with SMTP id w12-20020a170902a70c00b00189dcc3e4a1mr28589601plq.9.1672301592863; Thu, 29 Dec 2022 00:13:12 -0800 (PST) Received: from sarthakkukreti-glaptop.hsd1.ca.comcast.net ([2601:647:4200:b5b0:75ff:1277:3d7b:d67a]) by smtp.gmail.com with ESMTPSA id 12-20020a170902e9cc00b00192820d00d0sm6496325plk.120.2022.12.29.00.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 00:13:12 -0800 (PST) From: Sarthak Kukreti To: 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 Cc: Jens Axboe , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Alasdair Kergon , Mike Snitzer , Christoph Hellwig , Brian Foster , Theodore Ts'o , Andreas Dilger , Bart Van Assche , Daniil Lunev , "Darrick J. Wong" Subject: [PATCH v2 6/7] ext4: Add mount option for provisioning blocks during allocations Date: Thu, 29 Dec 2022 00:12:51 -0800 Message-Id: <20221229081252.452240-7-sarthakkukreti@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221229081252.452240-1-sarthakkukreti@chromium.org> References: <20221229081252.452240-1-sarthakkukreti@chromium.org> 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=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-ext4@vger.kernel.org Add a mount option that sets the default provisioning mode for all files within the filesystem. Signed-off-by: Sarthak Kukreti --- fs/ext4/ext4.h | 1 + fs/ext4/extents.c | 7 +++++++ fs/ext4/super.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 49832e90b62f..29cab2e2ea20 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1269,6 +1269,7 @@ struct ext4_inode_info { #define EXT4_MOUNT2_MB_OPTIMIZE_SCAN 0x00000080 /* Optimize group * scanning in mballoc */ +#define EXT4_MOUNT2_PROVISION 0x00000100 /* Provision while allocating file blocks */ #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \ ~EXT4_MOUNT_##opt diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 2e64a9211792..a73f44264fe2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4441,6 +4441,13 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, unsigned int credits; loff_t epos; + /* + * Attempt to provision file blocks if the mount is mounted with + * provision. + */ + if (test_opt2(inode->i_sb, PROVISION)) + flags |= EXT4_GET_BLOCKS_PROVISION; + BUG_ON(!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)); map.m_lblk = offset; map.m_len = len; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 260c1b3e3ef2..5bc376f6a6f0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1591,6 +1591,7 @@ enum { Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache, Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, Opt_errors, Opt_data, Opt_data_err, Opt_jqfmt, Opt_dax_type, + Opt_provision, Opt_noprovision, #ifdef CONFIG_EXT4_DEBUG Opt_fc_debug_max_replay, Opt_fc_debug_force #endif @@ -1737,6 +1738,8 @@ static const struct fs_parameter_spec ext4_param_specs[] = { fsparam_flag ("reservation", Opt_removed), /* mount option from ext2/3 */ fsparam_flag ("noreservation", Opt_removed), /* mount option from ext2/3 */ fsparam_u32 ("journal", Opt_removed), /* mount option from ext2/3 */ + fsparam_flag ("provision", Opt_provision), + fsparam_flag ("noprovision", Opt_noprovision), {} }; @@ -1826,6 +1829,8 @@ static const struct mount_opts { {Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET}, {Opt_no_prefetch_block_bitmaps, EXT4_MOUNT_NO_PREFETCH_BLOCK_BITMAPS, MOPT_SET}, + {Opt_provision, EXT4_MOUNT2_PROVISION, MOPT_SET | MOPT_2}, + {Opt_noprovision, EXT4_MOUNT2_PROVISION, MOPT_CLEAR | MOPT_2}, #ifdef CONFIG_EXT4_DEBUG {Opt_fc_debug_force, EXT4_MOUNT2_JOURNAL_FAST_COMMIT, MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, @@ -2977,6 +2982,8 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, SEQ_OPTS_PUTS("dax=never"); } else if (test_opt2(sb, DAX_INODE)) { SEQ_OPTS_PUTS("dax=inode"); + } else if (test_opt2(sb, PROVISION)) { + SEQ_OPTS_PUTS("provision"); } if (sbi->s_groups_count >= MB_DEFAULT_LINEAR_SCAN_THRESHOLD && -- 2.37.3