Skip to content

Commit 8806f27

Browse files
Hongbo Librauner
authored andcommitted
iomap: stash iomap read ctx in the private field of iomap_iter
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 <lihongbo22@huawei.com> Link: https://patch.msgid.link/20260109102856.598531-2-lihongbo22@huawei.com Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 8f0b4cc commit 8806f27

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

fs/fuse/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static int fuse_read_folio(struct file *file, struct folio *folio)
979979
return -EIO;
980980
}
981981

982-
iomap_read_folio(&fuse_iomap_ops, &ctx);
982+
iomap_read_folio(&fuse_iomap_ops, &ctx, NULL);
983983
fuse_invalidate_atime(inode);
984984
return 0;
985985
}
@@ -1081,7 +1081,7 @@ static void fuse_readahead(struct readahead_control *rac)
10811081
if (fuse_is_bad(inode))
10821082
return;
10831083

1084-
iomap_readahead(&fuse_iomap_ops, &ctx);
1084+
iomap_readahead(&fuse_iomap_ops, &ctx, NULL);
10851085
}
10861086

10871087
static ssize_t fuse_cache_read_iter(struct kiocb *iocb, struct iov_iter *to)

fs/iomap/buffered-io.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,14 @@ static int iomap_read_folio_iter(struct iomap_iter *iter,
555555
}
556556

557557
void iomap_read_folio(const struct iomap_ops *ops,
558-
struct iomap_read_folio_ctx *ctx)
558+
struct iomap_read_folio_ctx *ctx, void *private)
559559
{
560560
struct folio *folio = ctx->cur_folio;
561561
struct iomap_iter iter = {
562562
.inode = folio->mapping->host,
563563
.pos = folio_pos(folio),
564564
.len = folio_size(folio),
565+
.private = private,
565566
};
566567
size_t bytes_submitted = 0;
567568
int ret;
@@ -620,13 +621,14 @@ static int iomap_readahead_iter(struct iomap_iter *iter,
620621
* the filesystem to be reentered.
621622
*/
622623
void iomap_readahead(const struct iomap_ops *ops,
623-
struct iomap_read_folio_ctx *ctx)
624+
struct iomap_read_folio_ctx *ctx, void *private)
624625
{
625626
struct readahead_control *rac = ctx->rac;
626627
struct iomap_iter iter = {
627628
.inode = rac->mapping->host,
628629
.pos = readahead_pos(rac),
629630
.len = readahead_length(rac),
631+
.private = private,
630632
};
631633
size_t cur_bytes_submitted;
632634

include/linux/iomap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
341341
const struct iomap_ops *ops,
342342
const struct iomap_write_ops *write_ops, void *private);
343343
void iomap_read_folio(const struct iomap_ops *ops,
344-
struct iomap_read_folio_ctx *ctx);
344+
struct iomap_read_folio_ctx *ctx, void *private);
345345
void iomap_readahead(const struct iomap_ops *ops,
346-
struct iomap_read_folio_ctx *ctx);
346+
struct iomap_read_folio_ctx *ctx, void *private);
347347
bool iomap_is_partially_uptodate(struct folio *, size_t from, size_t count);
348348
struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len);
349349
bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags);
@@ -595,7 +595,7 @@ static inline void iomap_bio_read_folio(struct folio *folio,
595595
.cur_folio = folio,
596596
};
597597

598-
iomap_read_folio(ops, &ctx);
598+
iomap_read_folio(ops, &ctx, NULL);
599599
}
600600

601601
static inline void iomap_bio_readahead(struct readahead_control *rac,
@@ -606,7 +606,7 @@ static inline void iomap_bio_readahead(struct readahead_control *rac,
606606
.rac = rac,
607607
};
608608

609-
iomap_readahead(ops, &ctx);
609+
iomap_readahead(ops, &ctx, NULL);
610610
}
611611
#endif /* CONFIG_BLOCK */
612612

0 commit comments

Comments
 (0)