From: Gao Xiang hsiangkao@linux.alibaba.com
anolis inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT
Reference: https://gitee.com/anolis/cloud-kernel/commit/4f2620305915
--------------------------------
ANBZ: #1666
commit bd735bdaa62fb64980c07f5443f24aefd0081569 upstream.
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 jefflexu@linux.alibaba.com Reviewed-by: Gao Xiang hsiangkao@linux.alibaba.com Link: https://lore.kernel.org/r/20220425122143.56815-20-jefflexu@linux.alibaba.com Acked-by: Chao Yu chao@kernel.org Signed-off-by: Gao Xiang hsiangkao@linux.alibaba.com Signed-off-by: Huang Jianan jnhuang@linux.alibaba.com Reviewed-by: Jeffle Xu jefflexu@linux.alibaba.com Signed-off-by: Baokun Li libaokun1@huawei.com --- fs/erofs/fscache.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 5c48656550f7..37f8d754a741 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -89,6 +89,34 @@ static void erofs_fscache_invalidate_page(struct page *page, unsigned int offset ClearPageFsCache(page); }
+static int erofs_fscache_readpage_inline(struct page *page, + struct erofs_map_blocks *map) +{ + struct super_block *sb = page->mapping->host->i_sb; + struct erofs_buf buf = __EROFS_BUF_INITIALIZER; + erofs_blk_t blknr; + size_t offset, len; + void *src, *dst; + + /* For tail packing layout, the offset may be non-zero. */ + offset = erofs_blkoff(map->m_pa); + blknr = erofs_blknr(map->m_pa); + len = map->m_llen; + + src = erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP_ATOMIC); + if (IS_ERR(src)) + return PTR_ERR(src); + + dst = kmap_atomic(page); + memcpy(dst, src + offset, len); + memset(dst + len, 0, PAGE_SIZE - len); + kunmap_atomic(dst); + + erofs_put_metabuf(&buf); + SetPageUptodate(page); + return 0; +} + static int erofs_fscache_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; @@ -110,6 +138,11 @@ static int erofs_fscache_readpage(struct file *file, struct page *page) goto out_unlock; }
+ if (map.m_flags & EROFS_MAP_META) { + ret = erofs_fscache_readpage_inline(page, &map); + goto out_unlock; + } + mdev = (struct erofs_map_dev) { .m_deviceid = map.m_deviceid, .m_pa = map.m_pa,