Skip to content

Commit bd735bd

Browse files
lostjefflehsiangkao
authored andcommitted
erofs: implement fscache-based data read for inline layout
Implement the data plane of reading data from data blobs over fscache for inline layout. For the heading non-inline part, the data plane for non-inline layout is reused, while only the tail packing part needs special handling. Signed-off-by: Jeffle Xu <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent 1442b02 commit bd735bd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

fs/erofs/fscache.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,33 @@ static int erofs_fscache_meta_readpage(struct file *data, struct page *page)
8383
return ret;
8484
}
8585

86+
static int erofs_fscache_readpage_inline(struct folio *folio,
87+
struct erofs_map_blocks *map)
88+
{
89+
struct super_block *sb = folio_mapping(folio)->host->i_sb;
90+
struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
91+
erofs_blk_t blknr;
92+
size_t offset, len;
93+
void *src, *dst;
94+
95+
/* For tail packing layout, the offset may be non-zero. */
96+
offset = erofs_blkoff(map->m_pa);
97+
blknr = erofs_blknr(map->m_pa);
98+
len = map->m_llen;
99+
100+
src = erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP);
101+
if (IS_ERR(src))
102+
return PTR_ERR(src);
103+
104+
dst = kmap_local_folio(folio, 0);
105+
memcpy(dst, src + offset, len);
106+
memset(dst + len, 0, PAGE_SIZE - len);
107+
kunmap_local(dst);
108+
109+
erofs_put_metabuf(&buf);
110+
return 0;
111+
}
112+
86113
static int erofs_fscache_readpage(struct file *file, struct page *page)
87114
{
88115
struct folio *folio = page_folio(page);
@@ -108,6 +135,11 @@ static int erofs_fscache_readpage(struct file *file, struct page *page)
108135
goto out_uptodate;
109136
}
110137

138+
if (map.m_flags & EROFS_MAP_META) {
139+
ret = erofs_fscache_readpage_inline(folio, &map);
140+
goto out_uptodate;
141+
}
142+
111143
mdev = (struct erofs_map_dev) {
112144
.m_deviceid = map.m_deviceid,
113145
.m_pa = map.m_pa,

0 commit comments

Comments
 (0)