Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp44599rdb; Fri, 26 Jan 2024 18:08:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIx2DSOeKNekmdXkV7ObFYK65a0YB9zy7sxv4tq9ORn66jm+oFcbagtPeH5ydUp87Xm41z X-Received: by 2002:a05:6402:517b:b0:55d:c05c:673c with SMTP id d27-20020a056402517b00b0055dc05c673cmr390386ede.22.1706321334521; Fri, 26 Jan 2024 18:08:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706321334; cv=pass; d=google.com; s=arc-20160816; b=CGWywZYWO2n92xaOcn7EHHWJJfBEjF1vchVLF1SJbWFDZdTP6YFVxenHqmEBeCzMkK 1hghE05fPGDPdps6t1w4m92av8Qj7MHZaRfOLzJDu29/Il03pG4LnHa72XcWgXqbRG7D rCh45ei3swmozfVQbPwAM1bLMLGT++A1K4+Xbg7cEadvzKjbgZeTIyJ4mzSI32/9h6pj 4roi8of3B+5U5g7asSscDRyY4xtMAy7R6K9oN6HP0EexyLScUVwzktbbRXJXZdQlCCog 7CegqSduj+6dbF6my4HoCC9Z44It7n/kXmWEWYaJpLBCg7Tr3ZBDjZZj3cGvaKxoIQ/x 4DZw== 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=jZXDX/r428qGIjAuoeLgCUOV30TlAf4fX7eW5feSwIY=; fh=UhGiR19HeAIu8tzXykjZgtAKLLMPZj8YX6gPScUOsdE=; b=vEBZiX21L3QOQrd/ZSziZGuWXM+JIYi4O9bBBdj7qW8zWtmCXZCWTAQLqIDPpi5WMX YroIAjo8AItmrgM13w11UvZbdbiezsRv94Ci4/3cjmLO0jzZmyhN7kPKUf0wJLIkOQRi +UNWcsPPWgvKw3MhpEXjOfS7JNG/wwO0vVJ+I6FI86LiYFaJVzBSgqo19NEz9airRzz4 KAOaU8IlwqVDqCYxmhf90AAEhRqLgZpW/9l6pDlr8S5rwsttjoagiqpvFm4H/uUhjJpu ugTUkq9BY5zpl+Ew7OWjPI62ow23XgbWiQlV/ojObKOq/1BEWGGh0Pm0wfV1SSlIvC3t 3QnA== 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-965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-965-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id es26-20020a056402381a00b00558a7d36950si1217293edb.129.2024.01.26.18.08.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 18:08:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-965-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C51761F22881 for ; Sat, 27 Jan 2024 02:08:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F89C28E2E; Sat, 27 Jan 2024 02:02:55 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (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 DA00D250EE; Sat, 27 Jan 2024 02:02:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706320974; cv=none; b=VQmGee7RJtkbXc8HtBHMn8R2tBzqqg80f/Jh61///5IGV91gK/NBkZ3B2dA7faBL3smzyenpQYN8FJlNABrgESEp+lN6cy6DEDC6Fq1Bc9zBS9stuatK9nVq3fZcUm00Vq/mnyshGeJqJyq/bsB5UkpDGGXhOxBB7zMLp4KLU8M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706320974; c=relaxed/simple; bh=7YKFrlvZ/lxWAihHwYcRtDZ3s326RXyN+mp+GRn0QwU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MSOZjbNRXNi+KVBJA2GuHksXi/eoCgKGL+O45CO/+/UCwQbomoQI1QbTLgk6K1Vuxn48uRf5QKGhFDHKeEHbqku1tlS5ZGrdp01kjpO62UnA68v9CClK5oT4jHjNcinTuQvrJrm7zqgIufyc6Ns5fnI4YdB8OhUMsI8GHClU2Oc= 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.51 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TMHrg4bQQz4f3lg0; Sat, 27 Jan 2024 10:02:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 026501A0232; Sat, 27 Jan 2024 10:02:50 +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> 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: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/ 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 -- 2.39.2