Skip to content

Commit ae54567

Browse files
committed
erofs: get rid of kaddr in struct z_erofs_maprecorder
`kaddr` becomes useless after switching to metabuf. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2402082 commit ae54567

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

fs/erofs/zmap.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
struct z_erofs_maprecorder {
1111
struct inode *inode;
1212
struct erofs_map_blocks *map;
13-
void *kaddr;
14-
1513
unsigned long lcn;
1614
/* compression extent information gathered */
1715
u8 type, headtype;
@@ -33,14 +31,11 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
3331
struct z_erofs_lcluster_index *di;
3432
unsigned int advise;
3533

36-
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
37-
pos, EROFS_KMAP);
38-
if (IS_ERR(m->kaddr))
39-
return PTR_ERR(m->kaddr);
40-
41-
m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
34+
di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, EROFS_KMAP);
35+
if (IS_ERR(di))
36+
return PTR_ERR(di);
4237
m->lcn = lcn;
43-
di = m->kaddr;
38+
m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
4439

4540
advise = le16_to_cpu(di->di_advise);
4641
m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK;
@@ -53,8 +48,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
5348
DBG_BUGON(1);
5449
return -EFSCORRUPTED;
5550
}
56-
m->compressedblks = m->delta[0] &
57-
~Z_EROFS_LI_D0_CBLKCNT;
51+
m->compressedblks = m->delta[0] & ~Z_EROFS_LI_D0_CBLKCNT;
5852
m->delta[0] = 1;
5953
}
6054
m->delta[1] = le16_to_cpu(di->di_u.delta[1]);
@@ -110,9 +104,9 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
110104
struct erofs_inode *const vi = EROFS_I(m->inode);
111105
const unsigned int lclusterbits = vi->z_logical_clusterbits;
112106
unsigned int vcnt, lo, lobits, encodebits, nblk, bytes;
113-
int i;
114-
u8 *in, type;
115107
bool big_pcluster;
108+
u8 *in, type;
109+
int i;
116110

117111
if (1 << amortizedshift == 4 && lclusterbits <= 14)
118112
vcnt = 2;
@@ -121,16 +115,18 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
121115
else
122116
return -EOPNOTSUPP;
123117

118+
in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, EROFS_KMAP);
119+
if (IS_ERR(in))
120+
return PTR_ERR(in);
121+
124122
/* it doesn't equal to round_up(..) */
125123
m->nextpackoff = round_down(pos, vcnt << amortizedshift) +
126124
(vcnt << amortizedshift);
127125
big_pcluster = vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1;
128126
lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U);
129127
encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt;
130128
bytes = pos & ((vcnt << amortizedshift) - 1);
131-
132-
in = m->kaddr - bytes;
133-
129+
in -= bytes;
134130
i = bytes >> amortizedshift;
135131

136132
lo = decode_compactedbits(lobits, in, encodebits * i, &type);
@@ -255,10 +251,6 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
255251
amortizedshift = 2;
256252
out:
257253
pos += lcn * (1 << amortizedshift);
258-
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
259-
pos, EROFS_KMAP);
260-
if (IS_ERR(m->kaddr))
261-
return PTR_ERR(m->kaddr);
262254
return unpack_compacted_index(m, amortizedshift, pos, lookahead);
263255
}
264256

0 commit comments

Comments
 (0)