Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp188772lqj; Wed, 10 Apr 2024 07:48:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVdp6yAXCPGh9KGVVdelY5C4AX9GPeQmcov+G38aouyjCyY00BYfHDMwq6qs2W/l7d4bRhPTWcU8qbRRT8FItfyoUaHuV+AK6ryqJepgQ== X-Google-Smtp-Source: AGHT+IFIgUTvW1Pjgo4wTKUYgSLA69aSFIHjy68e+Isu28OX49XlgUd9isn9jP6HieCoFRX9YY2R X-Received: by 2002:a17:902:f684:b0:1e0:bc64:a37a with SMTP id l4-20020a170902f68400b001e0bc64a37amr8715939plg.8.1712760498580; Wed, 10 Apr 2024 07:48:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712760498; cv=pass; d=google.com; s=arc-20160816; b=IKQM5pLc6ANfTGlplwZq6m5p3S5fA8uMhTdGxI5+D8qVPuceujj1PGT9t2TGtTO/Dt IkD6PEZbG9KON5iLKRL9qC4YxQegBBCQ51yFN/p9rNg40vnJn3jamDHbnKoH8WeM0RVx Y6VXYtugdMMKlLlqEQGNKWeI5HW/OFDyK3tOiMf84ZCcheqsb1QzfLBiQQvF+BcJAKU3 wQkaU+VYKvaqajcCJCUGo2qwEMH41QAGD0NC/G2ThGM0nLG+KjXaFnn4Z+3MxB520zE6 XeZxzCsK3nMzQGRkXrJ0chYvh3rY9MHHJSsjKzkkojGanBGtFS8gCDnqmqHdIXYl6hX1 wagA== 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=fOgEdgws1v255Vbot+gwvOYlz1LDBoFxwezUsQaS9kk=; fh=VCdyVZCUh9R8dltaA9/RWs/hxQzWhc63WX0fta2PQtE=; b=wUyT9lk72EHQJVUnticZoVrdYTnHtULCKbWoRRjfdhDu2TcmX9sF7QSn3dbhg1+0U3 UxD/hVHaqMPgx65iZyWngRTavy+dBYLGp1JQawe3P6CJWtwj12ANU5dNn6H6pXcBVNFE u1VXgjV0/nBwoB9Mo4fjn6N32I5q+rz9u7GokkEDR+GfNExOxcRqAfIRitbhblW6YPSP AJWoKjfnXPZf3L4CyMrZamF4oclFyvs9J8JtHbc0V9tSVYg++5iwixyUfoRFfuebbb0o 9tnFuL3ZBxe+GKbd6f9hSy7axYEmaxBPp0eboaEE4Imn9zAO9C5F9WdclR4ynaPNapv4 oBZw==; dara=google.com 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-1993-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1993-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b001e3f91122c5si7952216plf.196.2024.04.10.07.48.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:48:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1993-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1993-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1993-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 11FCE28B6EC for ; Wed, 10 Apr 2024 14:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38E56180A98; Wed, 10 Apr 2024 14:38:46 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 3E5D517BB3E; Wed, 10 Apr 2024 14:38:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759925; cv=none; b=OHpV7maWwVoU/AwGu8rFNkWvSvhoSF4W8vQboY/3TZLeHpeWFdAtE0yXn+w6HZUPvxzxe1qF567SntVAaTsy/6eKrCmuYO6wCMqM8r8zMok8WaGFvahirmhvTL1BbiGTwmt7MOOF79vvV9ZVw//0GdlktlVA2no3SHVJmjlhq+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759925; c=relaxed/simple; bh=KM32SNb41b4Lg9S0iKRUmn1qiuXmKsCzoFcVq1tt5Q4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LfbRM6UsfKcV0atmVtZsPog6LzYnHo6dN2H762qkPozz6cxmP5kQiwlxdcqptRe6DXdVsjo2X82yns95TVydjBrryPdmD+jMYKHUJYczUAsOVaACTII48wsedrv4j/R6ZF1ygNPtOUHowhb/rMk8QOhghTOFYsHRPcmSTYQ3CTs= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VF56d1RbWz4f3kny; 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 0BCAD1A0568; Wed, 10 Apr 2024 22:38:40 +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> 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:cCh0CgAX6RFSpBZmcwR8Jg--.63000S26 X-Coremail-Antispam: 1UD129KBjvJXoWxCryDCFWrXrWrZr17Kr17KFg_yoW5CF17pF Z8Kas3Gr18Zr9F9a1fXayDZF4Yya4fGw4UKFW3G3WavFyrGrW7KFWvk3WjkFy5t3y8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voofrz/ 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 -- 2.39.2