Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hsiangkao:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
affggh authored Jul 21, 2023
2 parents 9528f36 + fe6de7d commit 91ef5e6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion fsck/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)
}
}

addr = iloc(inode->nid) + inode->inode_isize;
addr = erofs_iloc(inode) + inode->inode_isize;
ret = dev_read(0, buf, addr, xattr_hdr_size);
if (ret < 0) {
erofs_err("failed to read xattr header @ nid %llu: %d",
Expand Down
10 changes: 5 additions & 5 deletions include/erofs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ struct erofs_sb_info {
/* make sure that any user of the erofs headers has atleast 64bit off_t type */
extern int erofs_assert_largefile[sizeof(off_t)-8];

static inline erofs_off_t iloc(erofs_nid_t nid)
{
return erofs_pos(sbi.meta_blkaddr) + (nid << sbi.islotbits);
}

#define EROFS_FEATURE_FUNCS(name, compat, feature) \
static inline bool erofs_sb_has_##name(void) \
{ \
Expand Down Expand Up @@ -219,6 +214,11 @@ struct erofs_inode {
unsigned int fragment_size;
};

static inline erofs_off_t erofs_iloc(struct erofs_inode *inode)
{
return erofs_pos(sbi.meta_blkaddr) + (inode->nid << sbi.islotbits);
}

static inline bool is_inode_layout_compression(struct erofs_inode *inode)
{
return erofs_inode_is_data_compressed(inode->datalayout);
Expand Down
4 changes: 2 additions & 2 deletions lib/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,
map->m_plen = erofs_pos(lastblk) - offset;
} else if (tailendpacking) {
/* 2 - inode inline B: inode, [xattrs], inline last blk... */
map->m_pa = iloc(vi->nid) + vi->inode_isize +
map->m_pa = erofs_iloc(vi) + vi->inode_isize +
vi->xattr_isize + erofs_blkoff(map->m_la);
map->m_plen = inode->i_size - offset;

Expand Down Expand Up @@ -89,7 +89,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
unit = EROFS_BLOCK_MAP_ENTRY_SIZE; /* block map */

chunknr = map->m_la >> vi->u.chunkbits;
pos = roundup(iloc(vi->nid) + vi->inode_isize +
pos = roundup(erofs_iloc(vi) + vi->inode_isize +
vi->xattr_isize, unit) + unit * chunknr;

err = blk_read(0, buf, erofs_blknr(pos), 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
char buf[sizeof(struct erofs_inode_extended)];
struct erofs_inode_compact *dic;
struct erofs_inode_extended *die;
const erofs_off_t inode_loc = iloc(vi->nid);
const erofs_off_t inode_loc = erofs_iloc(vi);

ret = dev_read(0, buf, inode_loc, sizeof(*dic));
if (ret < 0)
Expand Down
8 changes: 4 additions & 4 deletions lib/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ static int init_inode_xattrs(struct erofs_inode *vi)
return -ENOATTR;
}

it.blkaddr = erofs_blknr(iloc(vi->nid) + vi->inode_isize);
it.ofs = erofs_blkoff(iloc(vi->nid) + vi->inode_isize);
it.blkaddr = erofs_blknr(erofs_iloc(vi) + vi->inode_isize);
it.ofs = erofs_blkoff(erofs_iloc(vi) + vi->inode_isize);

ret = blk_read(0, it.page, it.blkaddr, 1);
if (ret < 0)
Expand Down Expand Up @@ -962,8 +962,8 @@ static int inline_xattr_iter_pre(struct xattr_iter *it,

inline_xattr_ofs = vi->inode_isize + xattr_header_sz;

it->blkaddr = erofs_blknr(iloc(vi->nid) + inline_xattr_ofs);
it->ofs = erofs_blkoff(iloc(vi->nid) + inline_xattr_ofs);
it->blkaddr = erofs_blknr(erofs_iloc(vi) + inline_xattr_ofs);
it->ofs = erofs_blkoff(erofs_iloc(vi) + inline_xattr_ofs);

ret = blk_read(0, it->page, it->blkaddr, 1);
if (ret < 0)
Expand Down
6 changes: 3 additions & 3 deletions lib/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi)
if (vi->flags & EROFS_I_Z_INITED)
return 0;

pos = round_up(iloc(vi->nid) + vi->inode_isize + vi->xattr_isize, 8);
pos = round_up(erofs_iloc(vi) + vi->inode_isize + vi->xattr_isize, 8);
ret = dev_read(0, buf, pos, sizeof(buf));
if (ret < 0)
return -EIO;
Expand Down Expand Up @@ -143,7 +143,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
unsigned long lcn)
{
struct erofs_inode *const vi = m->inode;
const erofs_off_t ibase = iloc(vi->nid);
const erofs_off_t ibase = erofs_iloc(vi);
const erofs_off_t pos = Z_EROFS_FULL_INDEX_ALIGN(ibase +
vi->inode_isize + vi->xattr_isize) +
lcn * sizeof(struct z_erofs_lcluster_index);
Expand Down Expand Up @@ -342,7 +342,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
{
struct erofs_inode *const vi = m->inode;
const unsigned int lclusterbits = vi->z_logical_clusterbits;
const erofs_off_t ebase = round_up(iloc(vi->nid) + vi->inode_isize +
const erofs_off_t ebase = round_up(erofs_iloc(vi) + vi->inode_isize +
vi->xattr_isize, 8) +
sizeof(struct z_erofs_map_header);
const unsigned int totalidx = BLK_ROUND_UP(vi->i_size);
Expand Down

0 comments on commit 91ef5e6

Please sign in to comment.