Skip to content

Commit 8d8a09b

Browse files
Gao Xianggregkh
authored andcommitted
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>
1 parent 5cf8967 commit 8d8a09b

12 files changed

Lines changed: 82 additions & 82 deletions

File tree

‎fs/erofs/data.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static inline void read_endio(struct bio *bio)
2727
/* page is already locked */
2828
DBG_BUGON(PageUptodate(page));
2929

30-
if (unlikely(err))
30+
if (err)
3131
SetPageError(page);
3232
else
3333
SetPageUptodate(page);
@@ -53,7 +53,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
5353

5454
repeat:
5555
page = find_or_create_page(mapping, blkaddr, gfp);
56-
if (unlikely(!page)) {
56+
if (!page) {
5757
DBG_BUGON(nofail);
5858
return ERR_PTR(-ENOMEM);
5959
}
@@ -70,7 +70,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
7070
}
7171

7272
err = bio_add_page(bio, page, PAGE_SIZE, 0);
73-
if (unlikely(err != PAGE_SIZE)) {
73+
if (err != PAGE_SIZE) {
7474
err = -EFAULT;
7575
goto err_out;
7676
}
@@ -81,15 +81,15 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
8181
lock_page(page);
8282

8383
/* this page has been truncated by others */
84-
if (unlikely(page->mapping != mapping)) {
84+
if (page->mapping != mapping) {
8585
unlock_repeat:
8686
unlock_page(page);
8787
put_page(page);
8888
goto repeat;
8989
}
9090

9191
/* more likely a read error */
92-
if (unlikely(!PageUptodate(page))) {
92+
if (!PageUptodate(page)) {
9393
if (io_retries) {
9494
--io_retries;
9595
goto unlock_repeat;
@@ -120,7 +120,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
120120
nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE);
121121
lastblk = nblocks - is_inode_flat_inline(inode);
122122

123-
if (unlikely(offset >= inode->i_size)) {
123+
if (offset >= inode->i_size) {
124124
/* leave out-of-bound access unmapped */
125125
map->m_flags = 0;
126126
map->m_plen = 0;
@@ -170,7 +170,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
170170
int erofs_map_blocks(struct inode *inode,
171171
struct erofs_map_blocks *map, int flags)
172172
{
173-
if (unlikely(is_inode_layout_compression(inode))) {
173+
if (is_inode_layout_compression(inode)) {
174174
int err = z_erofs_map_blocks_iter(inode, map, flags);
175175

176176
if (map->mpage) {
@@ -218,11 +218,11 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
218218
unsigned int blkoff;
219219

220220
err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
221-
if (unlikely(err))
221+
if (err)
222222
goto err_out;
223223

224224
/* zero out the holed page */
225-
if (unlikely(!(map.m_flags & EROFS_MAP_MAPPED))) {
225+
if (!(map.m_flags & EROFS_MAP_MAPPED)) {
226226
zero_user_segment(page, 0, PAGE_SIZE);
227227
SetPageUptodate(page);
228228

@@ -315,7 +315,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
315315
submit_bio_out:
316316
__submit_bio(bio, REQ_OP_READ, 0);
317317

318-
return unlikely(err) ? ERR_PTR(err) : NULL;
318+
return err ? ERR_PTR(err) : NULL;
319319
}
320320

321321
/*
@@ -377,7 +377,7 @@ static int erofs_raw_access_readpages(struct file *filp,
377377
DBG_BUGON(!list_empty(pages));
378378

379379
/* the rare case (end in gaps) */
380-
if (unlikely(bio))
380+
if (bio)
381381
__submit_bio(bio, REQ_OP_READ, 0);
382382
return 0;
383383
}

‎fs/erofs/decompressor.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
7878
get_page(victim);
7979
} else {
8080
victim = erofs_allocpage(pagepool, GFP_KERNEL, false);
81-
if (unlikely(!victim))
81+
if (!victim)
8282
return -ENOMEM;
8383
victim->mapping = Z_EROFS_MAPPING_STAGING;
8484
}

‎fs/erofs/dir.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx,
4545
de_namelen = le16_to_cpu(de[1].nameoff) - nameoff;
4646

4747
/* a corrupted entry is found */
48-
if (unlikely(nameoff + de_namelen > maxsize ||
49-
de_namelen > EROFS_NAME_LEN)) {
48+
if (nameoff + de_namelen > maxsize ||
49+
de_namelen > EROFS_NAME_LEN) {
5050
errln("bogus dirent @ nid %llu", EROFS_V(dir)->nid);
5151
DBG_BUGON(1);
5252
return -EFSCORRUPTED;
@@ -94,8 +94,8 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
9494

9595
nameoff = le16_to_cpu(de->nameoff);
9696

97-
if (unlikely(nameoff < sizeof(struct erofs_dirent) ||
98-
nameoff >= PAGE_SIZE)) {
97+
if (nameoff < sizeof(struct erofs_dirent) ||
98+
nameoff >= PAGE_SIZE) {
9999
errln("%s, invalid de[0].nameoff %u @ nid %llu",
100100
__func__, nameoff, EROFS_V(dir)->nid);
101101
err = -EFSCORRUPTED;
@@ -106,11 +106,11 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
106106
dirsize - ctx->pos + ofs, PAGE_SIZE);
107107

108108
/* search dirents at the arbitrary position */
109-
if (unlikely(initial)) {
109+
if (initial) {
110110
initial = false;
111111

112112
ofs = roundup(ofs, sizeof(struct erofs_dirent));
113-
if (unlikely(ofs >= nameoff))
113+
if (ofs >= nameoff)
114114
goto skip_this;
115115
}
116116

@@ -123,7 +123,7 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
123123

124124
ctx->pos = blknr_to_addr(i) + ofs;
125125

126-
if (unlikely(err))
126+
if (err)
127127
break;
128128
++i;
129129
ofs = 0;

‎fs/erofs/inode.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int read_inode(struct inode *inode, void *data)
1818

1919
vi->datamode = __inode_data_mapping(advise);
2020

21-
if (unlikely(vi->datamode >= EROFS_INODE_LAYOUT_MAX)) {
21+
if (vi->datamode >= EROFS_INODE_LAYOUT_MAX) {
2222
errln("unsupported data mapping %u of nid %llu",
2323
vi->datamode, vi->nid);
2424
DBG_BUGON(1);
@@ -133,13 +133,13 @@ static int fill_inline_data(struct inode *inode, void *data,
133133
if (S_ISLNK(inode->i_mode) && inode->i_size < PAGE_SIZE) {
134134
char *lnk = erofs_kmalloc(sbi, inode->i_size + 1, GFP_KERNEL);
135135

136-
if (unlikely(!lnk))
136+
if (!lnk)
137137
return -ENOMEM;
138138

139139
m_pofs += vi->inode_isize + vi->xattr_isize;
140140

141141
/* inline symlink data shouldn't across page boundary as well */
142-
if (unlikely(m_pofs + inode->i_size > PAGE_SIZE)) {
142+
if (m_pofs + inode->i_size > PAGE_SIZE) {
143143
kfree(lnk);
144144
errln("inline data cross block boundary @ nid %llu",
145145
vi->nid);
@@ -268,7 +268,7 @@ struct inode *erofs_iget(struct super_block *sb,
268268
{
269269
struct inode *inode = erofs_iget_locked(sb, nid);
270270

271-
if (unlikely(!inode))
271+
if (!inode)
272272
return ERR_PTR(-ENOMEM);
273273

274274
if (inode->i_state & I_NEW) {
@@ -278,7 +278,7 @@ struct inode *erofs_iget(struct super_block *sb,
278278
vi->nid = nid;
279279

280280
err = fill_inode(inode, isdir);
281-
if (likely(!err))
281+
if (!err)
282282
unlock_new_inode(inode);
283283
else {
284284
iget_failed(inode);

‎fs/erofs/internal.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,15 @@ static inline struct bio *erofs_grab_bio(struct super_block *sb,
424424
do {
425425
if (nr_pages == 1) {
426426
bio = bio_alloc(gfp | (nofail ? __GFP_NOFAIL : 0), 1);
427-
if (unlikely(!bio)) {
427+
if (!bio) {
428428
DBG_BUGON(nofail);
429429
return ERR_PTR(-ENOMEM);
430430
}
431431
break;
432432
}
433433
bio = bio_alloc(gfp, nr_pages);
434434
nr_pages /= 2;
435-
} while (unlikely(!bio));
435+
} while (!bio);
436436

437437
bio->bi_end_io = endio;
438438
bio_set_dev(bio, sb->s_bdev);

‎fs/erofs/namei.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name,
6464
unsigned int matched = min(startprfx, endprfx);
6565
struct erofs_qstr dname = {
6666
.name = data + nameoff,
67-
.end = unlikely(mid >= ndirents - 1) ?
67+
.end = mid >= ndirents - 1 ?
6868
data + dirblksize :
6969
data + nameoff_from_disk(de[mid + 1].nameoff,
7070
dirblksize)
@@ -73,7 +73,7 @@ static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name,
7373
/* string comparison without already matched prefix */
7474
int ret = dirnamecmp(name, &dname, &matched);
7575

76-
if (unlikely(!ret)) {
76+
if (!ret) {
7777
return de + mid;
7878
} else if (ret > 0) {
7979
head = mid + 1;
@@ -113,7 +113,7 @@ static struct page *find_target_block_classic(struct inode *dir,
113113
unsigned int matched;
114114
struct erofs_qstr dname;
115115

116-
if (unlikely(!ndirents)) {
116+
if (!ndirents) {
117117
kunmap_atomic(de);
118118
put_page(page);
119119
errln("corrupted dir block %d @ nid %llu",
@@ -137,7 +137,7 @@ static struct page *find_target_block_classic(struct inode *dir,
137137
diff = dirnamecmp(name, &dname, &matched);
138138
kunmap_atomic(de);
139139

140-
if (unlikely(!diff)) {
140+
if (!diff) {
141141
*_ndirents = 0;
142142
goto out;
143143
} else if (diff > 0) {
@@ -174,7 +174,7 @@ int erofs_namei(struct inode *dir,
174174
struct erofs_dirent *de;
175175
struct erofs_qstr qn;
176176

177-
if (unlikely(!dir->i_size))
177+
if (!dir->i_size)
178178
return -ENOENT;
179179

180180
qn.name = name->name;
@@ -221,7 +221,7 @@ static struct dentry *erofs_lookup(struct inode *dir,
221221
trace_erofs_lookup(dir, dentry, flags);
222222

223223
/* file name exceeds fs limit */
224-
if (unlikely(dentry->d_name.len > EROFS_NAME_LEN))
224+
if (dentry->d_name.len > EROFS_NAME_LEN)
225225
return ERR_PTR(-ENAMETOOLONG);
226226

227227
/* false uninitialized warnings on gcc 4.8.x */
@@ -230,7 +230,7 @@ static struct dentry *erofs_lookup(struct inode *dir,
230230
if (err == -ENOENT) {
231231
/* negative dentry */
232232
inode = NULL;
233-
} else if (unlikely(err)) {
233+
} else if (err) {
234234
inode = ERR_PTR(err);
235235
} else {
236236
debugln("%s, %s (nid %llu) found, d_type %u", __func__,

‎fs/erofs/super.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int superblock_read(struct super_block *sb)
107107

108108
blkszbits = layout->blkszbits;
109109
/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
110-
if (unlikely(blkszbits != LOG_BLOCK_SIZE)) {
110+
if (blkszbits != LOG_BLOCK_SIZE) {
111111
errln("blksize %u isn't supported on this platform",
112112
1 << blkszbits);
113113
goto out;
@@ -379,7 +379,7 @@ static int erofs_init_managed_cache(struct super_block *sb)
379379
struct erofs_sb_info *const sbi = EROFS_SB(sb);
380380
struct inode *const inode = new_inode(sb);
381381

382-
if (unlikely(!inode))
382+
if (!inode)
383383
return -ENOMEM;
384384

385385
set_nlink(inode, 1);
@@ -406,13 +406,13 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
406406

407407
sb->s_magic = EROFS_SUPER_MAGIC;
408408

409-
if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) {
409+
if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) {
410410
errln("failed to set erofs blksize");
411411
return -EINVAL;
412412
}
413413

414414
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
415-
if (unlikely(!sbi))
415+
if (!sbi)
416416
return -ENOMEM;
417417

418418
sb->s_fs_info = sbi;
@@ -433,7 +433,7 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
433433
default_options(sbi);
434434

435435
err = parse_options(sb, data);
436-
if (unlikely(err))
436+
if (err)
437437
return err;
438438

439439
if (!silent)
@@ -453,21 +453,21 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
453453
if (IS_ERR(inode))
454454
return PTR_ERR(inode);
455455

456-
if (unlikely(!S_ISDIR(inode->i_mode))) {
456+
if (!S_ISDIR(inode->i_mode)) {
457457
errln("rootino(nid %llu) is not a directory(i_mode %o)",
458458
ROOT_NID(sbi), inode->i_mode);
459459
iput(inode);
460460
return -EINVAL;
461461
}
462462

463463
sb->s_root = d_make_root(inode);
464-
if (unlikely(!sb->s_root))
464+
if (!sb->s_root)
465465
return -ENOMEM;
466466

467467
erofs_shrinker_register(sb);
468468
/* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
469469
err = erofs_init_managed_cache(sb);
470-
if (unlikely(err))
470+
if (err)
471471
return err;
472472

473473
if (!silent)

‎fs/erofs/utils.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ static int erofs_workgroup_get(struct erofs_workgroup *grp)
4646

4747
repeat:
4848
o = erofs_wait_on_workgroup_freezed(grp);
49-
if (unlikely(o <= 0))
49+
if (o <= 0)
5050
return -1;
5151

52-
if (unlikely(atomic_cmpxchg(&grp->refcount, o, o + 1) != o))
52+
if (atomic_cmpxchg(&grp->refcount, o, o + 1) != o)
5353
goto repeat;
5454

5555
/* decrease refcount paired by erofs_workgroup_put */
56-
if (unlikely(o == 1))
56+
if (o == 1)
5757
atomic_long_dec(&erofs_global_shrink_cnt);
5858
return 0;
5959
}
@@ -91,7 +91,7 @@ int erofs_register_workgroup(struct super_block *sb,
9191
int err;
9292

9393
/* grp shouldn't be broken or used before */
94-
if (unlikely(atomic_read(&grp->refcount) != 1)) {
94+
if (atomic_read(&grp->refcount) != 1) {
9595
DBG_BUGON(1);
9696
return -EINVAL;
9797
}
@@ -113,7 +113,7 @@ int erofs_register_workgroup(struct super_block *sb,
113113
__erofs_workgroup_get(grp);
114114

115115
err = radix_tree_insert(&sbi->workstn_tree, grp->index, grp);
116-
if (unlikely(err))
116+
if (err)
117117
/*
118118
* it's safe to decrease since the workgroup isn't visible
119119
* and refcount >= 2 (cannot be freezed).
@@ -212,7 +212,7 @@ static unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
212212
continue;
213213

214214
++freed;
215-
if (unlikely(!--nr_shrink))
215+
if (!--nr_shrink)
216216
break;
217217
}
218218
xa_unlock(&sbi->workstn_tree);

0 commit comments

Comments
 (0)