diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-12-06 01:00:58 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-12-22 20:18:06 -0500 |
commit | 6bacf52fb58aeb3e89d9a62970b85a5570aa8ace (patch) | |
tree | 422eb46c144b7ffbae193570a001de2eed490e09 /fs/f2fs/data.c | |
parent | cfb271d485d0ec31eb92b51f4fbe54bf6542e8e6 (diff) |
f2fs: add unlikely() macro for compiler more aggressively
This patch adds unlikely() macro into the most of codes.
The basic rule is to add that when:
- checking unusual errors,
- checking page mappings,
- and the other unlikely conditions.
Change log from v1:
- Don't add unlikely for the NULL test and error test: advised by Andi Kleen.
Cc: Chao Yu <chao2.yu@samsung.com>
Cc: Andi Kleen <andi@firstfloor.org>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2ce5a9ef508b..5607393198df 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
@@ -49,11 +49,11 @@ static void f2fs_read_end_io(struct bio *bio, int err) | |||
49 | if (--bvec >= bio->bi_io_vec) | 49 | if (--bvec >= bio->bi_io_vec) |
50 | prefetchw(&bvec->bv_page->flags); | 50 | prefetchw(&bvec->bv_page->flags); |
51 | 51 | ||
52 | if (uptodate) { | 52 | if (unlikely(!uptodate)) { |
53 | SetPageUptodate(page); | ||
54 | } else { | ||
55 | ClearPageUptodate(page); | 53 | ClearPageUptodate(page); |
56 | SetPageError(page); | 54 | SetPageError(page); |
55 | } else { | ||
56 | SetPageUptodate(page); | ||
57 | } | 57 | } |
58 | unlock_page(page); | 58 | unlock_page(page); |
59 | } while (bvec >= bio->bi_io_vec); | 59 | } while (bvec >= bio->bi_io_vec); |
@@ -73,7 +73,7 @@ static void f2fs_write_end_io(struct bio *bio, int err) | |||
73 | if (--bvec >= bio->bi_io_vec) | 73 | if (--bvec >= bio->bi_io_vec) |
74 | prefetchw(&bvec->bv_page->flags); | 74 | prefetchw(&bvec->bv_page->flags); |
75 | 75 | ||
76 | if (!uptodate) { | 76 | if (unlikely(!uptodate)) { |
77 | SetPageError(page); | 77 | SetPageError(page); |
78 | set_bit(AS_EIO, &page->mapping->flags); | 78 | set_bit(AS_EIO, &page->mapping->flags); |
79 | set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG); | 79 | set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG); |
@@ -249,7 +249,7 @@ int reserve_new_block(struct dnode_of_data *dn) | |||
249 | { | 249 | { |
250 | struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); | 250 | struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); |
251 | 251 | ||
252 | if (is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC)) | 252 | if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC))) |
253 | return -EPERM; | 253 | return -EPERM; |
254 | if (unlikely(!inc_valid_block_count(sbi, dn->inode, 1))) | 254 | if (unlikely(!inc_valid_block_count(sbi, dn->inode, 1))) |
255 | return -ENOSPC; | 255 | return -ENOSPC; |
@@ -424,7 +424,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync) | |||
424 | return ERR_PTR(-ENOENT); | 424 | return ERR_PTR(-ENOENT); |
425 | 425 | ||
426 | /* By fallocate(), there is no cached page, but with NEW_ADDR */ | 426 | /* By fallocate(), there is no cached page, but with NEW_ADDR */ |
427 | if (dn.data_blkaddr == NEW_ADDR) | 427 | if (unlikely(dn.data_blkaddr == NEW_ADDR)) |
428 | return ERR_PTR(-EINVAL); | 428 | return ERR_PTR(-EINVAL); |
429 | 429 | ||
430 | page = grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS); | 430 | page = grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS); |
@@ -443,7 +443,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync) | |||
443 | 443 | ||
444 | if (sync) { | 444 | if (sync) { |
445 | wait_on_page_locked(page); | 445 | wait_on_page_locked(page); |
446 | if (!PageUptodate(page)) { | 446 | if (unlikely(!PageUptodate(page))) { |
447 | f2fs_put_page(page, 0); | 447 | f2fs_put_page(page, 0); |
448 | return ERR_PTR(-EIO); | 448 | return ERR_PTR(-EIO); |
449 | } | 449 | } |
@@ -477,7 +477,7 @@ repeat: | |||
477 | } | 477 | } |
478 | f2fs_put_dnode(&dn); | 478 | f2fs_put_dnode(&dn); |
479 | 479 | ||
480 | if (dn.data_blkaddr == NULL_ADDR) { | 480 | if (unlikely(dn.data_blkaddr == NULL_ADDR)) { |
481 | f2fs_put_page(page, 1); | 481 | f2fs_put_page(page, 1); |
482 | return ERR_PTR(-ENOENT); | 482 | return ERR_PTR(-ENOENT); |
483 | } | 483 | } |
@@ -502,11 +502,11 @@ repeat: | |||
502 | return ERR_PTR(err); | 502 | return ERR_PTR(err); |
503 | 503 | ||
504 | lock_page(page); | 504 | lock_page(page); |
505 | if (!PageUptodate(page)) { | 505 | if (unlikely(!PageUptodate(page))) { |
506 | f2fs_put_page(page, 1); | 506 | f2fs_put_page(page, 1); |
507 | return ERR_PTR(-EIO); | 507 | return ERR_PTR(-EIO); |
508 | } | 508 | } |
509 | if (page->mapping != mapping) { | 509 | if (unlikely(page->mapping != mapping)) { |
510 | f2fs_put_page(page, 1); | 510 | f2fs_put_page(page, 1); |
511 | goto repeat; | 511 | goto repeat; |
512 | } | 512 | } |
@@ -534,7 +534,6 @@ struct page *get_new_data_page(struct inode *inode, | |||
534 | err = f2fs_reserve_block(&dn, index); | 534 | err = f2fs_reserve_block(&dn, index); |
535 | if (err) | 535 | if (err) |
536 | return ERR_PTR(err); | 536 | return ERR_PTR(err); |
537 | |||
538 | repeat: | 537 | repeat: |
539 | page = grab_cache_page(mapping, index); | 538 | page = grab_cache_page(mapping, index); |
540 | if (!page) | 539 | if (!page) |
@@ -552,11 +551,11 @@ repeat: | |||
552 | if (err) | 551 | if (err) |
553 | return ERR_PTR(err); | 552 | return ERR_PTR(err); |
554 | lock_page(page); | 553 | lock_page(page); |
555 | if (!PageUptodate(page)) { | 554 | if (unlikely(!PageUptodate(page))) { |
556 | f2fs_put_page(page, 1); | 555 | f2fs_put_page(page, 1); |
557 | return ERR_PTR(-EIO); | 556 | return ERR_PTR(-EIO); |
558 | } | 557 | } |
559 | if (page->mapping != mapping) { | 558 | if (unlikely(page->mapping != mapping)) { |
560 | f2fs_put_page(page, 1); | 559 | f2fs_put_page(page, 1); |
561 | goto repeat; | 560 | goto repeat; |
562 | } | 561 | } |
@@ -841,11 +840,11 @@ repeat: | |||
841 | if (err) | 840 | if (err) |
842 | return err; | 841 | return err; |
843 | lock_page(page); | 842 | lock_page(page); |
844 | if (!PageUptodate(page)) { | 843 | if (unlikely(!PageUptodate(page))) { |
845 | f2fs_put_page(page, 1); | 844 | f2fs_put_page(page, 1); |
846 | return -EIO; | 845 | return -EIO; |
847 | } | 846 | } |
848 | if (page->mapping != mapping) { | 847 | if (unlikely(page->mapping != mapping)) { |
849 | f2fs_put_page(page, 1); | 848 | f2fs_put_page(page, 1); |
850 | goto repeat; | 849 | goto repeat; |
851 | } | 850 | } |