Skip to content

Commit

Permalink
erofs: get rid of kaddr in struct z_erofs_maprecorder
Browse files Browse the repository at this point in the history
`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]
  • Loading branch information
hsiangkao committed Oct 11, 2024
1 parent 2402082 commit ae54567
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions fs/erofs/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
struct z_erofs_maprecorder {
struct inode *inode;
struct erofs_map_blocks *map;
void *kaddr;

unsigned long lcn;
/* compression extent information gathered */
u8 type, headtype;
Expand All @@ -33,14 +31,11 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
struct z_erofs_lcluster_index *di;
unsigned int advise;

m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
pos, EROFS_KMAP);
if (IS_ERR(m->kaddr))
return PTR_ERR(m->kaddr);

m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, EROFS_KMAP);
if (IS_ERR(di))
return PTR_ERR(di);
m->lcn = lcn;
di = m->kaddr;
m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);

advise = le16_to_cpu(di->di_advise);
m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK;
Expand All @@ -53,8 +48,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
DBG_BUGON(1);
return -EFSCORRUPTED;
}
m->compressedblks = m->delta[0] &
~Z_EROFS_LI_D0_CBLKCNT;
m->compressedblks = m->delta[0] & ~Z_EROFS_LI_D0_CBLKCNT;
m->delta[0] = 1;
}
m->delta[1] = le16_to_cpu(di->di_u.delta[1]);
Expand Down Expand Up @@ -110,9 +104,9 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
struct erofs_inode *const vi = EROFS_I(m->inode);
const unsigned int lclusterbits = vi->z_logical_clusterbits;
unsigned int vcnt, lo, lobits, encodebits, nblk, bytes;
int i;
u8 *in, type;
bool big_pcluster;
u8 *in, type;
int i;

if (1 << amortizedshift == 4 && lclusterbits <= 14)
vcnt = 2;
Expand All @@ -121,16 +115,18 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
else
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(..) */
m->nextpackoff = round_down(pos, vcnt << amortizedshift) +
(vcnt << amortizedshift);
big_pcluster = vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1;
lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U);
encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt;
bytes = pos & ((vcnt << amortizedshift) - 1);

in = m->kaddr - bytes;

in -= bytes;
i = bytes >> amortizedshift;

lo = decode_compactedbits(lobits, in, encodebits * i, &type);
Expand Down Expand Up @@ -255,10 +251,6 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
amortizedshift = 2;
out:
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);
}

Expand Down

0 comments on commit ae54567

Please sign in to comment.