Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp206627lqj; Wed, 10 Apr 2024 08:13:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0t/H8MMemu5AxIMU/Vc1xF3Ic5VecVJDyyANR7ygPQfioyHo/Zf7G/psANprPF6c765pGbIn8IV9+Y6228LRoUxsAaidVViih1otNIw== X-Google-Smtp-Source: AGHT+IGmLN1U9QknkY2J6DjI5+kbUXHVdqMvGT99GbL33LhN3YbQiOhDPvOxeyMjttm3334kNBfl X-Received: by 2002:a17:90a:5aa1:b0:2a2:2f51:41e0 with SMTP id n30-20020a17090a5aa100b002a22f5141e0mr2880070pji.4.1712762012080; Wed, 10 Apr 2024 08:13:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712762012; cv=pass; d=google.com; s=arc-20160816; b=E3AUEbedPrGPmzlFIPv+s9i+PGFHF8a8SUFQFuwotvsZ8/75QSEmCbWmlGPdno/wo9 8fO5R238fRfcgzpida4JNQXQ/gLVycucggsv135MYGm4merQpKOJ9QZ1IEjSqjAXlSu4 Z9cKwwP7vhcjf3Lg1xzkEoU+kj8FXL/sySbhmTPGOlezmEO9dmov9D9ULoKvKPkRXmPI OBCgaCDqYadZkqDjTl3404NRs9EMDoKALqiCtOqebXPUMkZr3fF61tFevWCnBh86ij6I YyMsUPb3niFnzPhBzGvWRFQUIk1bg7QNYHFSK1sgY+q7mZ9jsI4VnYFBYcTSaOUXEqDA bgvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rOISLZvWRRFPAoNVpRKCtz5oaelI0ZZn5x96xzrs6Pk=; fh=VCdyVZCUh9R8dltaA9/RWs/hxQzWhc63WX0fta2PQtE=; b=gCtbDdp/CcDK0TulNCFE12G61pn61HVcS3GdWay+o0HldHQrTetFFEbNfYHZvLHcLF Gv7RXBCxXUy25VaNMXTh+FpS5vCxA6h968N+bfj+RuVqSuI9rFVH64Ep9FCxaMyQfCLY y+3QYsy+7P4no8Uc7Fy0Y20OYa4f3xXW9kWZke177Iu2HULWvuQhdSaMnLHegX8L8D0J mrqyx4h0YRWF8c435zIk1suQaEVMpC1OdOf5lDHz2rgws9hRu2R4rdFWRPlPSgGlyrzp pdlb2ELiki/V9OKpgYWdt392oA6fvnI0rXlyaXJfZD3ywfDPcrF4JsvS2Mbaz7ik9yvT W5oA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2006-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b13-20020a17090a990d00b002a2317897d8si1616800pjp.122.2024.04.10.08.13.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 08:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2006-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B2FEB289E5D for ; Wed, 10 Apr 2024 15:13:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58CF2173330; Wed, 10 Apr 2024 15:11:58 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 458B216E86D; Wed, 10 Apr 2024 15:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712761918; cv=none; b=NpVPGmPM0khC8QPlIHBhr8ZOS3KH0XEHwfgOYi86YaIjSwrP0VGC6IWfW80O8lARyR6W7nziakFqw+u0QtAFdJgPV7u2MIun3npDJYyZzhUhFU+1RT7Xzius/iCkSJ81azTk63cLSOnFj9QLjkxZ15rYWL0eoHQ4rlWGrA8y2JQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712761918; c=relaxed/simple; bh=Py1SPSnSmM02LNWBuDSfAjgXNIjhNrL3rfUfwdnJBrY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YVOWR7apHBEkCLnAWoEGBoO3etQ9MMyJcE+DBGa9wu0pma5PiNTeIYWLqJIbySyhw1+40+gJB773w9wIfwEVXYSGz/ZF/VFpW1a1VGSp0fayVx+SxJIbLBOzl4IjinvWPWf7M4J97Mkq1MaatMQ8eLdBeD5DEujgF18fl8DfRh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VF5rx0bFsz4f3kjK; Wed, 10 Apr 2024 23:11:45 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id E3E851A0E02; Wed, 10 Apr 2024 23:11:51 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn9g4orBZmFSt+Jg--.51485S9; Wed, 10 Apr 2024 23:11:51 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, david@fromorbit.com, willy@infradead.org, zokeefe@google.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v4 34/34] ext4: add mount option for buffered IO iomap path Date: Wed, 10 Apr 2024 23:03:13 +0800 Message-Id: <20240410150313.2820364-6-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> References: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAn9g4orBZmFSt+Jg--.51485S9 X-Coremail-Antispam: 1UD129KBjvJXoWxCw13GF15ur4fGw47KF4kWFg_yoWrJr4xp3 s0gFWrGw1vvryj9FWI9Fs3Xr1Sya1Fka1UCrW09w17XFZrAryIgF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/ From: Zhang Yi Add buffered_io_iomap mount option to enable buffered IO iomap path for regular file, this option is disabled by default now. Signed-off-by: Zhang Yi --- fs/ext4/ext4.h | 1 + fs/ext4/inode.c | 2 ++ fs/ext4/super.c | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4e7667b21c2f..fef609e6ba7d 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1254,6 +1254,7 @@ struct ext4_inode_info { * scanning in mballoc */ #define EXT4_MOUNT2_ABORT 0x00000100 /* Abort filesystem */ +#define EXT4_MOUNT2_BUFFERED_IOMAP 0x00000200 /* Use iomap for buffered IO */ #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \ ~EXT4_MOUNT_##opt diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 269503749ef5..c930108f11dd 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5120,6 +5120,8 @@ bool ext4_should_use_buffered_iomap(struct inode *inode) { struct super_block *sb = inode->i_sb; + if (!test_opt2(sb, BUFFERED_IOMAP)) + return false; if (ext4_has_feature_inline_data(sb)) return false; if (ext4_has_feature_verity(sb)) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 6410918161a0..c8b691e605f1 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1685,7 +1685,7 @@ enum { Opt_dioread_nolock, Opt_dioread_lock, Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache, - Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, + Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, Opt_buffered_iomap, Opt_errors, Opt_data, Opt_data_err, Opt_jqfmt, Opt_dax_type, #ifdef CONFIG_EXT4_DEBUG Opt_fc_debug_max_replay, Opt_fc_debug_force @@ -1828,6 +1828,7 @@ static const struct fs_parameter_spec ext4_param_specs[] = { fsparam_flag ("no_prefetch_block_bitmaps", Opt_no_prefetch_block_bitmaps), fsparam_s32 ("mb_optimize_scan", Opt_mb_optimize_scan), + fsparam_flag ("buffered_iomap", Opt_buffered_iomap), fsparam_string ("check", Opt_removed), /* mount option from ext2/3 */ fsparam_flag ("nocheck", Opt_removed), /* mount option from ext2/3 */ fsparam_flag ("reservation", Opt_removed), /* mount option from ext2/3 */ @@ -1922,6 +1923,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_buffered_iomap, EXT4_MOUNT2_BUFFERED_IOMAP, + MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, #ifdef CONFIG_EXT4_DEBUG {Opt_fc_debug_force, EXT4_MOUNT2_JOURNAL_FAST_COMMIT, MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, @@ -2408,6 +2411,11 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) return -EINVAL; } return 0; + case Opt_buffered_iomap: + ext4_msg(NULL, KERN_WARNING, + "iomap for buffered enabled. Warning: EXPERIMENTAL, use at your own risk"); + ctx_set_mount_opt2(ctx, EXT4_MOUNT2_BUFFERED_IOMAP); + return 0; } /* @@ -2838,6 +2846,12 @@ static int ext4_check_opt_consistency(struct fs_context *fc, !(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_INODE))) { goto fail_dax_change_remount; } + + if (ctx_test_mount_opt2(ctx, EXT4_MOUNT2_BUFFERED_IOMAP) && + !test_opt2(sb, BUFFERED_IOMAP)) { + ext4_msg(NULL, KERN_ERR, "can't enable iomap for buffered IO on remount"); + return -EINVAL; + } } return ext4_check_quota_consistency(fc, sb); -- 2.39.2