From patchwork Wed Apr 10 13:28:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13624594 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 5F97BCD11C2 for ; Wed, 10 Apr 2024 13:56:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6C726B00BB; Wed, 10 Apr 2024 09:56:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1DA96B00BC; Wed, 10 Apr 2024 09:56:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE3446B00BD; Wed, 10 Apr 2024 09:56:25 -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 B09BF6B00BB for ; Wed, 10 Apr 2024 09:56:25 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 760D0160694 for ; Wed, 10 Apr 2024 13:56:25 +0000 (UTC) X-FDA: 81993771930.13.B32D4B6 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf29.hostedemail.com (Postfix) with ESMTP id 022CF120028 for ; Wed, 10 Apr 2024 13:56:21 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.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=1712757383; 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=kVAk2dgYSxzULNFo0gK5IV9T1YIMmcWWsAJ0rMEEiASMeiTDl1caZI8JeViaQ3CTyJnAz9 jxD4IS5RrBD0E+Ty+vFfJxuHU2E2CxogAAd24geNNWu4Lw8ahmkETUmnJJAMfEGIYP3Dk0 SUd65ke8UOBXmWhGDIpDLWwOa8DyJhw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.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=1712757383; a=rsa-sha256; cv=none; b=n3/3SlbXwO3nrh0Om32FixJxmq3LH1ThHVwh8ElHy3agiASlu0YMWzuOby6cagGbxkc36s hFMx18+ZQm+M6/bJTx+XY7M95nCChPVOCRFioTwq7rMNTfMwqq0Mdy+F1Q++JgL8PPipUA 2I+rGl9h2pzEgZreJ/8BkB5mMj0yexE= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF3lY1JhQz4f3jJ2 for ; Wed, 10 Apr 2024 21:36:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 955B21A016E for ; Wed, 10 Apr 2024 21:37:01 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn+RHolRZmeCl4Jg--.8806S26; Wed, 10 Apr 2024 21:37:01 +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, 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 21:28:06 +0800 Message-Id: <20240410132818.2812377-23-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> References: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAn+RHolRZmeCl4Jg--.8806S26 X-Coremail-Antispam: 1UD129KBjvJXoWxCryDCFWrXrWrZr17Kr17KFg_yoW5CF17pF Z8Kas3Gr18Zr9F9a1fXayDZF4Yya4fGw4UKFW3G3WavFyrGrW7KFWvk3WjkFy5t3y8Ar17 XF4jkry7WF17CrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUA rcfUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 022CF120028 X-Stat-Signature: 69rsm1iw4f91dgf9gq3he5j1ff5nimcm X-HE-Tag: 1712757381-99925 X-HE-Meta: U2FsdGVkX19hS55Eo/4qxe0oG0Wk/ERJB/HM67ZEFCjw+ZPDtGl8VWAUYZL2GYyBuc7YirMbrM/tjIAeeoXp+Zq5iWXX52MRczRbHGznFpiWCZA/kA19a1S0liKvh7/K91o7cOQh7TCwz8DsE7Rb64o8hJiKOc76xFRFDngy1rEmkpidsBg3788QGB1W69NqWXO5WMNp4QLXKYwoonXtpK55lHjXQRfitNU+5ou/4lRHN7BzCBUj6QHNZXKpRrJiYz4pXQsCKl4/GV8iqd76gq2zSb65xI0GRJfcvf3mxoqFgaPb78fwsjb9Vuz0E54FjX9WTa6qc+jgaoUB6ph0E6/T9qSIOqkTfMwWeB5GQ2VPF8/jEAgK3H5LqhKV3vFWoDUted8y5tF0L3wgZMMll9O42rLBPff/vbSd/uNYoHCdRHkrJvIzF0Ir0k2mr8b6oyKUcUSPUYYT8cj0fCd81T7b2vPjFwNy0hnAZ+ymqcntZ/uSeY9Ui6r/o/gsOkzxzCDxDT3Wadx6B02bX+2K3egMVLRCzTYIMdbX16SvdgEATQXyIMboH82dXCsUm/IAuUvuuorvKj6YzOJ1UCyJ1U9qEvV0UTKcIVOJ/MkSR23T/gM0o+RBQGt8i/8v+uimxebErjO/y5mW/kH6/TMYFDUyLTOhV2gq52ekPhftsM8MJyLWy064uQ7K8UVe21e52Ni6S0wodd/hO+drbA/xO0ylCr5DJRRR1EyYaYKNe30hMG4vcXCr2g4ALOj8bQpEKPvPKjoEKHAAlFcdvA12ZTMF6th0N7z4RrlqnFGfyJM1iaOtXsmQjnupdTz6z1+RD3xFk7GMdj5bQoqisIvtdtuo929ooCnCmftqpD5L7FfR60UD0WcBST+jKioI51DpJ8xHY9e93qA/cTFTnd4hlHnhhYTeecyEIrkM8BVOwpN/6FGBafBChSlBXUWG0SC/7NlJGwm1nzpVJGiSsYf ZyywNY35 hPwcnTG3Bdxb3sSSEHIbWgJcKOqdctzOzmFj+B9xJtkIrLbe60MKGkFpThghVLG30zJTg2yANuXImYiszfrzyhV6IhvhiUv65XUwhgjiAOMItDD+83ZGoKHi0o8l9/f+mh3i94x7HyKUnXKKCzfAEWlZnKAtJliommeeYQdBkFq+a2BifLV5R+f1QGD8O14R/pl/xbkwYo/9sNCw= 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