From patchwork Wed Apr 10 14:29:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13624715 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 A4F7ACD1299 for ; Wed, 10 Apr 2024 14:39:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEE246B00AB; Wed, 10 Apr 2024 10:38:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D98A86B00AD; Wed, 10 Apr 2024 10:38:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3A536B00AC; Wed, 10 Apr 2024 10:38:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A6C196B00A8 for ; Wed, 10 Apr 2024 10:38:46 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7D3B51407DB for ; Wed, 10 Apr 2024 14:38:46 +0000 (UTC) X-FDA: 81993878652.06.37C2A68 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf16.hostedemail.com (Postfix) with ESMTP id 37DF718000F for ; Wed, 10 Apr 2024 14:38:43 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712759924; 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=fOgEdgws1v255Vbot+gwvOYlz1LDBoFxwezUsQaS9kk=; b=y4D0iPtvipWNQgPlsYDtXz5RcU2obVTdy2UeykfZJs9nHaQoKK1PYmBfgQxK9N+71MLaa3 2dCD0sVhXgIPAJ3xmhwqbstocMoMxpcfrCEXWGfPGtLkqkh6mdCP8zFXcrQn7/eQcsV4wi k2fv26E2cd3akN5EOvJD02Lm2q4TSs0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712759924; a=rsa-sha256; cv=none; b=JEg9O7uA9LC/85CKDKou3Iu1t7Ft8n1fGJ5Vqt1XMtXno8sIjXXxAUp5G/3Kg+xCyE9nAk kDEgJpPQysrbQqREV5JR5m6403N1b4jw/YQtuEbPYqtbKtPpb8TN0N1Z5g0EY/WwaDoaF+ zoWwrBjO600wJfxPxK9t6BG63/kH0rQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VF56d0ycXz4f3knl for ; Wed, 10 Apr 2024 22:38:33 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id F18D01A0DF5 for ; Wed, 10 Apr 2024 22:38:39 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6RFSpBZmcwR8Jg--.63000S26; Wed, 10 Apr 2024 22:38:39 +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 22/34] ext4: add a new iomap aops for regular file's buffered IO path Date: Wed, 10 Apr 2024 22:29:36 +0800 Message-Id: <20240410142948.2817554-23-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: cCh0CgAX6RFSpBZmcwR8Jg--.63000S26 X-Coremail-Antispam: 1UD129KBjvJXoWxCryDCFWrXrWrZr17Kr17KFg_yoW5CF17pF Z8Kas3Gr18Zr9F9a1fXayDZF4Yya4fGw4UKFW3G3WavFyrGrW7KFWvk3WjkFy5t3y8Ar17 XF4jkry7WF17CrDanT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUHI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4 xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCa FVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI4 02YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCF x2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUXVWUAwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWDJVCq3wCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr 1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr1j6F4U JwCI42IY6I8E87Iv6xkF7I0E14v26rxl6s0DYxBIdaVFxhVjvjDU0xZFpf9x0pRDPE-UUU UU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspamd-Queue-Id: 37DF718000F X-Rspam-User: X-Stat-Signature: kos6yige6s69nq9etb8e9txgnihpwi5s X-Rspamd-Server: rspam03 X-HE-Tag: 1712759923-864652 X-HE-Meta: U2FsdGVkX18gHCI5LgzTZDHNw6mknt6exk9gTWvNL+ZXot4AOXZkINFgqV6n6ERSOysU1bo5izC7He+e6CsgMN66omj9KYkFwFCOyY85t+aBqYVOdudn6RQpikyon0DM+0nlXPMp7L2V+vtn+/OYm6u6URkUZcXQABox4FZj424/TEQ25xTHdEaFuctEJoRJqR2TPO2zT+3KnODPlH5h2CPvs+KJR/dok4ME4NGLwNo5GqRKTepRfvue5kQfTRSyUar9zb9E7GAITcybPt6TBlCbHpBl0n1itoahl8CLseu2Mc1OEl24zRdcgruWsLknTyNtt2zPXKd0+3abFm053lCkBAmlGV6tEcE9arZVkIxkc93QIVz/rK2l4f7Gh9I0DQ9FINYXuvl8mzPohwUUsU6MFZfhwzi6mR+IJd0RBnISO89HMWlkWmaIOE2Qro/e7VN/JiGLf9QxvTnbmRp3fweGopKByXLYZugu7qxQZxuHLuSAafMYSdBfLmRwSnIG8xUW2n90gJvU0B4bphVBtWAUFeivbU02tnKjp//fvoo7uhUt15pDcax+znuSnEZiuKjKQCK1HZMJFM+06JaB2H4BFPzACSO+DfWOHZYFZcTKGUyEpDvNlOMj3Eh6/XNzh/qQyydQu3kNm59laFhhGJtwBlsdMcA1qeo6d+3M5SrgqmlCb3vYoI3Cu2FA1i5KTkniAzX4c9U+QGiBpKmUcxbSzxHCg9KPRwa0/Ew5lpjiMZ6sOl2WvBP0OeZJyBji1iDYIn6Q1Tk1DtWO5dpVQy8T6KSgchyaIRXG5fPfIULRRslRibxe72ZytQcbF2G9+Gz8pcdCRM8kKVv5H7OKifRUar4ob5LJg8Rc4CFZd5yRxcenHriykDLRyewiTskTouU5SjUZ3mvhNm/dKsDZEAzN7glFDaTYitU13gx4PVIlaw5BkX5Axwahk5ZvZjxM3QpIrTn93094+jonP2P iKEzAHK/ qUH/+md27Meu/N6o= 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 Introduce a new iomap address space operations ext4_iomap_aops to support regular file's buffered IO path, also add an inode state flag EXT4_STATE_BUFFERED_IOMAP, if it was set on an inode, it means that inode use the iomap path instead of buffer_head path for buffered IO. Most of their callbacks can use generic implementations, the left over read_folio, readahead and writepages will be implemented later. Signed-off-by: Zhang Yi --- fs/ext4/ext4.h | 1 + fs/ext4/inode.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 7e27e1e7c579..05949a8136ae 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1913,6 +1913,7 @@ enum { EXT4_STATE_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */ EXT4_STATE_FC_COMMITTING, /* Fast commit ongoing */ EXT4_STATE_ORPHAN_FILE, /* Inode orphaned in orphan file */ + EXT4_STATE_BUFFERED_IOMAP, /* Inode use iomap for buffered IO */ }; #define EXT4_INODE_BIT_FNS(name, field, offset) \ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2704dca96ee7..4c1fed516d9e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3523,6 +3523,22 @@ const struct iomap_ops ext4_iomap_report_ops = { .iomap_begin = ext4_iomap_begin_report, }; +static int ext4_iomap_read_folio(struct file *file, struct folio *folio) +{ + return 0; +} + +static void ext4_iomap_readahead(struct readahead_control *rac) +{ + +} + +static int ext4_iomap_writepages(struct address_space *mapping, + struct writeback_control *wbc) +{ + return 0; +} + /* * For data=journal mode, folio should be marked dirty only when it was * writeably mapped. When that happens, it was already attached to the @@ -3612,6 +3628,21 @@ static const struct address_space_operations ext4_da_aops = { .swap_activate = ext4_iomap_swap_activate, }; +static const struct address_space_operations ext4_iomap_aops = { + .read_folio = ext4_iomap_read_folio, + .readahead = ext4_iomap_readahead, + .writepages = ext4_iomap_writepages, + .dirty_folio = iomap_dirty_folio, + .bmap = ext4_bmap, + .invalidate_folio = iomap_invalidate_folio, + .release_folio = iomap_release_folio, + .direct_IO = noop_direct_IO, + .migrate_folio = filemap_migrate_folio, + .is_partially_uptodate = iomap_is_partially_uptodate, + .error_remove_folio = generic_error_remove_folio, + .swap_activate = ext4_iomap_swap_activate, +}; + static const struct address_space_operations ext4_dax_aops = { .writepages = ext4_dax_writepages, .direct_IO = noop_direct_IO, @@ -3634,6 +3665,8 @@ void ext4_set_aops(struct inode *inode) } if (IS_DAX(inode)) inode->i_mapping->a_ops = &ext4_dax_aops; + else if (ext4_test_inode_state(inode, EXT4_STATE_BUFFERED_IOMAP)) + inode->i_mapping->a_ops = &ext4_iomap_aops; else if (test_opt(inode->i_sb, DELALLOC)) inode->i_mapping->a_ops = &ext4_da_aops; else