diff options
author | Chao Yu <chao2.yu@samsung.com> | 2014-08-03 22:10:07 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-08-04 16:20:53 -0400 |
commit | b65ee14818e67127aa242fe1dbd3711b9c095cc0 (patch) | |
tree | 7784dd17a2672c2e5860e5c2418b79e4245690be /fs/f2fs/segment.c | |
parent | 497a0930bb4bd148451e1af239a082e3916b681b (diff) |
f2fs: use for_each_set_bit to simplify the code
This patch uses for_each_set_bit to simplify some codes in f2fs.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index c3b76d091450..0dfeebae2a50 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -439,17 +439,12 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, | |||
439 | static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi) | 439 | static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi) |
440 | { | 440 | { |
441 | struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); | 441 | struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); |
442 | unsigned int segno = -1; | 442 | unsigned int segno; |
443 | unsigned int total_segs = TOTAL_SEGS(sbi); | 443 | unsigned int total_segs = TOTAL_SEGS(sbi); |
444 | 444 | ||
445 | mutex_lock(&dirty_i->seglist_lock); | 445 | mutex_lock(&dirty_i->seglist_lock); |
446 | while (1) { | 446 | for_each_set_bit(segno, dirty_i->dirty_segmap[PRE], total_segs) |
447 | segno = find_next_bit(dirty_i->dirty_segmap[PRE], total_segs, | ||
448 | segno + 1); | ||
449 | if (segno >= total_segs) | ||
450 | break; | ||
451 | __set_test_and_free(sbi, segno); | 447 | __set_test_and_free(sbi, segno); |
452 | } | ||
453 | mutex_unlock(&dirty_i->seglist_lock); | 448 | mutex_unlock(&dirty_i->seglist_lock); |
454 | } | 449 | } |
455 | 450 | ||
@@ -1531,7 +1526,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi) | |||
1531 | struct page *page = NULL; | 1526 | struct page *page = NULL; |
1532 | struct f2fs_sit_block *raw_sit = NULL; | 1527 | struct f2fs_sit_block *raw_sit = NULL; |
1533 | unsigned int start = 0, end = 0; | 1528 | unsigned int start = 0, end = 0; |
1534 | unsigned int segno = -1; | 1529 | unsigned int segno; |
1535 | bool flushed; | 1530 | bool flushed; |
1536 | 1531 | ||
1537 | mutex_lock(&curseg->curseg_mutex); | 1532 | mutex_lock(&curseg->curseg_mutex); |
@@ -1543,7 +1538,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi) | |||
1543 | */ | 1538 | */ |
1544 | flushed = flush_sits_in_journal(sbi); | 1539 | flushed = flush_sits_in_journal(sbi); |
1545 | 1540 | ||
1546 | while ((segno = find_next_bit(bitmap, nsegs, segno + 1)) < nsegs) { | 1541 | for_each_set_bit(segno, bitmap, nsegs) { |
1547 | struct seg_entry *se = get_seg_entry(sbi, segno); | 1542 | struct seg_entry *se = get_seg_entry(sbi, segno); |
1548 | int sit_offset, offset; | 1543 | int sit_offset, offset; |
1549 | 1544 | ||