From patchwork Sat Jan 27 01:58:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13533907 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 C97A0C47422 for ; Sat, 27 Jan 2024 02:03:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 424B06B00A2; Fri, 26 Jan 2024 21:02:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B8C06B009F; Fri, 26 Jan 2024 21:02:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C1F16B00A0; Fri, 26 Jan 2024 21:02:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DCFC36B009C for ; Fri, 26 Jan 2024 21:02:56 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BDE5CC0166 for ; Sat, 27 Jan 2024 02:02:56 +0000 (UTC) X-FDA: 81723442752.23.69D6D6B Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf13.hostedemail.com (Postfix) with ESMTP id 41A832000B for ; Sat, 27 Jan 2024 02:02:53 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 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=1706320975; 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=jZXDX/r428qGIjAuoeLgCUOV30TlAf4fX7eW5feSwIY=; b=yco3jGlYE+MVlrOrC6XW4K/II+hirosUqiEJOdoSUXcxX+WRoZQgYxZNUsXI4cXBuHJLYz MlqdKNLewihCoQQzzN4Ec26vXTY58A5uCXAkjyEjigb02wR3SJlWkfiZhsxwXxGZlB92YE 8vfQarX8cJwREujQ12xQEYx/EvBgZKw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706320975; a=rsa-sha256; cv=none; b=ToZFuscIwPY22Cnatf9I/qkwETjXCTx1rIt9qKlx72SS/WSc/q/Gon2Ez+Yrkdz4UwCUlD ofWtUq4PuSuU4GKBgFx8vpBRccb7qPCpN81nFpNF5AbfkAmt/dC2hY8cESn1l478BtloGx 1RtqH1hAkqFV4LqYU3U0DzgPChGZ+DA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TMHrl3gNqz4f3k5v for ; Sat, 27 Jan 2024 10:02:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id E77361A0272 for ; Sat, 27 Jan 2024 10:02:49 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g40ZLRlGJtmCA--.7377S20; Sat, 27 Jan 2024 10:02:49 +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 v3 16/26] ext4: add a new iomap aops for regular file's buffered IO path Date: Sat, 27 Jan 2024 09:58:15 +0800 Message-Id: <20240127015825.1608160-17-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> References: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g40ZLRlGJtmCA--.7377S20 X-Coremail-Antispam: 1UD129KBjvJXoWxur43KF1xCr4ruw1kKF13twb_yoW5Cr1UpF Z8Gas8Gr18Zry7ua1fXFWDZF4Yka4fJw4jgFW3G3Wa9ryrGrW7KFWvka4jyFy7t3y8Ar17 XF4jkry7WFy7CrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl 2NtUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Stat-Signature: csfjwij7en9w1gd1jk8r5whkb78ksu6d X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 41A832000B X-Rspam-User: X-HE-Tag: 1706320973-578363 X-HE-Meta: U2FsdGVkX18mF1NoWdnEmHqol+NEn+MjiS2N0YdZq2Yc0b5ERdOQwgUY/T0AoJgCHhcYg4pcbNIya7jNeKyXCnzuOtP0F+BMfW6RLxfDqqaBu2XIKEqG63lp/VfVyKimmZzfd6h+1J33vq2krOjmSmhT/FYmkTUxc2MDCZ0crTnIUXoVh9/lhaeZWdtGtTsmeTwBFpr7WcHWKrZKQf867hSxAok1cvRliTDp9VWBBUsRdnE7n5kJJ2vxSb9Fvc+KigstbeIybgGJrdy2GLBO9Lqxh3tCaNJ+yQw4erbu5MPzmOdqvNHX6PEe83yYLweC8IYJdhWh9AzrjT4Djt7tY5LEhg6kRTAZYuq0nZEErAmU3GpMUHiLF/TnIkFC9dX8XvLuH80VbdOicBPD6v0bKE3phix431NUJSa2JoMuCBjKokXId8OyQXn8C1w36EoZ4oKIUBgeZJ8PAk2aXrh6jIqHdaaxgzqgyxXSUziuQV6DvIMjPIlDQiYj/xwju41ihCu7Okqic01j1G0ou4YSVkwgXE8GDb6f/vmv1IAUYznu0GpFwXTIfuwk4FjNl+aRTvoEx5+dL6BbMjEbG5yUFQ67kPY6mPs3JNed21vC3ISiwjMN+CM0jto73smQDz4svCIaLEHx+unEqYvTzKY4Ig2EPXHTblSB7uPybbCNuZ2Hf9gELAjrNxXfN05LfNbzoO1hoMLJeOyokdhmslqFef890v/y9Za2r8rIVm59EyjvCr9RBau5GnPx9ffKjnUBu/xAaPi3D3JO0lX/Z6ozsWhLvVMuaqi/QssQezKoKOK0pA2HzaYxwpuVKQXpWXDbsDi4GjokH15IeB3KhUYRlNJL/RC1bAkNf/mEda9NNq5XNR0GzctvNNaPYg/ghs/laHlh4PvvEpniMNGvAxeFnhpMAvsY8oWBuKABPjPDhOF1j5hZy90+qkM2KhGIF9UrMCP4V7kiVzjL+ZWbSMt 3aIcPF6j J0D/0A5frGyKadppk8jTqwdsq1Ze60A+cCDda70GiQFb3OqTnrSrG5QEyozNtcCExn+nA3w/iVexED1gwHcipYS3EBkltFeRQJNLKdNWca9VBo+YzeioS7ssURL7RKrse0lyi8al9SXbkiY8jfVCY0iLAlw7gqbPd0DQcoDmEcSM+4VMsGuyrm83Qnctl0O2knj69OfJVR1D3rEl19ME+SZjTfLIVIpKVeRI91g6VfWexYHhkewEaqaKbLvFMk99kxFyO 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 and add an inode state flag EXT4_STATE_BUFFERED_IOMAP to indicate that one inode use the iomap path. Most of their callbacks should be able to use general implementation, the left over read_folio, readahead and writepages should 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 287284a3f128..3461cb3ff524 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 125d0665fa10..eca9bf5dd255 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3507,6 +3507,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 @@ -3596,6 +3612,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_page = generic_error_remove_page, + .swap_activate = ext4_iomap_swap_activate, +}; + static const struct address_space_operations ext4_dax_aops = { .writepages = ext4_dax_writepages, .direct_IO = noop_direct_IO, @@ -3618,6 +3649,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