diff options
author | Gao Xiang <gaoxiang25@huawei.com> | 2019-09-03 22:08:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-05 14:10:07 -0400 |
commit | 8a76568225deae18cea1d1a21c2bade2f2ced2ba (patch) | |
tree | 1156c41d308d2a292b6c7ed5aa0fe916b10ec495 | |
parent | 426a930891cf17c5c16f12e8e2c8cb75c4cfff3c (diff) |
erofs: better naming for erofs inode related stuffs
updates inode naming
- kill is_inode_layout_compression [1]
- kill magic underscores [2] [3]
- better naming for datamode & data_mapping_mode [3]
- better naming erofs_inode_{compact, extended} [4]
[1] https://lore.kernel.org/r/20190829102426.GE20598@infradead.org/
[2] https://lore.kernel.org/r/20190829102426.GE20598@infradead.org/
[3] https://lore.kernel.org/r/20190902122627.GN15931@infradead.org/
[4] https://lore.kernel.org/r/20190902125438.GA17750@infradead.org/
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190904020912.63925-8-gaoxiang25@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/erofs/data.c | 9 | ||||
-rw-r--r-- | fs/erofs/erofs_fs.h | 24 | ||||
-rw-r--r-- | fs/erofs/inode.c | 126 | ||||
-rw-r--r-- | fs/erofs/internal.h | 31 | ||||
-rw-r--r-- | fs/erofs/super.c | 2 | ||||
-rw-r--r-- | fs/erofs/zmap.c | 6 |
6 files changed, 108 insertions, 90 deletions
diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 0983807737fd..4d9b07991d07 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c | |||
@@ -113,11 +113,12 @@ static int erofs_map_blocks_flatmode(struct inode *inode, | |||
113 | erofs_blk_t nblocks, lastblk; | 113 | erofs_blk_t nblocks, lastblk; |
114 | u64 offset = map->m_la; | 114 | u64 offset = map->m_la; |
115 | struct erofs_vnode *vi = EROFS_V(inode); | 115 | struct erofs_vnode *vi = EROFS_V(inode); |
116 | bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE); | ||
116 | 117 | ||
117 | trace_erofs_map_blocks_flatmode_enter(inode, map, flags); | 118 | trace_erofs_map_blocks_flatmode_enter(inode, map, flags); |
118 | 119 | ||
119 | nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); | 120 | nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); |
120 | lastblk = nblocks - is_inode_flat_inline(inode); | 121 | lastblk = nblocks - tailendpacking; |
121 | 122 | ||
122 | if (offset >= inode->i_size) { | 123 | if (offset >= inode->i_size) { |
123 | /* leave out-of-bound access unmapped */ | 124 | /* leave out-of-bound access unmapped */ |
@@ -132,7 +133,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode, | |||
132 | if (offset < blknr_to_addr(lastblk)) { | 133 | if (offset < blknr_to_addr(lastblk)) { |
133 | map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la; | 134 | map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la; |
134 | map->m_plen = blknr_to_addr(lastblk) - offset; | 135 | map->m_plen = blknr_to_addr(lastblk) - offset; |
135 | } else if (is_inode_flat_inline(inode)) { | 136 | } else if (tailendpacking) { |
136 | /* 2 - inode inline B: inode, [xattrs], inline last blk... */ | 137 | /* 2 - inode inline B: inode, [xattrs], inline last blk... */ |
137 | struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); | 138 | struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); |
138 | 139 | ||
@@ -169,7 +170,7 @@ err_out: | |||
169 | int erofs_map_blocks(struct inode *inode, | 170 | int erofs_map_blocks(struct inode *inode, |
170 | struct erofs_map_blocks *map, int flags) | 171 | struct erofs_map_blocks *map, int flags) |
171 | { | 172 | { |
172 | if (is_inode_layout_compression(inode)) { | 173 | if (erofs_inode_is_data_compressed(EROFS_V(inode)->datalayout)) { |
173 | int err = z_erofs_map_blocks_iter(inode, map, flags); | 174 | int err = z_erofs_map_blocks_iter(inode, map, flags); |
174 | 175 | ||
175 | if (map->mpage) { | 176 | if (map->mpage) { |
@@ -403,7 +404,7 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block) | |||
403 | { | 404 | { |
404 | struct inode *inode = mapping->host; | 405 | struct inode *inode = mapping->host; |
405 | 406 | ||
406 | if (is_inode_flat_inline(inode)) { | 407 | if (EROFS_V(inode)->datalayout == EROFS_INODE_FLAT_INLINE) { |
407 | erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE; | 408 | erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE; |
408 | 409 | ||
409 | if (block >> LOG_SECTORS_PER_BLOCK >= blks) | 410 | if (block >> LOG_SECTORS_PER_BLOCK >= blks) |
diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h index b2aef3bc377d..18689e916e94 100644 --- a/fs/erofs/erofs_fs.h +++ b/fs/erofs/erofs_fs.h | |||
@@ -41,7 +41,7 @@ struct erofs_super_block { | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * erofs inode data mapping: | 44 | * erofs inode datalayout: |
45 | * 0 - inode plain without inline data A: | 45 | * 0 - inode plain without inline data A: |
46 | * inode, [xattrs], ... | ... | no-holed data | 46 | * inode, [xattrs], ... | ... | no-holed data |
47 | * 1 - inode VLE compression B (legacy): | 47 | * 1 - inode VLE compression B (legacy): |
@@ -57,7 +57,7 @@ enum { | |||
57 | EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1, | 57 | EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1, |
58 | EROFS_INODE_FLAT_INLINE = 2, | 58 | EROFS_INODE_FLAT_INLINE = 2, |
59 | EROFS_INODE_FLAT_COMPRESSION = 3, | 59 | EROFS_INODE_FLAT_COMPRESSION = 3, |
60 | EROFS_INODE_LAYOUT_MAX | 60 | EROFS_INODE_DATALAYOUT_MAX |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static inline bool erofs_inode_is_data_compressed(unsigned int datamode) | 63 | static inline bool erofs_inode_is_data_compressed(unsigned int datamode) |
@@ -68,14 +68,14 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode) | |||
68 | 68 | ||
69 | /* bit definitions of inode i_advise */ | 69 | /* bit definitions of inode i_advise */ |
70 | #define EROFS_I_VERSION_BITS 1 | 70 | #define EROFS_I_VERSION_BITS 1 |
71 | #define EROFS_I_DATA_MAPPING_BITS 3 | 71 | #define EROFS_I_DATALAYOUT_BITS 3 |
72 | 72 | ||
73 | #define EROFS_I_VERSION_BIT 0 | 73 | #define EROFS_I_VERSION_BIT 0 |
74 | #define EROFS_I_DATA_MAPPING_BIT 1 | 74 | #define EROFS_I_DATALAYOUT_BIT 1 |
75 | 75 | ||
76 | /* 32-byte reduced form of an ondisk inode */ | 76 | /* 32-byte reduced form of an ondisk inode */ |
77 | struct erofs_inode_v1 { | 77 | struct erofs_inode_compact { |
78 | __le16 i_advise; /* inode hints */ | 78 | __le16 i_format; /* inode format hints */ |
79 | 79 | ||
80 | /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ | 80 | /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ |
81 | __le16 i_xattr_icount; | 81 | __le16 i_xattr_icount; |
@@ -98,13 +98,13 @@ struct erofs_inode_v1 { | |||
98 | }; | 98 | }; |
99 | 99 | ||
100 | /* 32 bytes on-disk inode */ | 100 | /* 32 bytes on-disk inode */ |
101 | #define EROFS_INODE_LAYOUT_V1 0 | 101 | #define EROFS_INODE_LAYOUT_COMPACT 0 |
102 | /* 64 bytes on-disk inode */ | 102 | /* 64 bytes on-disk inode */ |
103 | #define EROFS_INODE_LAYOUT_V2 1 | 103 | #define EROFS_INODE_LAYOUT_EXTENDED 1 |
104 | 104 | ||
105 | /* 64-byte complete form of an ondisk inode */ | 105 | /* 64-byte complete form of an ondisk inode */ |
106 | struct erofs_inode_v2 { | 106 | struct erofs_inode_extended { |
107 | __le16 i_advise; /* inode hints */ | 107 | __le16 i_format; /* inode format hints */ |
108 | 108 | ||
109 | /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ | 109 | /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ |
110 | __le16 i_xattr_icount; | 110 | __le16 i_xattr_icount; |
@@ -299,8 +299,8 @@ struct erofs_dirent { | |||
299 | static inline void erofs_check_ondisk_layout_definitions(void) | 299 | static inline void erofs_check_ondisk_layout_definitions(void) |
300 | { | 300 | { |
301 | BUILD_BUG_ON(sizeof(struct erofs_super_block) != 128); | 301 | BUILD_BUG_ON(sizeof(struct erofs_super_block) != 128); |
302 | BUILD_BUG_ON(sizeof(struct erofs_inode_v1) != 32); | 302 | BUILD_BUG_ON(sizeof(struct erofs_inode_compact) != 32); |
303 | BUILD_BUG_ON(sizeof(struct erofs_inode_v2) != 64); | 303 | BUILD_BUG_ON(sizeof(struct erofs_inode_extended) != 64); |
304 | BUILD_BUG_ON(sizeof(struct erofs_xattr_ibody_header) != 12); | 304 | BUILD_BUG_ON(sizeof(struct erofs_xattr_ibody_header) != 12); |
305 | BUILD_BUG_ON(sizeof(struct erofs_xattr_entry) != 4); | 305 | BUILD_BUG_ON(sizeof(struct erofs_xattr_entry) != 4); |
306 | BUILD_BUG_ON(sizeof(struct z_erofs_map_header) != 8); | 306 | BUILD_BUG_ON(sizeof(struct z_erofs_map_header) != 8); |
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 3fc4f764b387..494b35e5830a 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c | |||
@@ -12,73 +12,90 @@ | |||
12 | static int read_inode(struct inode *inode, void *data) | 12 | static int read_inode(struct inode *inode, void *data) |
13 | { | 13 | { |
14 | struct erofs_vnode *vi = EROFS_V(inode); | 14 | struct erofs_vnode *vi = EROFS_V(inode); |
15 | struct erofs_inode_v1 *v1 = data; | 15 | struct erofs_inode_compact *dic = data; |
16 | const unsigned int advise = le16_to_cpu(v1->i_advise); | 16 | struct erofs_inode_extended *die; |
17 | |||
18 | const unsigned int ifmt = le16_to_cpu(dic->i_format); | ||
19 | struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); | ||
17 | erofs_blk_t nblks = 0; | 20 | erofs_blk_t nblks = 0; |
18 | 21 | ||
19 | vi->datamode = __inode_data_mapping(advise); | 22 | vi->datalayout = erofs_inode_datalayout(ifmt); |
20 | 23 | ||
21 | if (vi->datamode >= EROFS_INODE_LAYOUT_MAX) { | 24 | if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) { |
22 | errln("unsupported data mapping %u of nid %llu", | 25 | errln("unsupported datalayout %u of nid %llu", |
23 | vi->datamode, vi->nid); | 26 | vi->datalayout, vi->nid); |
24 | DBG_BUGON(1); | 27 | DBG_BUGON(1); |
25 | return -EOPNOTSUPP; | 28 | return -EOPNOTSUPP; |
26 | } | 29 | } |
27 | 30 | ||
28 | if (__inode_version(advise) == EROFS_INODE_LAYOUT_V2) { | 31 | switch (erofs_inode_version(ifmt)) { |
29 | struct erofs_inode_v2 *v2 = data; | 32 | case EROFS_INODE_LAYOUT_EXTENDED: |
33 | die = data; | ||
30 | 34 | ||
31 | vi->inode_isize = sizeof(struct erofs_inode_v2); | 35 | vi->inode_isize = sizeof(struct erofs_inode_extended); |
32 | vi->xattr_isize = erofs_xattr_ibody_size(v2->i_xattr_icount); | 36 | vi->xattr_isize = erofs_xattr_ibody_size(die->i_xattr_icount); |
33 | 37 | ||
34 | inode->i_mode = le16_to_cpu(v2->i_mode); | 38 | inode->i_mode = le16_to_cpu(die->i_mode); |
35 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 39 | switch (inode->i_mode & S_IFMT) { |
36 | S_ISLNK(inode->i_mode)) | 40 | case S_IFREG: |
37 | vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr); | 41 | case S_IFDIR: |
38 | else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) | 42 | case S_IFLNK: |
43 | vi->raw_blkaddr = le32_to_cpu(die->i_u.raw_blkaddr); | ||
44 | break; | ||
45 | case S_IFCHR: | ||
46 | case S_IFBLK: | ||
39 | inode->i_rdev = | 47 | inode->i_rdev = |
40 | new_decode_dev(le32_to_cpu(v2->i_u.rdev)); | 48 | new_decode_dev(le32_to_cpu(die->i_u.rdev)); |
41 | else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) | 49 | break; |
50 | case S_IFIFO: | ||
51 | case S_IFSOCK: | ||
42 | inode->i_rdev = 0; | 52 | inode->i_rdev = 0; |
43 | else | 53 | break; |
54 | default: | ||
44 | goto bogusimode; | 55 | goto bogusimode; |
45 | 56 | } | |
46 | i_uid_write(inode, le32_to_cpu(v2->i_uid)); | 57 | i_uid_write(inode, le32_to_cpu(die->i_uid)); |
47 | i_gid_write(inode, le32_to_cpu(v2->i_gid)); | 58 | i_gid_write(inode, le32_to_cpu(die->i_gid)); |
48 | set_nlink(inode, le32_to_cpu(v2->i_nlink)); | 59 | set_nlink(inode, le32_to_cpu(die->i_nlink)); |
49 | 60 | ||
50 | /* ns timestamp */ | 61 | /* ns timestamp */ |
51 | inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = | 62 | inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = |
52 | le64_to_cpu(v2->i_ctime); | 63 | le64_to_cpu(die->i_ctime); |
53 | inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = | 64 | inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = |
54 | le32_to_cpu(v2->i_ctime_nsec); | 65 | le32_to_cpu(die->i_ctime_nsec); |
55 | 66 | ||
56 | inode->i_size = le64_to_cpu(v2->i_size); | 67 | inode->i_size = le64_to_cpu(die->i_size); |
57 | 68 | ||
58 | /* total blocks for compressed files */ | 69 | /* total blocks for compressed files */ |
59 | if (is_inode_layout_compression(inode)) | 70 | if (erofs_inode_is_data_compressed(vi->datalayout)) |
60 | nblks = le32_to_cpu(v2->i_u.compressed_blocks); | 71 | nblks = le32_to_cpu(die->i_u.compressed_blocks); |
61 | } else if (__inode_version(advise) == EROFS_INODE_LAYOUT_V1) { | 72 | break; |
62 | struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); | 73 | case EROFS_INODE_LAYOUT_COMPACT: |
63 | 74 | vi->inode_isize = sizeof(struct erofs_inode_compact); | |
64 | vi->inode_isize = sizeof(struct erofs_inode_v1); | 75 | vi->xattr_isize = erofs_xattr_ibody_size(dic->i_xattr_icount); |
65 | vi->xattr_isize = erofs_xattr_ibody_size(v1->i_xattr_icount); | 76 | |
66 | 77 | inode->i_mode = le16_to_cpu(dic->i_mode); | |
67 | inode->i_mode = le16_to_cpu(v1->i_mode); | 78 | switch (inode->i_mode & S_IFMT) { |
68 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 79 | case S_IFREG: |
69 | S_ISLNK(inode->i_mode)) | 80 | case S_IFDIR: |
70 | vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr); | 81 | case S_IFLNK: |
71 | else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) | 82 | vi->raw_blkaddr = le32_to_cpu(dic->i_u.raw_blkaddr); |
83 | break; | ||
84 | case S_IFCHR: | ||
85 | case S_IFBLK: | ||
72 | inode->i_rdev = | 86 | inode->i_rdev = |
73 | new_decode_dev(le32_to_cpu(v1->i_u.rdev)); | 87 | new_decode_dev(le32_to_cpu(dic->i_u.rdev)); |
74 | else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) | 88 | break; |
89 | case S_IFIFO: | ||
90 | case S_IFSOCK: | ||
75 | inode->i_rdev = 0; | 91 | inode->i_rdev = 0; |
76 | else | 92 | break; |
93 | default: | ||
77 | goto bogusimode; | 94 | goto bogusimode; |
78 | 95 | } | |
79 | i_uid_write(inode, le16_to_cpu(v1->i_uid)); | 96 | i_uid_write(inode, le16_to_cpu(dic->i_uid)); |
80 | i_gid_write(inode, le16_to_cpu(v1->i_gid)); | 97 | i_gid_write(inode, le16_to_cpu(dic->i_gid)); |
81 | set_nlink(inode, le16_to_cpu(v1->i_nlink)); | 98 | set_nlink(inode, le16_to_cpu(dic->i_nlink)); |
82 | 99 | ||
83 | /* use build time to derive all file time */ | 100 | /* use build time to derive all file time */ |
84 | inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = | 101 | inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = |
@@ -86,12 +103,13 @@ static int read_inode(struct inode *inode, void *data) | |||
86 | inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = | 103 | inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = |
87 | sbi->build_time_nsec; | 104 | sbi->build_time_nsec; |
88 | 105 | ||
89 | inode->i_size = le32_to_cpu(v1->i_size); | 106 | inode->i_size = le32_to_cpu(dic->i_size); |
90 | if (is_inode_layout_compression(inode)) | 107 | if (erofs_inode_is_data_compressed(vi->datalayout)) |
91 | nblks = le32_to_cpu(v1->i_u.compressed_blocks); | 108 | nblks = le32_to_cpu(dic->i_u.compressed_blocks); |
92 | } else { | 109 | break; |
110 | default: | ||
93 | errln("unsupported on-disk inode version %u of nid %llu", | 111 | errln("unsupported on-disk inode version %u of nid %llu", |
94 | __inode_version(advise), vi->nid); | 112 | erofs_inode_version(ifmt), vi->nid); |
95 | DBG_BUGON(1); | 113 | DBG_BUGON(1); |
96 | return -EOPNOTSUPP; | 114 | return -EOPNOTSUPP; |
97 | } | 115 | } |
@@ -125,8 +143,8 @@ static int fill_inline_data(struct inode *inode, void *data, | |||
125 | struct erofs_vnode *vi = EROFS_V(inode); | 143 | struct erofs_vnode *vi = EROFS_V(inode); |
126 | struct erofs_sb_info *sbi = EROFS_I_SB(inode); | 144 | struct erofs_sb_info *sbi = EROFS_I_SB(inode); |
127 | 145 | ||
128 | /* should be inode inline C */ | 146 | /* should be tail-packing data inline */ |
129 | if (!is_inode_flat_inline(inode)) | 147 | if (vi->datalayout != EROFS_INODE_FLAT_INLINE) |
130 | return 0; | 148 | return 0; |
131 | 149 | ||
132 | /* fast symlink (following ext4) */ | 150 | /* fast symlink (following ext4) */ |
@@ -216,7 +234,7 @@ static int fill_inode(struct inode *inode, int isdir) | |||
216 | goto out_unlock; | 234 | goto out_unlock; |
217 | } | 235 | } |
218 | 236 | ||
219 | if (is_inode_layout_compression(inode)) { | 237 | if (erofs_inode_is_data_compressed(vi->datalayout)) { |
220 | err = z_erofs_fill_inode(inode); | 238 | err = z_erofs_fill_inode(inode); |
221 | goto out_unlock; | 239 | goto out_unlock; |
222 | } | 240 | } |
@@ -299,7 +317,7 @@ int erofs_getattr(const struct path *path, struct kstat *stat, | |||
299 | { | 317 | { |
300 | struct inode *const inode = d_inode(path->dentry); | 318 | struct inode *const inode = d_inode(path->dentry); |
301 | 319 | ||
302 | if (is_inode_layout_compression(inode)) | 320 | if (erofs_inode_is_data_compressed(EROFS_V(inode)->datalayout)) |
303 | stat->attributes |= STATX_ATTR_COMPRESSED; | 321 | stat->attributes |= STATX_ATTR_COMPRESSED; |
304 | 322 | ||
305 | stat->attributes |= STATX_ATTR_IMMUTABLE; | 323 | stat->attributes |= STATX_ATTR_IMMUTABLE; |
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 7ff36f404ec3..0f5cbf0a7570 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h | |||
@@ -285,7 +285,7 @@ struct erofs_vnode { | |||
285 | /* atomic flags (including bitlocks) */ | 285 | /* atomic flags (including bitlocks) */ |
286 | unsigned long flags; | 286 | unsigned long flags; |
287 | 287 | ||
288 | unsigned char datamode; | 288 | unsigned char datalayout; |
289 | unsigned char inode_isize; | 289 | unsigned char inode_isize; |
290 | unsigned short xattr_isize; | 290 | unsigned short xattr_isize; |
291 | 291 | ||
@@ -310,31 +310,30 @@ struct erofs_vnode { | |||
310 | #define EROFS_V(ptr) \ | 310 | #define EROFS_V(ptr) \ |
311 | container_of(ptr, struct erofs_vnode, vfs_inode) | 311 | container_of(ptr, struct erofs_vnode, vfs_inode) |
312 | 312 | ||
313 | #define __inode_advise(x, bit, bits) \ | ||
314 | (((x) >> (bit)) & ((1 << (bits)) - 1)) | ||
315 | |||
316 | #define __inode_version(advise) \ | ||
317 | __inode_advise(advise, EROFS_I_VERSION_BIT, \ | ||
318 | EROFS_I_VERSION_BITS) | ||
319 | |||
320 | #define __inode_data_mapping(advise) \ | ||
321 | __inode_advise(advise, EROFS_I_DATA_MAPPING_BIT,\ | ||
322 | EROFS_I_DATA_MAPPING_BITS) | ||
323 | |||
324 | static inline unsigned long inode_datablocks(struct inode *inode) | 313 | static inline unsigned long inode_datablocks(struct inode *inode) |
325 | { | 314 | { |
326 | /* since i_size cannot be changed */ | 315 | /* since i_size cannot be changed */ |
327 | return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); | 316 | return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); |
328 | } | 317 | } |
329 | 318 | ||
330 | static inline bool is_inode_layout_compression(struct inode *inode) | 319 | static inline unsigned int erofs_bitrange(unsigned int value, unsigned int bit, |
320 | unsigned int bits) | ||
321 | { | ||
322 | |||
323 | return (value >> bit) & ((1 << bits) - 1); | ||
324 | } | ||
325 | |||
326 | |||
327 | static inline unsigned int erofs_inode_version(unsigned int value) | ||
331 | { | 328 | { |
332 | return erofs_inode_is_data_compressed(EROFS_V(inode)->datamode); | 329 | return erofs_bitrange(value, EROFS_I_VERSION_BIT, |
330 | EROFS_I_VERSION_BITS); | ||
333 | } | 331 | } |
334 | 332 | ||
335 | static inline bool is_inode_flat_inline(struct inode *inode) | 333 | static inline unsigned int erofs_inode_datalayout(unsigned int value) |
336 | { | 334 | { |
337 | return EROFS_V(inode)->datamode == EROFS_INODE_FLAT_INLINE; | 335 | return erofs_bitrange(value, EROFS_I_DATALAYOUT_BIT, |
336 | EROFS_I_DATALAYOUT_BITS); | ||
338 | } | 337 | } |
339 | 338 | ||
340 | extern const struct super_operations erofs_sops; | 339 | extern const struct super_operations erofs_sops; |
diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 6a7ab194783c..8d9f38d56b3b 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c | |||
@@ -121,7 +121,7 @@ static int superblock_read(struct super_block *sb) | |||
121 | #ifdef CONFIG_EROFS_FS_XATTR | 121 | #ifdef CONFIG_EROFS_FS_XATTR |
122 | sbi->xattr_blkaddr = le32_to_cpu(layout->xattr_blkaddr); | 122 | sbi->xattr_blkaddr = le32_to_cpu(layout->xattr_blkaddr); |
123 | #endif | 123 | #endif |
124 | sbi->islotbits = ffs(sizeof(struct erofs_inode_v1)) - 1; | 124 | sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact)); |
125 | sbi->root_nid = le16_to_cpu(layout->root_nid); | 125 | sbi->root_nid = le16_to_cpu(layout->root_nid); |
126 | sbi->inos = le64_to_cpu(layout->inos); | 126 | sbi->inos = le64_to_cpu(layout->inos); |
127 | 127 | ||
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 850e0e3d57a8..6a06fb80ef3f 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c | |||
@@ -12,7 +12,7 @@ int z_erofs_fill_inode(struct inode *inode) | |||
12 | { | 12 | { |
13 | struct erofs_vnode *const vi = EROFS_V(inode); | 13 | struct erofs_vnode *const vi = EROFS_V(inode); |
14 | 14 | ||
15 | if (vi->datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY) { | 15 | if (vi->datalayout == EROFS_INODE_FLAT_COMPRESSION_LEGACY) { |
16 | vi->z_advise = 0; | 16 | vi->z_advise = 0; |
17 | vi->z_algorithmtype[0] = 0; | 17 | vi->z_algorithmtype[0] = 0; |
18 | vi->z_algorithmtype[1] = 0; | 18 | vi->z_algorithmtype[1] = 0; |
@@ -46,7 +46,7 @@ static int fill_inode_lazy(struct inode *inode) | |||
46 | if (test_bit(EROFS_V_Z_INITED_BIT, &vi->flags)) | 46 | if (test_bit(EROFS_V_Z_INITED_BIT, &vi->flags)) |
47 | goto out_unlock; | 47 | goto out_unlock; |
48 | 48 | ||
49 | DBG_BUGON(vi->datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY); | 49 | DBG_BUGON(vi->datalayout == EROFS_INODE_FLAT_COMPRESSION_LEGACY); |
50 | 50 | ||
51 | pos = ALIGN(iloc(EROFS_SB(sb), vi->nid) + vi->inode_isize + | 51 | pos = ALIGN(iloc(EROFS_SB(sb), vi->nid) + vi->inode_isize + |
52 | vi->xattr_isize, 8); | 52 | vi->xattr_isize, 8); |
@@ -314,7 +314,7 @@ out: | |||
314 | static int vle_load_cluster_from_disk(struct z_erofs_maprecorder *m, | 314 | static int vle_load_cluster_from_disk(struct z_erofs_maprecorder *m, |
315 | unsigned int lcn) | 315 | unsigned int lcn) |
316 | { | 316 | { |
317 | const unsigned int datamode = EROFS_V(m->inode)->datamode; | 317 | const unsigned int datamode = EROFS_V(m->inode)->datalayout; |
318 | 318 | ||
319 | if (datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY) | 319 | if (datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY) |
320 | return vle_legacy_load_cluster_from_disk(m, lcn); | 320 | return vle_legacy_load_cluster_from_disk(m, lcn); |