diff options
author | Wang Shilong <wangsl-fnst@cn.fujitsu.com> | 2013-01-12 16:28:47 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-01-12 16:28:47 -0500 |
commit | aebf02430d25b6bd2b8542126fdcdb90e75a24b8 (patch) | |
tree | 7f884e64b000d9bed3a59dd557b3075a2da4405d /fs/ext4 | |
parent | 860d21e2c585f7ee8a4ecc06f474fdc33c9474f4 (diff) |
ext4: 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 optimize it.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/extents.c | 6 | ||||
-rw-r--r-- | fs/ext4/inode.c | 6 | ||||
-rw-r--r-- | fs/ext4/mmp.c | 2 | ||||
-rw-r--r-- | fs/ext4/resize.c | 10 | ||||
-rw-r--r-- | fs/ext4/xattr.c | 2 |
5 files changed, 13 insertions, 13 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index d42a8c49ad69..391e53a52e58 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -956,7 +956,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, | |||
956 | goto cleanup; | 956 | goto cleanup; |
957 | } | 957 | } |
958 | bh = sb_getblk(inode->i_sb, newblock); | 958 | bh = sb_getblk(inode->i_sb, newblock); |
959 | if (!bh) { | 959 | if (unlikely(!bh)) { |
960 | err = -ENOMEM; | 960 | err = -ENOMEM; |
961 | goto cleanup; | 961 | goto cleanup; |
962 | } | 962 | } |
@@ -1029,7 +1029,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, | |||
1029 | oldblock = newblock; | 1029 | oldblock = newblock; |
1030 | newblock = ablocks[--a]; | 1030 | newblock = ablocks[--a]; |
1031 | bh = sb_getblk(inode->i_sb, newblock); | 1031 | bh = sb_getblk(inode->i_sb, newblock); |
1032 | if (!bh) { | 1032 | if (unlikely(!bh)) { |
1033 | err = -ENOMEM; | 1033 | err = -ENOMEM; |
1034 | goto cleanup; | 1034 | goto cleanup; |
1035 | } | 1035 | } |
@@ -1142,7 +1142,7 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, | |||
1142 | return err; | 1142 | return err; |
1143 | 1143 | ||
1144 | bh = sb_getblk(inode->i_sb, newblock); | 1144 | bh = sb_getblk(inode->i_sb, newblock); |
1145 | if (!bh) | 1145 | if (unlikely(!bh)) |
1146 | return -ENOMEM; | 1146 | return -ENOMEM; |
1147 | lock_buffer(bh); | 1147 | lock_buffer(bh); |
1148 | 1148 | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 9ccc140b82d2..93a7e8453a68 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -713,7 +713,7 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, | |||
713 | return NULL; | 713 | return NULL; |
714 | 714 | ||
715 | bh = sb_getblk(inode->i_sb, map.m_pblk); | 715 | bh = sb_getblk(inode->i_sb, map.m_pblk); |
716 | if (!bh) { | 716 | if (unlikely(!bh)) { |
717 | *errp = -ENOMEM; | 717 | *errp = -ENOMEM; |
718 | return NULL; | 718 | return NULL; |
719 | } | 719 | } |
@@ -3660,7 +3660,7 @@ static int __ext4_get_inode_loc(struct inode *inode, | |||
3660 | iloc->offset = (inode_offset % inodes_per_block) * EXT4_INODE_SIZE(sb); | 3660 | iloc->offset = (inode_offset % inodes_per_block) * EXT4_INODE_SIZE(sb); |
3661 | 3661 | ||
3662 | bh = sb_getblk(sb, block); | 3662 | bh = sb_getblk(sb, block); |
3663 | if (!bh) | 3663 | if (unlikely(!bh)) |
3664 | return -ENOMEM; | 3664 | return -ENOMEM; |
3665 | if (!buffer_uptodate(bh)) { | 3665 | if (!buffer_uptodate(bh)) { |
3666 | lock_buffer(bh); | 3666 | lock_buffer(bh); |
@@ -3693,7 +3693,7 @@ static int __ext4_get_inode_loc(struct inode *inode, | |||
3693 | 3693 | ||
3694 | /* Is the inode bitmap in cache? */ | 3694 | /* Is the inode bitmap in cache? */ |
3695 | bitmap_bh = sb_getblk(sb, ext4_inode_bitmap(sb, gdp)); | 3695 | bitmap_bh = sb_getblk(sb, ext4_inode_bitmap(sb, gdp)); |
3696 | if (!bitmap_bh) | 3696 | if (unlikely(!bitmap_bh)) |
3697 | goto make_io; | 3697 | goto make_io; |
3698 | 3698 | ||
3699 | /* | 3699 | /* |
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 44734f1ca554..f9b551561d2c 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c | |||
@@ -93,7 +93,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh, | |||
93 | *bh = NULL; | 93 | *bh = NULL; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | if (!*bh) { | 96 | if (unlikely(!*bh)) { |
97 | ext4_warning(sb, "Error while reading MMP block %llu", | 97 | ext4_warning(sb, "Error while reading MMP block %llu", |
98 | mmp_block); | 98 | mmp_block); |
99 | return -EIO; | 99 | return -EIO; |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 02824dc2ff3b..05f8d4502d42 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -333,7 +333,7 @@ static struct buffer_head *bclean(handle_t *handle, struct super_block *sb, | |||
333 | int err; | 333 | int err; |
334 | 334 | ||
335 | bh = sb_getblk(sb, blk); | 335 | bh = sb_getblk(sb, blk); |
336 | if (!bh) | 336 | if (unlikely(!bh)) |
337 | return ERR_PTR(-ENOMEM); | 337 | return ERR_PTR(-ENOMEM); |
338 | if ((err = ext4_journal_get_write_access(handle, bh))) { | 338 | if ((err = ext4_journal_get_write_access(handle, bh))) { |
339 | brelse(bh); | 339 | brelse(bh); |
@@ -410,7 +410,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle, | |||
410 | return err; | 410 | return err; |
411 | 411 | ||
412 | bh = sb_getblk(sb, flex_gd->groups[group].block_bitmap); | 412 | bh = sb_getblk(sb, flex_gd->groups[group].block_bitmap); |
413 | if (!bh) | 413 | if (unlikely(!bh)) |
414 | return -ENOMEM; | 414 | return -ENOMEM; |
415 | 415 | ||
416 | err = ext4_journal_get_write_access(handle, bh); | 416 | err = ext4_journal_get_write_access(handle, bh); |
@@ -500,7 +500,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb, | |||
500 | goto out; | 500 | goto out; |
501 | 501 | ||
502 | gdb = sb_getblk(sb, block); | 502 | gdb = sb_getblk(sb, block); |
503 | if (!gdb) { | 503 | if (unlikely(!gdb)) { |
504 | err = -ENOMEM; | 504 | err = -ENOMEM; |
505 | goto out; | 505 | goto out; |
506 | } | 506 | } |
@@ -1064,7 +1064,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data, | |||
1064 | ext4_bg_has_super(sb, group)); | 1064 | ext4_bg_has_super(sb, group)); |
1065 | 1065 | ||
1066 | bh = sb_getblk(sb, backup_block); | 1066 | bh = sb_getblk(sb, backup_block); |
1067 | if (!bh) { | 1067 | if (unlikely(!bh)) { |
1068 | err = -ENOMEM; | 1068 | err = -ENOMEM; |
1069 | break; | 1069 | break; |
1070 | } | 1070 | } |
@@ -1168,7 +1168,7 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb, | |||
1168 | static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block) | 1168 | static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block) |
1169 | { | 1169 | { |
1170 | struct buffer_head *bh = sb_getblk(sb, block); | 1170 | struct buffer_head *bh = sb_getblk(sb, block); |
1171 | if (!bh) | 1171 | if (unlikely(!bh)) |
1172 | return NULL; | 1172 | return NULL; |
1173 | if (!bh_uptodate_or_lock(bh)) { | 1173 | if (!bh_uptodate_or_lock(bh)) { |
1174 | if (bh_submit_read(bh) < 0) { | 1174 | if (bh_submit_read(bh) < 0) { |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 07d684a4e523..c68990c392c7 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -886,7 +886,7 @@ inserted: | |||
886 | (unsigned long long)block); | 886 | (unsigned long long)block); |
887 | 887 | ||
888 | new_bh = sb_getblk(sb, block); | 888 | new_bh = sb_getblk(sb, block); |
889 | if (!new_bh) { | 889 | if (unlikely(!new_bh)) { |
890 | error = -ENOMEM; | 890 | error = -ENOMEM; |
891 | getblk_failed: | 891 | getblk_failed: |
892 | ext4_free_blocks(handle, inode, NULL, block, 1, | 892 | ext4_free_blocks(handle, inode, NULL, block, 1, |