Commit 469407a3 authored by Gao Xiang's avatar Gao Xiang

erofs: clean up erofs_map_blocks tracepoints

Since the new type of chunk-based files is introduced, there is no
need to leave flatmode tracepoints.

Rename to erofs_map_blocks instead.

Link: https://lore.kernel.org/r/20211209012918.30337-1-hsiangkao@linux.alibaba.comReviewed-by: default avatarYue Hu <huyue2@yulong.com>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
parent 7acc3d1a
...@@ -26,20 +26,16 @@ static int erofs_map_blocks_flatmode(struct inode *inode, ...@@ -26,20 +26,16 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
struct erofs_map_blocks *map, struct erofs_map_blocks *map,
int flags) int flags)
{ {
int err = 0;
erofs_blk_t nblocks, lastblk; erofs_blk_t nblocks, lastblk;
u64 offset = map->m_la; u64 offset = map->m_la;
struct erofs_inode *vi = EROFS_I(inode); struct erofs_inode *vi = EROFS_I(inode);
bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE); bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
trace_erofs_map_blocks_flatmode_enter(inode, map, flags);
nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE);
lastblk = nblocks - tailendpacking; lastblk = nblocks - tailendpacking;
/* there is no hole in flatmode */ /* there is no hole in flatmode */
map->m_flags = EROFS_MAP_MAPPED; map->m_flags = EROFS_MAP_MAPPED;
if (offset < blknr_to_addr(lastblk)) { if (offset < blknr_to_addr(lastblk)) {
map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la; map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la;
map->m_plen = blknr_to_addr(lastblk) - offset; map->m_plen = blknr_to_addr(lastblk) - offset;
...@@ -51,30 +47,23 @@ static int erofs_map_blocks_flatmode(struct inode *inode, ...@@ -51,30 +47,23 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
vi->xattr_isize + erofs_blkoff(map->m_la); vi->xattr_isize + erofs_blkoff(map->m_la);
map->m_plen = inode->i_size - offset; map->m_plen = inode->i_size - offset;
/* inline data should be located in one meta block */ /* inline data should be located in the same meta block */
if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) { if (erofs_blkoff(map->m_pa) + map->m_plen > EROFS_BLKSIZ) {
erofs_err(inode->i_sb, erofs_err(inode->i_sb,
"inline data cross block boundary @ nid %llu", "inline data cross block boundary @ nid %llu",
vi->nid); vi->nid);
DBG_BUGON(1); DBG_BUGON(1);
err = -EFSCORRUPTED; return -EFSCORRUPTED;
goto err_out;
} }
map->m_flags |= EROFS_MAP_META; map->m_flags |= EROFS_MAP_META;
} else { } else {
erofs_err(inode->i_sb, erofs_err(inode->i_sb,
"internal error @ nid: %llu (size %llu), m_la 0x%llx", "internal error @ nid: %llu (size %llu), m_la 0x%llx",
vi->nid, inode->i_size, map->m_la); vi->nid, inode->i_size, map->m_la);
DBG_BUGON(1); DBG_BUGON(1);
err = -EIO; return -EIO;
goto err_out;
} }
return 0;
map->m_llen = map->m_plen;
err_out:
trace_erofs_map_blocks_flatmode_exit(inode, map, flags, 0);
return err;
} }
static int erofs_map_blocks(struct inode *inode, static int erofs_map_blocks(struct inode *inode,
...@@ -89,6 +78,7 @@ static int erofs_map_blocks(struct inode *inode, ...@@ -89,6 +78,7 @@ static int erofs_map_blocks(struct inode *inode,
erofs_off_t pos; erofs_off_t pos;
int err = 0; int err = 0;
trace_erofs_map_blocks_enter(inode, map, flags);
map->m_deviceid = 0; map->m_deviceid = 0;
if (map->m_la >= inode->i_size) { if (map->m_la >= inode->i_size) {
/* leave out-of-bound access unmapped */ /* leave out-of-bound access unmapped */
...@@ -97,8 +87,10 @@ static int erofs_map_blocks(struct inode *inode, ...@@ -97,8 +87,10 @@ static int erofs_map_blocks(struct inode *inode,
goto out; goto out;
} }
if (vi->datalayout != EROFS_INODE_CHUNK_BASED) if (vi->datalayout != EROFS_INODE_CHUNK_BASED) {
return erofs_map_blocks_flatmode(inode, map, flags); err = erofs_map_blocks_flatmode(inode, map, flags);
goto out;
}
if (vi->chunkformat & EROFS_CHUNK_FORMAT_INDEXES) if (vi->chunkformat & EROFS_CHUNK_FORMAT_INDEXES)
unit = sizeof(*idx); /* chunk index */ unit = sizeof(*idx); /* chunk index */
...@@ -110,9 +102,10 @@ static int erofs_map_blocks(struct inode *inode, ...@@ -110,9 +102,10 @@ static int erofs_map_blocks(struct inode *inode,
vi->xattr_isize, unit) + unit * chunknr; vi->xattr_isize, unit) + unit * chunknr;
page = erofs_get_meta_page(inode->i_sb, erofs_blknr(pos)); page = erofs_get_meta_page(inode->i_sb, erofs_blknr(pos));
if (IS_ERR(page)) if (IS_ERR(page)) {
return PTR_ERR(page); err = PTR_ERR(page);
goto out;
}
map->m_la = chunknr << vi->chunkbits; map->m_la = chunknr << vi->chunkbits;
map->m_plen = min_t(erofs_off_t, 1UL << vi->chunkbits, map->m_plen = min_t(erofs_off_t, 1UL << vi->chunkbits,
roundup(inode->i_size - map->m_la, EROFS_BLKSIZ)); roundup(inode->i_size - map->m_la, EROFS_BLKSIZ));
...@@ -146,7 +139,9 @@ static int erofs_map_blocks(struct inode *inode, ...@@ -146,7 +139,9 @@ static int erofs_map_blocks(struct inode *inode,
unlock_page(page); unlock_page(page);
put_page(page); put_page(page);
out: out:
map->m_llen = map->m_plen; if (!err)
map->m_llen = map->m_plen;
trace_erofs_map_blocks_exit(inode, map, flags, 0);
return err; return err;
} }
......
...@@ -169,7 +169,7 @@ DECLARE_EVENT_CLASS(erofs__map_blocks_enter, ...@@ -169,7 +169,7 @@ DECLARE_EVENT_CLASS(erofs__map_blocks_enter,
__entry->flags ? show_map_flags(__entry->flags) : "NULL") __entry->flags ? show_map_flags(__entry->flags) : "NULL")
); );
DEFINE_EVENT(erofs__map_blocks_enter, erofs_map_blocks_flatmode_enter, DEFINE_EVENT(erofs__map_blocks_enter, erofs_map_blocks_enter,
TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
unsigned flags), unsigned flags),
...@@ -221,7 +221,7 @@ DECLARE_EVENT_CLASS(erofs__map_blocks_exit, ...@@ -221,7 +221,7 @@ DECLARE_EVENT_CLASS(erofs__map_blocks_exit,
show_mflags(__entry->mflags), __entry->ret) show_mflags(__entry->mflags), __entry->ret)
); );
DEFINE_EVENT(erofs__map_blocks_exit, erofs_map_blocks_flatmode_exit, DEFINE_EVENT(erofs__map_blocks_exit, erofs_map_blocks_exit,
TP_PROTO(struct inode *inode, struct erofs_map_blocks *map, TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
unsigned flags, int ret), unsigned flags, int ret),
......
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