Skip to content

Commit 1b7d76e

Browse files
Wang Shilongjankara
authored andcommitted
Ext3: use unlikely to improve the efficiency of the kernel
Because the function 'sb_getblk' seldomly fails to return NULL value,it will be better to use unlikely to check it. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 2b0542a commit 1b7d76e

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/ext3/inode.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode *inode,
10821082
if (!err && buffer_mapped(&dummy)) {
10831083
struct buffer_head *bh;
10841084
bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
1085-
if (!bh) {
1085+
if (unlikely(!bh)) {
10861086
*errp = -EIO;
10871087
goto err;
10881088
}
@@ -2733,7 +2733,7 @@ static int __ext3_get_inode_loc(struct inode *inode,
27332733
return -EIO;
27342734

27352735
bh = sb_getblk(inode->i_sb, block);
2736-
if (!bh) {
2736+
if (unlikely(!bh)) {
27372737
ext3_error (inode->i_sb, "ext3_get_inode_loc",
27382738
"unable to read inode block - "
27392739
"inode=%lu, block="E3FSBLK,
@@ -2787,7 +2787,7 @@ static int __ext3_get_inode_loc(struct inode *inode,
27872787

27882788
bitmap_bh = sb_getblk(inode->i_sb,
27892789
le32_to_cpu(desc->bg_inode_bitmap));
2790-
if (!bitmap_bh)
2790+
if (unlikely(!bitmap_bh))
27912791
goto make_io;
27922792

27932793
/*

‎fs/ext3/resize.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
116116
int err;
117117

118118
bh = sb_getblk(sb, blk);
119-
if (!bh)
119+
if (unlikely(!bh))
120120
return ERR_PTR(-EIO);
121121
if ((err = ext3_journal_get_write_access(handle, bh))) {
122122
brelse(bh);
@@ -234,7 +234,7 @@ static int setup_new_group_blocks(struct super_block *sb,
234234
goto exit_bh;
235235

236236
gdb = sb_getblk(sb, block);
237-
if (!gdb) {
237+
if (unlikely(!gdb)) {
238238
err = -EIO;
239239
goto exit_bh;
240240
}
@@ -722,7 +722,7 @@ static void update_backups(struct super_block *sb,
722722
break;
723723

724724
bh = sb_getblk(sb, group * bpg + blk_off);
725-
if (!bh) {
725+
if (unlikely(!bh)) {
726726
err = -EIO;
727727
break;
728728
}

‎fs/ext3/xattr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ ext3_xattr_block_set(handle_t *handle, struct inode *inode,
813813
ea_idebug(inode, "creating block %d", block);
814814

815815
new_bh = sb_getblk(sb, block);
816-
if (!new_bh) {
816+
if (unlikely(!new_bh)) {
817817
getblk_failed:
818818
ext3_free_blocks(handle, inode, block, 1);
819819
error = -EIO;

0 commit comments

Comments
 (0)