erofs: remove all likely/unlikely annotations

As Dan Carpenter suggested [1], I have to remove
all erofs likely/unlikely annotations.

[1] https://lore.kernel.org/linux-fsdevel/20190829154346.GK23584@kadam/
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190829163827.203274-1-gaoxiang25@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Gao Xiang 2019-08-30 00:38:27 +08:00 committed by Greg Kroah-Hartman
parent 5cf8967364
commit 8d8a09b093
12 changed files with 82 additions and 82 deletions

View File

@ -27,7 +27,7 @@ static inline void read_endio(struct bio *bio)
/* page is already locked */ /* page is already locked */
DBG_BUGON(PageUptodate(page)); DBG_BUGON(PageUptodate(page));
if (unlikely(err)) if (err)
SetPageError(page); SetPageError(page);
else else
SetPageUptodate(page); SetPageUptodate(page);
@ -53,7 +53,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
repeat: repeat:
page = find_or_create_page(mapping, blkaddr, gfp); page = find_or_create_page(mapping, blkaddr, gfp);
if (unlikely(!page)) { if (!page) {
DBG_BUGON(nofail); DBG_BUGON(nofail);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
@ -70,7 +70,7 @@ repeat:
} }
err = bio_add_page(bio, page, PAGE_SIZE, 0); err = bio_add_page(bio, page, PAGE_SIZE, 0);
if (unlikely(err != PAGE_SIZE)) { if (err != PAGE_SIZE) {
err = -EFAULT; err = -EFAULT;
goto err_out; goto err_out;
} }
@ -81,7 +81,7 @@ repeat:
lock_page(page); lock_page(page);
/* this page has been truncated by others */ /* this page has been truncated by others */
if (unlikely(page->mapping != mapping)) { if (page->mapping != mapping) {
unlock_repeat: unlock_repeat:
unlock_page(page); unlock_page(page);
put_page(page); put_page(page);
@ -89,7 +89,7 @@ unlock_repeat:
} }
/* more likely a read error */ /* more likely a read error */
if (unlikely(!PageUptodate(page))) { if (!PageUptodate(page)) {
if (io_retries) { if (io_retries) {
--io_retries; --io_retries;
goto unlock_repeat; goto unlock_repeat;
@ -120,7 +120,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE);
lastblk = nblocks - is_inode_flat_inline(inode); lastblk = nblocks - is_inode_flat_inline(inode);
if (unlikely(offset >= inode->i_size)) { if (offset >= inode->i_size) {
/* leave out-of-bound access unmapped */ /* leave out-of-bound access unmapped */
map->m_flags = 0; map->m_flags = 0;
map->m_plen = 0; map->m_plen = 0;
@ -170,7 +170,7 @@ err_out:
int erofs_map_blocks(struct inode *inode, int erofs_map_blocks(struct inode *inode,
struct erofs_map_blocks *map, int flags) struct erofs_map_blocks *map, int flags)
{ {
if (unlikely(is_inode_layout_compression(inode))) { if (is_inode_layout_compression(inode)) {
int err = z_erofs_map_blocks_iter(inode, map, flags); int err = z_erofs_map_blocks_iter(inode, map, flags);
if (map->mpage) { if (map->mpage) {
@ -218,11 +218,11 @@ submit_bio_retry:
unsigned int blkoff; unsigned int blkoff;
err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW); err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
if (unlikely(err)) if (err)
goto err_out; goto err_out;
/* zero out the holed page */ /* zero out the holed page */
if (unlikely(!(map.m_flags & EROFS_MAP_MAPPED))) { if (!(map.m_flags & EROFS_MAP_MAPPED)) {
zero_user_segment(page, 0, PAGE_SIZE); zero_user_segment(page, 0, PAGE_SIZE);
SetPageUptodate(page); SetPageUptodate(page);
@ -315,7 +315,7 @@ has_updated:
submit_bio_out: submit_bio_out:
__submit_bio(bio, REQ_OP_READ, 0); __submit_bio(bio, REQ_OP_READ, 0);
return unlikely(err) ? ERR_PTR(err) : NULL; return err ? ERR_PTR(err) : NULL;
} }
/* /*
@ -377,7 +377,7 @@ static int erofs_raw_access_readpages(struct file *filp,
DBG_BUGON(!list_empty(pages)); DBG_BUGON(!list_empty(pages));
/* the rare case (end in gaps) */ /* the rare case (end in gaps) */
if (unlikely(bio)) if (bio)
__submit_bio(bio, REQ_OP_READ, 0); __submit_bio(bio, REQ_OP_READ, 0);
return 0; return 0;
} }

View File

@ -78,7 +78,7 @@ static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
get_page(victim); get_page(victim);
} else { } else {
victim = erofs_allocpage(pagepool, GFP_KERNEL, false); victim = erofs_allocpage(pagepool, GFP_KERNEL, false);
if (unlikely(!victim)) if (!victim)
return -ENOMEM; return -ENOMEM;
victim->mapping = Z_EROFS_MAPPING_STAGING; victim->mapping = Z_EROFS_MAPPING_STAGING;
} }

View File

@ -45,8 +45,8 @@ static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx,
de_namelen = le16_to_cpu(de[1].nameoff) - nameoff; de_namelen = le16_to_cpu(de[1].nameoff) - nameoff;
/* a corrupted entry is found */ /* a corrupted entry is found */
if (unlikely(nameoff + de_namelen > maxsize || if (nameoff + de_namelen > maxsize ||
de_namelen > EROFS_NAME_LEN)) { de_namelen > EROFS_NAME_LEN) {
errln("bogus dirent @ nid %llu", EROFS_V(dir)->nid); errln("bogus dirent @ nid %llu", EROFS_V(dir)->nid);
DBG_BUGON(1); DBG_BUGON(1);
return -EFSCORRUPTED; return -EFSCORRUPTED;
@ -94,8 +94,8 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
nameoff = le16_to_cpu(de->nameoff); nameoff = le16_to_cpu(de->nameoff);
if (unlikely(nameoff < sizeof(struct erofs_dirent) || if (nameoff < sizeof(struct erofs_dirent) ||
nameoff >= PAGE_SIZE)) { nameoff >= PAGE_SIZE) {
errln("%s, invalid de[0].nameoff %u @ nid %llu", errln("%s, invalid de[0].nameoff %u @ nid %llu",
__func__, nameoff, EROFS_V(dir)->nid); __func__, nameoff, EROFS_V(dir)->nid);
err = -EFSCORRUPTED; err = -EFSCORRUPTED;
@ -106,11 +106,11 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
dirsize - ctx->pos + ofs, PAGE_SIZE); dirsize - ctx->pos + ofs, PAGE_SIZE);
/* search dirents at the arbitrary position */ /* search dirents at the arbitrary position */
if (unlikely(initial)) { if (initial) {
initial = false; initial = false;
ofs = roundup(ofs, sizeof(struct erofs_dirent)); ofs = roundup(ofs, sizeof(struct erofs_dirent));
if (unlikely(ofs >= nameoff)) if (ofs >= nameoff)
goto skip_this; goto skip_this;
} }
@ -123,7 +123,7 @@ skip_this:
ctx->pos = blknr_to_addr(i) + ofs; ctx->pos = blknr_to_addr(i) + ofs;
if (unlikely(err)) if (err)
break; break;
++i; ++i;
ofs = 0; ofs = 0;

View File

@ -18,7 +18,7 @@ static int read_inode(struct inode *inode, void *data)
vi->datamode = __inode_data_mapping(advise); vi->datamode = __inode_data_mapping(advise);
if (unlikely(vi->datamode >= EROFS_INODE_LAYOUT_MAX)) { if (vi->datamode >= EROFS_INODE_LAYOUT_MAX) {
errln("unsupported data mapping %u of nid %llu", errln("unsupported data mapping %u of nid %llu",
vi->datamode, vi->nid); vi->datamode, vi->nid);
DBG_BUGON(1); DBG_BUGON(1);
@ -133,13 +133,13 @@ static int fill_inline_data(struct inode *inode, void *data,
if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) { if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) {
char *lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL); char *lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL);
if (unlikely(!lnk)) if (!lnk)
return -ENOMEM; return -ENOMEM;
m_pofs += vi->inode_isize + vi->xattr_isize; m_pofs += vi->inode_isize + vi->xattr_isize;
/* inline symlink data shouldn't across page boundary as well */ /* inline symlink data shouldn't across page boundary as well */
if (unlikely(m_pofs + inode->i_size > PAGE_SIZE)) { if (m_pofs + inode->i_size > PAGE_SIZE) {
kfree(lnk); kfree(lnk);
errln("inline data cross block boundary @ nid %llu", errln("inline data cross block boundary @ nid %llu",
vi->nid); vi->nid);
@ -268,7 +268,7 @@ struct inode *erofs_iget(struct super_block *sb,
{ {
struct inode *inode = erofs_iget_locked(sb, nid); struct inode *inode = erofs_iget_locked(sb, nid);
if (unlikely(!inode)) if (!inode)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (inode->i_state & I_NEW) { if (inode->i_state & I_NEW) {
@ -278,7 +278,7 @@ struct inode *erofs_iget(struct super_block *sb,
vi->nid = nid; vi->nid = nid;
err = fill_inode(inode, isdir); err = fill_inode(inode, isdir);
if (likely(!err)) if (!err)
unlock_new_inode(inode); unlock_new_inode(inode);
else { else {
iget_failed(inode); iget_failed(inode);

View File

@ -424,7 +424,7 @@ static inline struct bio *erofs_grab_bio(struct super_block *sb,
do { do {
if (nr_pages == 1) { if (nr_pages == 1) {
bio = bio_alloc(gfp | (nofail ? __GFP_NOFAIL : 0), 1); bio = bio_alloc(gfp | (nofail ? __GFP_NOFAIL : 0), 1);
if (unlikely(!bio)) { if (!bio) {
DBG_BUGON(nofail); DBG_BUGON(nofail);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
@ -432,7 +432,7 @@ static inline struct bio *erofs_grab_bio(struct super_block *sb,
} }
bio = bio_alloc(gfp, nr_pages); bio = bio_alloc(gfp, nr_pages);
nr_pages /= 2; nr_pages /= 2;
} while (unlikely(!bio)); } while (!bio);
bio->bi_end_io = endio; bio->bi_end_io = endio;
bio_set_dev(bio, sb->s_bdev); bio_set_dev(bio, sb->s_bdev);

View File

@ -64,7 +64,7 @@ static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name,
unsigned int matched = min(startprfx, endprfx); unsigned int matched = min(startprfx, endprfx);
struct erofs_qstr dname = { struct erofs_qstr dname = {
.name = data + nameoff, .name = data + nameoff,
.end = unlikely(mid >= ndirents - 1) ? .end = mid >= ndirents - 1 ?
data + dirblksize : data + dirblksize :
data + nameoff_from_disk(de[mid + 1].nameoff, data + nameoff_from_disk(de[mid + 1].nameoff,
dirblksize) dirblksize)
@ -73,7 +73,7 @@ static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name,
/* string comparison without already matched prefix */ /* string comparison without already matched prefix */
int ret = dirnamecmp(name, &dname, &matched); int ret = dirnamecmp(name, &dname, &matched);
if (unlikely(!ret)) { if (!ret) {
return de + mid; return de + mid;
} else if (ret > 0) { } else if (ret > 0) {
head = mid + 1; head = mid + 1;
@ -113,7 +113,7 @@ static struct page *find_target_block_classic(struct inode *dir,
unsigned int matched; unsigned int matched;
struct erofs_qstr dname; struct erofs_qstr dname;
if (unlikely(!ndirents)) { if (!ndirents) {
kunmap_atomic(de); kunmap_atomic(de);
put_page(page); put_page(page);
errln("corrupted dir block %d @ nid %llu", errln("corrupted dir block %d @ nid %llu",
@ -137,7 +137,7 @@ static struct page *find_target_block_classic(struct inode *dir,
diff = dirnamecmp(name, &dname, &matched); diff = dirnamecmp(name, &dname, &matched);
kunmap_atomic(de); kunmap_atomic(de);
if (unlikely(!diff)) { if (!diff) {
*_ndirents = 0; *_ndirents = 0;
goto out; goto out;
} else if (diff > 0) { } else if (diff > 0) {
@ -174,7 +174,7 @@ int erofs_namei(struct inode *dir,
struct erofs_dirent *de; struct erofs_dirent *de;
struct erofs_qstr qn; struct erofs_qstr qn;
if (unlikely(!dir->i_size)) if (!dir->i_size)
return -ENOENT; return -ENOENT;
qn.name = name->name; qn.name = name->name;
@ -221,7 +221,7 @@ static struct dentry *erofs_lookup(struct inode *dir,
trace_erofs_lookup(dir, dentry, flags); trace_erofs_lookup(dir, dentry, flags);
/* file name exceeds fs limit */ /* file name exceeds fs limit */
if (unlikely(dentry->d_name.len > EROFS_NAME_LEN)) if (dentry->d_name.len > EROFS_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
/* false uninitialized warnings on gcc 4.8.x */ /* false uninitialized warnings on gcc 4.8.x */
@ -230,7 +230,7 @@ static struct dentry *erofs_lookup(struct inode *dir,
if (err == -ENOENT) { if (err == -ENOENT) {
/* negative dentry */ /* negative dentry */
inode = NULL; inode = NULL;
} else if (unlikely(err)) { } else if (err) {
inode = ERR_PTR(err); inode = ERR_PTR(err);
} else { } else {
debugln("%s, %s (nid %llu) found, d_type %u", __func__, debugln("%s, %s (nid %llu) found, d_type %u", __func__,

View File

@ -107,7 +107,7 @@ static int superblock_read(struct super_block *sb)
blkszbits = layout->blkszbits; blkszbits = layout->blkszbits;
/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
if (unlikely(blkszbits != LOG_BLOCK_SIZE)) { if (blkszbits != LOG_BLOCK_SIZE) {
errln("blksize %u isn't supported on this platform", errln("blksize %u isn't supported on this platform",
1 << blkszbits); 1 << blkszbits);
goto out; goto out;
@ -379,7 +379,7 @@ static int erofs_init_managed_cache(struct super_block *sb)
struct erofs_sb_info *const sbi = EROFS_SB(sb); struct erofs_sb_info *const sbi = EROFS_SB(sb);
struct inode *const inode = new_inode(sb); struct inode *const inode = new_inode(sb);
if (unlikely(!inode)) if (!inode)
return -ENOMEM; return -ENOMEM;
set_nlink(inode, 1); set_nlink(inode, 1);
@ -406,13 +406,13 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_magic = EROFS_SUPER_MAGIC; sb->s_magic = EROFS_SUPER_MAGIC;
if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) { if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) {
errln("failed to set erofs blksize"); errln("failed to set erofs blksize");
return -EINVAL; return -EINVAL;
} }
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (unlikely(!sbi)) if (!sbi)
return -ENOMEM; return -ENOMEM;
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
@ -433,7 +433,7 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
default_options(sbi); default_options(sbi);
err = parse_options(sb, data); err = parse_options(sb, data);
if (unlikely(err)) if (err)
return err; return err;
if (!silent) if (!silent)
@ -453,7 +453,7 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
if (IS_ERR(inode)) if (IS_ERR(inode))
return PTR_ERR(inode); return PTR_ERR(inode);
if (unlikely(!S_ISDIR(inode->i_mode))) { if (!S_ISDIR(inode->i_mode)) {
errln("rootino(nid %llu) is not a directory(i_mode %o)", errln("rootino(nid %llu) is not a directory(i_mode %o)",
ROOT_NID(sbi), inode->i_mode); ROOT_NID(sbi), inode->i_mode);
iput(inode); iput(inode);
@ -461,13 +461,13 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
} }
sb->s_root = d_make_root(inode); sb->s_root = d_make_root(inode);
if (unlikely(!sb->s_root)) if (!sb->s_root)
return -ENOMEM; return -ENOMEM;
erofs_shrinker_register(sb); erofs_shrinker_register(sb);
/* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */ /* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
err = erofs_init_managed_cache(sb); err = erofs_init_managed_cache(sb);
if (unlikely(err)) if (err)
return err; return err;
if (!silent) if (!silent)

View File

@ -46,14 +46,14 @@ static int erofs_workgroup_get(struct erofs_workgroup *grp)
repeat: repeat:
o = erofs_wait_on_workgroup_freezed(grp); o = erofs_wait_on_workgroup_freezed(grp);
if (unlikely(o <= 0)) if (o <= 0)
return -1; return -1;
if (unlikely(atomic_cmpxchg(&grp->refcount, o, o + 1) != o)) if (atomic_cmpxchg(&grp->refcount, o, o + 1) != o)
goto repeat; goto repeat;
/* decrease refcount paired by erofs_workgroup_put */ /* decrease refcount paired by erofs_workgroup_put */
if (unlikely(o == 1)) if (o == 1)
atomic_long_dec(&erofs_global_shrink_cnt); atomic_long_dec(&erofs_global_shrink_cnt);
return 0; return 0;
} }
@ -91,7 +91,7 @@ int erofs_register_workgroup(struct super_block *sb,
int err; int err;
/* grp shouldn't be broken or used before */ /* grp shouldn't be broken or used before */
if (unlikely(atomic_read(&grp->refcount) != 1)) { if (atomic_read(&grp->refcount) != 1) {
DBG_BUGON(1); DBG_BUGON(1);
return -EINVAL; return -EINVAL;
} }
@ -113,7 +113,7 @@ int erofs_register_workgroup(struct super_block *sb,
__erofs_workgroup_get(grp); __erofs_workgroup_get(grp);
err = radix_tree_insert(&sbi->workstn_tree, grp->index, grp); err = radix_tree_insert(&sbi->workstn_tree, grp->index, grp);
if (unlikely(err)) if (err)
/* /*
* it's safe to decrease since the workgroup isn't visible * it's safe to decrease since the workgroup isn't visible
* and refcount >= 2 (cannot be freezed). * and refcount >= 2 (cannot be freezed).
@ -212,7 +212,7 @@ repeat:
continue; continue;
++freed; ++freed;
if (unlikely(!--nr_shrink)) if (!--nr_shrink)
break; break;
} }
xa_unlock(&sbi->workstn_tree); xa_unlock(&sbi->workstn_tree);

View File

@ -19,7 +19,7 @@ struct xattr_iter {
static inline void xattr_iter_end(struct xattr_iter *it, bool atomic) static inline void xattr_iter_end(struct xattr_iter *it, bool atomic)
{ {
/* the only user of kunmap() is 'init_inode_xattrs' */ /* the only user of kunmap() is 'init_inode_xattrs' */
if (unlikely(!atomic)) if (!atomic)
kunmap(it->page); kunmap(it->page);
else else
kunmap_atomic(it->kaddr); kunmap_atomic(it->kaddr);
@ -72,7 +72,7 @@ static int init_inode_xattrs(struct inode *inode)
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto out_unlock; goto out_unlock;
} else if (vi->xattr_isize < sizeof(struct erofs_xattr_ibody_header)) { } else if (vi->xattr_isize < sizeof(struct erofs_xattr_ibody_header)) {
if (unlikely(vi->xattr_isize)) { if (vi->xattr_isize) {
errln("bogus xattr ibody @ nid %llu", vi->nid); errln("bogus xattr ibody @ nid %llu", vi->nid);
DBG_BUGON(1); DBG_BUGON(1);
ret = -EFSCORRUPTED; ret = -EFSCORRUPTED;
@ -112,7 +112,7 @@ static int init_inode_xattrs(struct inode *inode)
it.ofs += sizeof(struct erofs_xattr_ibody_header); it.ofs += sizeof(struct erofs_xattr_ibody_header);
for (i = 0; i < vi->xattr_shared_count; ++i) { for (i = 0; i < vi->xattr_shared_count; ++i) {
if (unlikely(it.ofs >= EROFS_BLKSIZ)) { if (it.ofs >= EROFS_BLKSIZ) {
/* cannot be unaligned */ /* cannot be unaligned */
DBG_BUGON(it.ofs != EROFS_BLKSIZ); DBG_BUGON(it.ofs != EROFS_BLKSIZ);
xattr_iter_end(&it, atomic_map); xattr_iter_end(&it, atomic_map);
@ -189,7 +189,7 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
unsigned int xattr_header_sz, inline_xattr_ofs; unsigned int xattr_header_sz, inline_xattr_ofs;
xattr_header_sz = inlinexattr_header_size(inode); xattr_header_sz = inlinexattr_header_size(inode);
if (unlikely(xattr_header_sz >= vi->xattr_isize)) { if (xattr_header_sz >= vi->xattr_isize) {
DBG_BUGON(xattr_header_sz > vi->xattr_isize); DBG_BUGON(xattr_header_sz > vi->xattr_isize);
return -ENOATTR; return -ENOATTR;
} }
@ -234,7 +234,7 @@ static int xattr_foreach(struct xattr_iter *it,
unsigned int entry_sz = EROFS_XATTR_ENTRY_SIZE(&entry); unsigned int entry_sz = EROFS_XATTR_ENTRY_SIZE(&entry);
/* xattr on-disk corruption: xattr entry beyond xattr_isize */ /* xattr on-disk corruption: xattr entry beyond xattr_isize */
if (unlikely(*tlimit < entry_sz)) { if (*tlimit < entry_sz) {
DBG_BUGON(1); DBG_BUGON(1);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
@ -436,7 +436,7 @@ int erofs_getxattr(struct inode *inode, int index,
int ret; int ret;
struct getxattr_iter it; struct getxattr_iter it;
if (unlikely(!name)) if (!name)
return -EINVAL; return -EINVAL;
ret = init_inode_xattrs(inode); ret = init_inode_xattrs(inode);

View File

@ -230,7 +230,7 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
if (!trylock_page(page)) if (!trylock_page(page))
return -EBUSY; return -EBUSY;
if (unlikely(page->mapping != mapping)) if (page->mapping != mapping)
continue; continue;
/* barrier is implied in the following 'unlock_page' */ /* barrier is implied in the following 'unlock_page' */
@ -358,7 +358,7 @@ static struct z_erofs_collection *cllookup(struct z_erofs_collector *clt,
} }
cl = z_erofs_primarycollection(pcl); cl = z_erofs_primarycollection(pcl);
if (unlikely(cl->pageofs != (map->m_la & ~PAGE_MASK))) { if (cl->pageofs != (map->m_la & ~PAGE_MASK)) {
DBG_BUGON(1); DBG_BUGON(1);
erofs_workgroup_put(grp); erofs_workgroup_put(grp);
return ERR_PTR(-EFSCORRUPTED); return ERR_PTR(-EFSCORRUPTED);
@ -406,7 +406,7 @@ static struct z_erofs_collection *clregister(struct z_erofs_collector *clt,
/* no available workgroup, let's allocate one */ /* no available workgroup, let's allocate one */
pcl = kmem_cache_alloc(pcluster_cachep, GFP_NOFS); pcl = kmem_cache_alloc(pcluster_cachep, GFP_NOFS);
if (unlikely(!pcl)) if (!pcl)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
init_always(pcl); init_always(pcl);
@ -474,7 +474,7 @@ repeat:
if (!cl) { if (!cl) {
cl = clregister(clt, inode, map); cl = clregister(clt, inode, map);
if (unlikely(cl == ERR_PTR(-EAGAIN))) if (cl == ERR_PTR(-EAGAIN))
goto repeat; goto repeat;
} }
@ -607,15 +607,15 @@ repeat:
map->m_la = offset + cur; map->m_la = offset + cur;
map->m_llen = 0; map->m_llen = 0;
err = z_erofs_map_blocks_iter(inode, map, 0); err = z_erofs_map_blocks_iter(inode, map, 0);
if (unlikely(err)) if (err)
goto err_out; goto err_out;
restart_now: restart_now:
if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED))) if (!(map->m_flags & EROFS_MAP_MAPPED))
goto hitted; goto hitted;
err = z_erofs_collector_begin(clt, inode, map); err = z_erofs_collector_begin(clt, inode, map);
if (unlikely(err)) if (err)
goto err_out; goto err_out;
/* preload all compressed pages (maybe downgrade role if necessary) */ /* preload all compressed pages (maybe downgrade role if necessary) */
@ -630,7 +630,7 @@ restart_now:
tight &= (clt->mode >= COLLECT_PRIMARY_HOOKED); tight &= (clt->mode >= COLLECT_PRIMARY_HOOKED);
hitted: hitted:
cur = end - min_t(unsigned int, offset + end - map->m_la, end); cur = end - min_t(unsigned int, offset + end - map->m_la, end);
if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED))) { if (!(map->m_flags & EROFS_MAP_MAPPED)) {
zero_user_segment(page, cur, end); zero_user_segment(page, cur, end);
goto next_part; goto next_part;
} }
@ -653,11 +653,11 @@ retry:
err = z_erofs_attach_page(clt, newpage, err = z_erofs_attach_page(clt, newpage,
Z_EROFS_PAGE_TYPE_EXCLUSIVE); Z_EROFS_PAGE_TYPE_EXCLUSIVE);
if (likely(!err)) if (!err)
goto retry; goto retry;
} }
if (unlikely(err)) if (err)
goto err_out; goto err_out;
index = page->index - (map->m_la >> PAGE_SHIFT); index = page->index - (map->m_la >> PAGE_SHIFT);
@ -723,7 +723,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
DBG_BUGON(PageUptodate(page)); DBG_BUGON(PageUptodate(page));
DBG_BUGON(!page->mapping); DBG_BUGON(!page->mapping);
if (unlikely(!sbi && !z_erofs_page_is_staging(page))) { if (!sbi && !z_erofs_page_is_staging(page)) {
sbi = EROFS_SB(page->mapping->host->i_sb); sbi = EROFS_SB(page->mapping->host->i_sb);
if (time_to_inject(sbi, FAULT_READ_IO)) { if (time_to_inject(sbi, FAULT_READ_IO)) {
@ -736,7 +736,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
if (sbi) if (sbi)
cachemngd = erofs_page_is_managed(sbi, page); cachemngd = erofs_page_is_managed(sbi, page);
if (unlikely(err)) if (err)
SetPageError(page); SetPageError(page);
else if (cachemngd) else if (cachemngd)
SetPageUptodate(page); SetPageUptodate(page);
@ -772,7 +772,7 @@ static int z_erofs_decompress_pcluster(struct super_block *sb,
mutex_lock(&cl->lock); mutex_lock(&cl->lock);
nr_pages = cl->nr_pages; nr_pages = cl->nr_pages;
if (likely(nr_pages <= Z_EROFS_VMAP_ONSTACK_PAGES)) { if (nr_pages <= Z_EROFS_VMAP_ONSTACK_PAGES) {
pages = pages_onstack; pages = pages_onstack;
} else if (nr_pages <= Z_EROFS_VMAP_GLOBAL_PAGES && } else if (nr_pages <= Z_EROFS_VMAP_GLOBAL_PAGES &&
mutex_trylock(&z_pagemap_global_lock)) { mutex_trylock(&z_pagemap_global_lock)) {
@ -787,7 +787,7 @@ static int z_erofs_decompress_pcluster(struct super_block *sb,
gfp_flags); gfp_flags);
/* fallback to global pagemap for the lowmem scenario */ /* fallback to global pagemap for the lowmem scenario */
if (unlikely(!pages)) { if (!pages) {
mutex_lock(&z_pagemap_global_lock); mutex_lock(&z_pagemap_global_lock);
pages = z_pagemap_global; pages = z_pagemap_global;
} }
@ -823,7 +823,7 @@ static int z_erofs_decompress_pcluster(struct super_block *sb,
* currently EROFS doesn't support multiref(dedup), * currently EROFS doesn't support multiref(dedup),
* so here erroring out one multiref page. * so here erroring out one multiref page.
*/ */
if (unlikely(pages[pagenr])) { if (pages[pagenr]) {
DBG_BUGON(1); DBG_BUGON(1);
SetPageError(pages[pagenr]); SetPageError(pages[pagenr]);
z_erofs_onlinepage_endio(pages[pagenr]); z_erofs_onlinepage_endio(pages[pagenr]);
@ -847,7 +847,7 @@ static int z_erofs_decompress_pcluster(struct super_block *sb,
if (!z_erofs_page_is_staging(page)) { if (!z_erofs_page_is_staging(page)) {
if (erofs_page_is_managed(sbi, page)) { if (erofs_page_is_managed(sbi, page)) {
if (unlikely(!PageUptodate(page))) if (!PageUptodate(page))
err = -EIO; err = -EIO;
continue; continue;
} }
@ -859,7 +859,7 @@ static int z_erofs_decompress_pcluster(struct super_block *sb,
pagenr = z_erofs_onlinepage_index(page); pagenr = z_erofs_onlinepage_index(page);
DBG_BUGON(pagenr >= nr_pages); DBG_BUGON(pagenr >= nr_pages);
if (unlikely(pages[pagenr])) { if (pages[pagenr]) {
DBG_BUGON(1); DBG_BUGON(1);
SetPageError(pages[pagenr]); SetPageError(pages[pagenr]);
z_erofs_onlinepage_endio(pages[pagenr]); z_erofs_onlinepage_endio(pages[pagenr]);
@ -871,13 +871,13 @@ static int z_erofs_decompress_pcluster(struct super_block *sb,
} }
/* PG_error needs checking for inplaced and staging pages */ /* PG_error needs checking for inplaced and staging pages */
if (unlikely(PageError(page))) { if (PageError(page)) {
DBG_BUGON(PageUptodate(page)); DBG_BUGON(PageUptodate(page));
err = -EIO; err = -EIO;
} }
} }
if (unlikely(err)) if (err)
goto out; goto out;
llen = pcl->length >> Z_EROFS_PCLUSTER_LENGTH_BIT; llen = pcl->length >> Z_EROFS_PCLUSTER_LENGTH_BIT;
@ -926,7 +926,7 @@ out:
if (z_erofs_put_stagingpage(pagepool, page)) if (z_erofs_put_stagingpage(pagepool, page))
continue; continue;
if (unlikely(err < 0)) if (err < 0)
SetPageError(page); SetPageError(page);
z_erofs_onlinepage_endio(page); z_erofs_onlinepage_endio(page);
@ -934,7 +934,7 @@ out:
if (pages == z_pagemap_global) if (pages == z_pagemap_global)
mutex_unlock(&z_pagemap_global_lock); mutex_unlock(&z_pagemap_global_lock);
else if (unlikely(pages != pages_onstack)) else if (pages != pages_onstack)
kvfree(pages); kvfree(pages);
cl->nr_pages = 0; cl->nr_pages = 0;
@ -1212,7 +1212,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
bool force_submit = false; bool force_submit = false;
unsigned int nr_bios; unsigned int nr_bios;
if (unlikely(owned_head == Z_EROFS_PCLUSTER_TAIL)) if (owned_head == Z_EROFS_PCLUSTER_TAIL)
return false; return false;
force_submit = false; force_submit = false;

View File

@ -348,7 +348,7 @@ static int vle_extent_lookback(struct z_erofs_maprecorder *m,
switch (m->type) { switch (m->type) {
case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
if (unlikely(!m->delta[0])) { if (!m->delta[0]) {
errln("invalid lookback distance 0 at nid %llu", errln("invalid lookback distance 0 at nid %llu",
vi->nid); vi->nid);
DBG_BUGON(1); DBG_BUGON(1);
@ -386,7 +386,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,
trace_z_erofs_map_blocks_iter_enter(inode, map, flags); trace_z_erofs_map_blocks_iter_enter(inode, map, flags);
/* when trying to read beyond EOF, leave it unmapped */ /* when trying to read beyond EOF, leave it unmapped */
if (unlikely(map->m_la >= inode->i_size)) { if (map->m_la >= inode->i_size) {
map->m_llen = map->m_la + 1 - inode->i_size; map->m_llen = map->m_la + 1 - inode->i_size;
map->m_la = inode->i_size; map->m_la = inode->i_size;
map->m_flags = 0; map->m_flags = 0;
@ -420,7 +420,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,
break; break;
} }
/* m.lcn should be >= 1 if endoff < m.clusterofs */ /* m.lcn should be >= 1 if endoff < m.clusterofs */
if (unlikely(!m.lcn)) { if (!m.lcn) {
errln("invalid logical cluster 0 at nid %llu", errln("invalid logical cluster 0 at nid %llu",
vi->nid); vi->nid);
err = -EFSCORRUPTED; err = -EFSCORRUPTED;
@ -433,7 +433,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,
case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
/* get the correspoinding first chunk */ /* get the correspoinding first chunk */
err = vle_extent_lookback(&m, m.delta[0]); err = vle_extent_lookback(&m, m.delta[0]);
if (unlikely(err)) if (err)
goto unmap_out; goto unmap_out;
break; break;
default: default:

View File

@ -111,11 +111,11 @@ static inline bool z_erofs_pagevec_enqueue(struct z_erofs_pagevec_ctor *ctor,
bool *occupied) bool *occupied)
{ {
*occupied = false; *occupied = false;
if (unlikely(!ctor->next && type)) if (!ctor->next && type)
if (ctor->index + 1 == ctor->nr) if (ctor->index + 1 == ctor->nr)
return false; return false;
if (unlikely(ctor->index >= ctor->nr)) if (ctor->index >= ctor->nr)
z_erofs_pagevec_ctor_pagedown(ctor, false); z_erofs_pagevec_ctor_pagedown(ctor, false);
/* exclusive page type must be 0 */ /* exclusive page type must be 0 */
@ -137,7 +137,7 @@ z_erofs_pagevec_dequeue(struct z_erofs_pagevec_ctor *ctor,
{ {
erofs_vtptr_t t; erofs_vtptr_t t;
if (unlikely(ctor->index >= ctor->nr)) { if (ctor->index >= ctor->nr) {
DBG_BUGON(!ctor->next); DBG_BUGON(!ctor->next);
z_erofs_pagevec_ctor_pagedown(ctor, true); z_erofs_pagevec_ctor_pagedown(ctor, true);
} }