From patchwork Wed Apr 10 15:03:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13624744 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56F63CD11C2 for ; Wed, 10 Apr 2024 15:12:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D14F16B00C2; Wed, 10 Apr 2024 11:11:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9E6F6B00C3; Wed, 10 Apr 2024 11:11:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B176B6B00C5; Wed, 10 Apr 2024 11:11:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6628A6B00C2 for ; Wed, 10 Apr 2024 11:11:58 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 375C016082B for ; Wed, 10 Apr 2024 15:11:58 +0000 (UTC) X-FDA: 81993962316.29.FC348F1 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf01.hostedemail.com (Postfix) with ESMTP id B6BF140027 for ; Wed, 10 Apr 2024 15:11:55 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712761916; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rOISLZvWRRFPAoNVpRKCtz5oaelI0ZZn5x96xzrs6Pk=; b=j7Pto404k+GtV2Rx5fCo6ltzQA8TmfbGzTkmkdARxFeZpAg9vmMTnX91e7QxlsUfqXN1pp NzklUWgADgDPHL9qpZ0wLGl1xDhG8D6GhjJtTtOhuVYsr9rKYMSzSBctFTbdXgmh+cg4/T awi3HrW0D4Kb7zq4mEBerC31H8dwvhM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712761916; a=rsa-sha256; cv=none; b=VUU11HNQwDPwuWPVcF0CLcLgogFdhpFUB6uR6qzMk93B663CnV4DpWl5063FsHCg1ENKq1 TcG7MKm232bb5tceMcC2cJ87VNMWzCM2GVqNSy5SV2NpNTMK4GAakN9jdoRCyVys0RjtN2 4ACQbNlW/dz7Lb/u4LKF9SDZW1R6Cyg= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF5rz3CSGz4f3kjp for ; Wed, 10 Apr 2024 23:11:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id D6AF71A0175 for ; 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> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAn9g4orBZmFSt+Jg--.51485S9 X-Coremail-Antispam: 1UD129KBjvJXoWxCw13GF15ur4fGw47KF4kWFg_yoWrJr4xp3 s0gFWrGw1vvryj9FWI9Fs3Xr1Sya1Fka1UCrW09w17XFZrAryIgFyfKF1akF4aqrW8XFyI qF1rKF17WFW2krDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQFb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7xvrVCFI7AF6II2Y40_Zr0_Gr1UM4x0x7Aq67 IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2xKxwCF04k20xvY0x0EwIxGrwCF x2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14 v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY 67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4 v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr1j6F4UJwCI42IY6I8E87Iv6xkF7I0E 14v26rxl6s0DYxBIdaVFxhVjvjDU0xZFpf9x0ziBWlDUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B6BF140027 X-Stat-Signature: pek7ehmms3n49fhzy63rrwdu5rhsxc1q X-HE-Tag: 1712761915-96725 X-HE-Meta: U2FsdGVkX18VeEVLKINo7HVfLnQa5LLlF+tJKS02EEFFoQlp7h/T3SBnfKL2csMvDb2ZMq32wSHO1fKJg4vIVpDnRkGbse06v+vh5p+JUW8B8j0jBwIrcB+fKxSaS71hVob+R1wS7A6ei/234xCNTJJnuwL7hYpKBLFyxV2XfAUgkAwyf56GPaeyHIc4QKB6beZl7jgZz3hj7dxOaBDAURnH6Iska9QYdXdWn747p1uN+vmKiJhjixZzEC1UZ41edR0qBJ0cT70yxCws41k232Xw1CIdc44VBe+laH2eXPMbe79EYjvWxgrG+kIIikRkh4oK7jwUEXaYwylZRqgkp/oNggS58o0PjKGXR3peSb8nM0xPdyLtydNDZ1juRhHi29QUu9U6MegawA1zi5+aM+A5K/mQJZpDruz0LnqH2jiBtseFZKd3JSqkqg5zg+VXX89VaT5lDk6wbT4SHe34JHk55ooiOy0HzpbPmoMVuZAGNdvPXrC3guq1D+1dLqAtcJ4pthvyTixIDYqjhDsOgd5PA62rBjJHMeY/IiKG1DxU0m63WNZa8TPK6oxuHALDKiQDyfBwX+LyfKr1NwGgKV/ueq0oNUxnGjIt7FWqJqa//Bs8WplHh81/Vfzuh8pFG1P77kZ4fOxx+SuETQ+DOvVuH4RbWgUd5D5ZVxdIEAatSyb8lMssPlHDUuUze19qv9ejZPhiHnjD7pGwXtDroYz1o4THYiSE37LEnbPfnL3Sc9cVAbCm7rH/VIsyJDjqmnjkLKjJ4jqE/wN8KSRXADU3gkEbrjmddx2osc3R7uGH/gqDaLlYpA01vMneqAlM/egSECKlIHe4l7BOw0HkIAuaZEeg8s55wkzphsi58qftoxfwjwOJNS28BIjhfBYNAV9nAKTewEnonRz56itXrwo5jmacxDl+qqCdEPZ+kQu/mnNEryvqKKHCiaIzaUB1AbZQT9yPInoT+esN4uF ks7tVR1U SpXwb1zjYqhfCr4K0zcZjcZQ9eQfMYrSEasoCaUoR2ogpDVIdJsQEF8QEq9FRbe/24UC61vM95aUoFMeM/D0VUNRLDCzuadqXSDWenujLYXk3Ob7rvsS32jbetpYo7MkYsx37Tfun3n9GmU84W1bc/Q55VRp0jFaooxpHOrXi/O3LVE1UCAHwl5leEaffxwFxNns2GGcWiXhpc3FPuoUjVGg0DI/zBrC2NyuQrSfhVJrxBNhDuUiDJtjDbQarphXvUb3p X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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);