Commit ae54567e authored by Gao Xiang's avatar Gao Xiang

erofs: get rid of kaddr in `struct z_erofs_maprecorder`

`kaddr` becomes useless after switching to metabuf.
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241010235830.1535616-1-hsiangkao@linux.alibaba.com
parent 2402082e
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
struct z_erofs_maprecorder { struct z_erofs_maprecorder {
struct inode *inode; struct inode *inode;
struct erofs_map_blocks *map; struct erofs_map_blocks *map;
void *kaddr;
unsigned long lcn; unsigned long lcn;
/* compression extent information gathered */ /* compression extent information gathered */
u8 type, headtype; u8 type, headtype;
...@@ -33,14 +31,11 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, ...@@ -33,14 +31,11 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
struct z_erofs_lcluster_index *di; struct z_erofs_lcluster_index *di;
unsigned int advise; unsigned int advise;
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb, di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, EROFS_KMAP);
pos, EROFS_KMAP); if (IS_ERR(di))
if (IS_ERR(m->kaddr)) return PTR_ERR(di);
return PTR_ERR(m->kaddr);
m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
m->lcn = lcn; m->lcn = lcn;
di = m->kaddr; m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
advise = le16_to_cpu(di->di_advise); advise = le16_to_cpu(di->di_advise);
m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK; 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, ...@@ -53,8 +48,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
DBG_BUGON(1); DBG_BUGON(1);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
m->compressedblks = m->delta[0] & m->compressedblks = m->delta[0] & ~Z_EROFS_LI_D0_CBLKCNT;
~Z_EROFS_LI_D0_CBLKCNT;
m->delta[0] = 1; m->delta[0] = 1;
} }
m->delta[1] = le16_to_cpu(di->di_u.delta[1]); 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, ...@@ -110,9 +104,9 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
struct erofs_inode *const vi = EROFS_I(m->inode); struct erofs_inode *const vi = EROFS_I(m->inode);
const unsigned int lclusterbits = vi->z_logical_clusterbits; const unsigned int lclusterbits = vi->z_logical_clusterbits;
unsigned int vcnt, lo, lobits, encodebits, nblk, bytes; unsigned int vcnt, lo, lobits, encodebits, nblk, bytes;
int i;
u8 *in, type;
bool big_pcluster; bool big_pcluster;
u8 *in, type;
int i;
if (1 << amortizedshift == 4 && lclusterbits <= 14) if (1 << amortizedshift == 4 && lclusterbits <= 14)
vcnt = 2; vcnt = 2;
...@@ -121,6 +115,10 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m, ...@@ -121,6 +115,10 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
else else
return -EOPNOTSUPP; return -EOPNOTSUPP;
in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, EROFS_KMAP);
if (IS_ERR(in))
return PTR_ERR(in);
/* it doesn't equal to round_up(..) */ /* it doesn't equal to round_up(..) */
m->nextpackoff = round_down(pos, vcnt << amortizedshift) + m->nextpackoff = round_down(pos, vcnt << amortizedshift) +
(vcnt << amortizedshift); (vcnt << amortizedshift);
...@@ -128,9 +126,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m, ...@@ -128,9 +126,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U); lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U);
encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt; encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt;
bytes = pos & ((vcnt << amortizedshift) - 1); bytes = pos & ((vcnt << amortizedshift) - 1);
in -= bytes;
in = m->kaddr - bytes;
i = bytes >> amortizedshift; i = bytes >> amortizedshift;
lo = decode_compactedbits(lobits, in, encodebits * i, &type); lo = decode_compactedbits(lobits, in, encodebits * i, &type);
...@@ -255,10 +251,6 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m, ...@@ -255,10 +251,6 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
amortizedshift = 2; amortizedshift = 2;
out: out:
pos += lcn * (1 << amortizedshift); pos += lcn * (1 << amortizedshift);
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
pos, EROFS_KMAP);
if (IS_ERR(m->kaddr))
return PTR_ERR(m->kaddr);
return unpack_compacted_index(m, amortizedshift, pos, lookahead); return unpack_compacted_index(m, amortizedshift, pos, lookahead);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment