erofs-utils: lib: use erofs_map_blocks() for all datalayouts
authorGao Xiang <hsiangkao@linux.alibaba.com>
Fri, 17 Jan 2025 07:46:00 +0000 (15:46 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 21 Jan 2025 14:18:39 +0000 (22:18 +0800)
It simplifies the codebase a bit.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250117074602.2223094-1-hsiangkao@linux.alibaba.com
dump/main.c
fsck/main.c
lib/data.c

index 860ee5a2742e89e0bc76baafd14d9ce366dc0d69..44f65dabda74b93f90625b66ee6dc3e54c1f2dd3 100644 (file)
@@ -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;
index f20b767ccf335801fc48758511c79206ef7d9c88..f56a8122baeee7c343eb064f665b587604622e10 100644 (file)
@@ -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;
 
index f37f8f0907c9ecbf073b081d17daf95fa9940962..80332081fcee12e1e0b0d756c308c27916ee42e5 100644 (file)
@@ -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;