[PATCH 1/3] erofs-utils: lib: use erofs_map_blocks() for all datalayouts
Gao Xiang
hsiangkao at linux.alibaba.com
Fri Jan 17 18:46:00 AEDT 2025
It simplifies the codebase a bit.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
dump/main.c | 11 +----------
fsck/main.c | 23 ++---------------------
lib/data.c | 12 ++++++++++--
3 files changed, 13 insertions(+), 33 deletions(-)
diff --git a/dump/main.c b/dump/main.c
index 860ee5a..44f65da 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -359,14 +359,6 @@ static int erofsdump_readdir(struct erofs_dir_context *ctx)
return 0;
}
-static int erofsdump_map_blocks(struct erofs_inode *inode,
- struct erofs_map_blocks *map, int flags)
-{
- if (erofs_inode_is_data_compressed(inode->datalayout))
- return z_erofs_map_blocks_iter(inode, map, flags);
- return erofs_map_blocks(inode, map, flags);
-}
-
static void erofsdump_show_fileinfo(bool show_extent)
{
const char *ext_fmt[] = {
@@ -461,8 +453,7 @@ static void erofsdump_show_fileinfo(bool show_extent)
while (map.m_la < inode.i_size) {
struct erofs_map_dev mdev;
- err = erofsdump_map_blocks(&inode, &map,
- EROFS_GET_BLOCKS_FIEMAP);
+ err = erofs_map_blocks(&inode, &map, EROFS_GET_BLOCKS_FIEMAP);
if (err) {
erofs_err("failed to get file blocks range");
return;
diff --git a/fsck/main.c b/fsck/main.c
index f20b767..f56a812 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -527,31 +527,12 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
erofs_dbg("verify data chunk of nid(%llu): type(%d)",
inode->nid | 0ULL, inode->datalayout);
- switch (inode->datalayout) {
- case EROFS_INODE_FLAT_PLAIN:
- case EROFS_INODE_FLAT_INLINE:
- case EROFS_INODE_CHUNK_BASED:
- compressed = false;
- break;
- case EROFS_INODE_COMPRESSED_FULL:
- case EROFS_INODE_COMPRESSED_COMPACT:
- compressed = true;
- break;
- default:
- erofs_err("unknown datalayout");
- return -EINVAL;
- }
-
+ compressed = erofs_inode_is_data_compressed(inode->datalayout);
while (pos < inode->i_size) {
unsigned int alloc_rawsize;
map.m_la = pos;
- if (compressed)
- ret = z_erofs_map_blocks_iter(inode, &map,
- EROFS_GET_BLOCKS_FIEMAP);
- else
- ret = erofs_map_blocks(inode, &map,
- EROFS_GET_BLOCKS_FIEMAP);
+ ret = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_FIEMAP);
if (ret)
goto out;
diff --git a/lib/data.c b/lib/data.c
index f37f8f0..8033208 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -62,8 +62,8 @@ err_out:
return err;
}
-int erofs_map_blocks(struct erofs_inode *inode,
- struct erofs_map_blocks *map, int flags)
+int __erofs_map_blocks(struct erofs_inode *inode,
+ struct erofs_map_blocks *map, int flags)
{
struct erofs_inode *vi = inode;
struct erofs_sb_info *sbi = inode->sbi;
@@ -132,6 +132,14 @@ out:
return err;
}
+int erofs_map_blocks(struct erofs_inode *inode,
+ struct erofs_map_blocks *map, int flags)
+{
+ if (erofs_inode_is_data_compressed(inode->datalayout))
+ return z_erofs_map_blocks_iter(inode, map, flags);
+ return __erofs_map_blocks(inode, map, flags);
+}
+
int erofs_map_dev(struct erofs_sb_info *sbi, struct erofs_map_dev *map)
{
struct erofs_device_info *dif;
--
2.43.5
More information about the Linux-erofs
mailing list