From nobody Sat Feb 7 06:55:55 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 6F3B02DF131; Wed, 31 Dec 2025 09:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767172444; cv=none; b=DVJnYWGMzag3mGb4X0lhp3ZNShLFDkdWa/5JbxYSunieX/duavileaACslfxVjJcY3dUH8xPh6Aq1G10aaoGZlStte89YvcsMl2P6gXMdKqUZZKFupYXSZOL6rtyv2P1MH47oU2qOg5G59GCKc7CfQ6PyrxGP8P5vC6M0Ktivv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767172444; c=relaxed/simple; bh=n0CYApCMSTPET0JshPYELMjqMo0Sh6yI6KkP6p9i+R0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HpKmRVUQ4wQJ3KkMTsxIv6W39380Ac7JYROaic86qc1ZiAUeYrHE+i/B98yAFvvTRNKiefreLC71ui6dLtR0xhpTJWpJkVNAxOETJRpMzmhNepzzUhzgVuEdI8t5b7urW0A82ZQX5wXUCZ1ra3pZwASmsy+JvEW6xr2YRUR/A1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=ZP999kvm; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="ZP999kvm" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=lfJ/O4D8J9vNgJSRQcHGc3PWqPTwsbyNQanvesy0zuM=; b=ZP999kvmVIM5g0Z3M5rHvI+y02z5I7bYWmfzFpC634J7gM4BedPDjrL4fqVf3LZONrFV0gfaN U6jq58kyErcj7RXi+ftcBapO3T3+xxEGWoIu19ZNf2zZg2VcSoQLSsTRGstQrWQnaVXJm2+QAMb wvyKxEUvvb4EU52IoW46QKE= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4dh41f5hq2zmV71; Wed, 31 Dec 2025 17:10:46 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 90BE74069C; Wed, 31 Dec 2025 17:13:58 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 31 Dec 2025 17:13:57 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v12 01/10] iomap: stash iomap read ctx in the private field of iomap_iter Date: Wed, 31 Dec 2025 09:01:09 +0000 Message-ID: <20251231090118.541061-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20251231090118.541061-1-lihongbo22@huawei.com> References: <20251231090118.541061-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" It's useful to get filesystem-specific information using the existing private field in the @iomap_iter passed to iomap_{begin,end} for advanced usage for iomap buffered reads, which is much like the current iomap DIO. For example, EROFS needs it to: - implement an efficient page cache sharing feature, since iomap needs to apply to anon inode page cache but we'd like to get the backing inode/fs instead, so filesystem-specific private data is needed to keep such information; - pass in both struct page * and void * for inline data to avoid kmap_to_page() usage (which is bogus). Signed-off-by: Hongbo Li Reviewed-by: Gao Xiang --- fs/fuse/file.c | 4 ++-- fs/iomap/buffered-io.c | 6 ++++-- include/linux/iomap.h | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 01bc894e9c2b..f5d8887c1922 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -979,7 +979,7 @@ static int fuse_read_folio(struct file *file, struct fo= lio *folio) return -EIO; } =20 - iomap_read_folio(&fuse_iomap_ops, &ctx); + iomap_read_folio(&fuse_iomap_ops, &ctx, NULL); fuse_invalidate_atime(inode); return 0; } @@ -1081,7 +1081,7 @@ static void fuse_readahead(struct readahead_control *= rac) if (fuse_is_bad(inode)) return; =20 - iomap_readahead(&fuse_iomap_ops, &ctx); + iomap_readahead(&fuse_iomap_ops, &ctx, NULL); } =20 static ssize_t fuse_cache_read_iter(struct kiocb *iocb, struct iov_iter *t= o) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index e5c1ca440d93..5f7dcbabbda3 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -555,13 +555,14 @@ static int iomap_read_folio_iter(struct iomap_iter *i= ter, } =20 void iomap_read_folio(const struct iomap_ops *ops, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, void *private) { struct folio *folio =3D ctx->cur_folio; struct iomap_iter iter =3D { .inode =3D folio->mapping->host, .pos =3D folio_pos(folio), .len =3D folio_size(folio), + .private =3D private, }; size_t bytes_submitted =3D 0; int ret; @@ -620,13 +621,14 @@ static int iomap_readahead_iter(struct iomap_iter *it= er, * the filesystem to be reentered. */ void iomap_readahead(const struct iomap_ops *ops, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, void *private) { struct readahead_control *rac =3D ctx->rac; struct iomap_iter iter =3D { .inode =3D rac->mapping->host, .pos =3D readahead_pos(rac), .len =3D readahead_length(rac), + .private =3D private, }; size_t cur_bytes_submitted; =20 diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 520e967cb501..441d614e9fdf 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -341,9 +341,9 @@ ssize_t iomap_file_buffered_write(struct kiocb *iocb, s= truct iov_iter *from, const struct iomap_ops *ops, const struct iomap_write_ops *write_ops, void *private); void iomap_read_folio(const struct iomap_ops *ops, - struct iomap_read_folio_ctx *ctx); + struct iomap_read_folio_ctx *ctx, void *private); void iomap_readahead(const struct iomap_ops *ops, - struct iomap_read_folio_ctx *ctx); + struct iomap_read_folio_ctx *ctx, void *private); bool iomap_is_partially_uptodate(struct folio *, size_t from, size_t count= ); struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t = len); bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags); @@ -595,7 +595,7 @@ static inline void iomap_bio_read_folio(struct folio *f= olio, .cur_folio =3D folio, }; =20 - iomap_read_folio(ops, &ctx); + iomap_read_folio(ops, &ctx, NULL); } =20 static inline void iomap_bio_readahead(struct readahead_control *rac, @@ -606,7 +606,7 @@ static inline void iomap_bio_readahead(struct readahead= _control *rac, .rac =3D rac, }; =20 - iomap_readahead(ops, &ctx); + iomap_readahead(ops, &ctx, NULL); } #endif /* CONFIG_BLOCK */ =20 --=20 2.22.0