diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-03-30 23:39:49 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-04-03 03:23:10 -0400 |
commit | 53cf95222fad7a962cc03fb61a33e37bcf4f5c9d (patch) | |
tree | d908690ba50571d23a55bcb788d8b1c4cd92c5b6 /fs/f2fs | |
parent | 5c773ba33a29c0dcddac7cfaa39fc63a7137130d (diff) |
f2fs: introduce TOTAL_SECS macro
Let's use a macro to get the total number of sections.
Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/debug.c | 7 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 19 | ||||
-rw-r--r-- | fs/f2fs/segment.h | 1 |
3 files changed, 13 insertions, 14 deletions
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 025b9e2f935d..20b8794ec8f6 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c | |||
@@ -106,7 +106,7 @@ static void update_sit_info(struct f2fs_sb_info *sbi) | |||
106 | } | 106 | } |
107 | } | 107 | } |
108 | mutex_unlock(&sit_i->sentry_lock); | 108 | mutex_unlock(&sit_i->sentry_lock); |
109 | dist = sbi->total_sections * hblks_per_sec * hblks_per_sec / 100; | 109 | dist = TOTAL_SECS(sbi) * hblks_per_sec * hblks_per_sec / 100; |
110 | si->bimodal = bimodal / dist; | 110 | si->bimodal = bimodal / dist; |
111 | if (si->dirty_count) | 111 | if (si->dirty_count) |
112 | si->avg_vblocks = total_vblocks / ndirty; | 112 | si->avg_vblocks = total_vblocks / ndirty; |
@@ -138,14 +138,13 @@ static void update_mem_info(struct f2fs_sb_info *sbi) | |||
138 | si->base_mem += f2fs_bitmap_size(TOTAL_SEGS(sbi)); | 138 | si->base_mem += f2fs_bitmap_size(TOTAL_SEGS(sbi)); |
139 | si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * TOTAL_SEGS(sbi); | 139 | si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * TOTAL_SEGS(sbi); |
140 | if (sbi->segs_per_sec > 1) | 140 | if (sbi->segs_per_sec > 1) |
141 | si->base_mem += sbi->total_sections * | 141 | si->base_mem += TOTAL_SECS(sbi) * sizeof(struct sec_entry); |
142 | sizeof(struct sec_entry); | ||
143 | si->base_mem += __bitmap_size(sbi, SIT_BITMAP); | 142 | si->base_mem += __bitmap_size(sbi, SIT_BITMAP); |
144 | 143 | ||
145 | /* build free segmap */ | 144 | /* build free segmap */ |
146 | si->base_mem += sizeof(struct free_segmap_info); | 145 | si->base_mem += sizeof(struct free_segmap_info); |
147 | si->base_mem += f2fs_bitmap_size(TOTAL_SEGS(sbi)); | 146 | si->base_mem += f2fs_bitmap_size(TOTAL_SEGS(sbi)); |
148 | si->base_mem += f2fs_bitmap_size(sbi->total_sections); | 147 | si->base_mem += f2fs_bitmap_size(TOTAL_SECS(sbi)); |
149 | 148 | ||
150 | /* build curseg */ | 149 | /* build curseg */ |
151 | si->base_mem += sizeof(struct curseg_info) * NR_CURSEG_TYPE; | 150 | si->base_mem += sizeof(struct curseg_info) * NR_CURSEG_TYPE; |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 17581495bafb..179a13e86f69 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -348,9 +348,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, | |||
348 | unsigned int *newseg, bool new_sec, int dir) | 348 | unsigned int *newseg, bool new_sec, int dir) |
349 | { | 349 | { |
350 | struct free_segmap_info *free_i = FREE_I(sbi); | 350 | struct free_segmap_info *free_i = FREE_I(sbi); |
351 | unsigned int total_secs = sbi->total_sections; | ||
352 | unsigned int segno, secno, zoneno; | 351 | unsigned int segno, secno, zoneno; |
353 | unsigned int total_zones = sbi->total_sections / sbi->secs_per_zone; | 352 | unsigned int total_zones = TOTAL_SECS(sbi) / sbi->secs_per_zone; |
354 | unsigned int hint = *newseg / sbi->segs_per_sec; | 353 | unsigned int hint = *newseg / sbi->segs_per_sec; |
355 | unsigned int old_zoneno = GET_ZONENO_FROM_SEGNO(sbi, *newseg); | 354 | unsigned int old_zoneno = GET_ZONENO_FROM_SEGNO(sbi, *newseg); |
356 | unsigned int left_start = hint; | 355 | unsigned int left_start = hint; |
@@ -367,12 +366,12 @@ static void get_new_segment(struct f2fs_sb_info *sbi, | |||
367 | goto got_it; | 366 | goto got_it; |
368 | } | 367 | } |
369 | find_other_zone: | 368 | find_other_zone: |
370 | secno = find_next_zero_bit(free_i->free_secmap, total_secs, hint); | 369 | secno = find_next_zero_bit(free_i->free_secmap, TOTAL_SECS(sbi), hint); |
371 | if (secno >= total_secs) { | 370 | if (secno >= TOTAL_SECS(sbi)) { |
372 | if (dir == ALLOC_RIGHT) { | 371 | if (dir == ALLOC_RIGHT) { |
373 | secno = find_next_zero_bit(free_i->free_secmap, | 372 | secno = find_next_zero_bit(free_i->free_secmap, |
374 | total_secs, 0); | 373 | TOTAL_SECS(sbi), 0); |
375 | BUG_ON(secno >= total_secs); | 374 | BUG_ON(secno >= TOTAL_SECS(sbi)); |
376 | } else { | 375 | } else { |
377 | go_left = 1; | 376 | go_left = 1; |
378 | left_start = hint - 1; | 377 | left_start = hint - 1; |
@@ -387,8 +386,8 @@ find_other_zone: | |||
387 | continue; | 386 | continue; |
388 | } | 387 | } |
389 | left_start = find_next_zero_bit(free_i->free_secmap, | 388 | left_start = find_next_zero_bit(free_i->free_secmap, |
390 | total_secs, 0); | 389 | TOTAL_SECS(sbi), 0); |
391 | BUG_ON(left_start >= total_secs); | 390 | BUG_ON(left_start >= TOTAL_SECS(sbi)); |
392 | break; | 391 | break; |
393 | } | 392 | } |
394 | secno = left_start; | 393 | secno = left_start; |
@@ -1390,7 +1389,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi) | |||
1390 | } | 1389 | } |
1391 | 1390 | ||
1392 | if (sbi->segs_per_sec > 1) { | 1391 | if (sbi->segs_per_sec > 1) { |
1393 | sit_i->sec_entries = vzalloc(sbi->total_sections * | 1392 | sit_i->sec_entries = vzalloc(TOTAL_SECS(sbi) * |
1394 | sizeof(struct sec_entry)); | 1393 | sizeof(struct sec_entry)); |
1395 | if (!sit_i->sec_entries) | 1394 | if (!sit_i->sec_entries) |
1396 | return -ENOMEM; | 1395 | return -ENOMEM; |
@@ -1441,7 +1440,7 @@ static int build_free_segmap(struct f2fs_sb_info *sbi) | |||
1441 | if (!free_i->free_segmap) | 1440 | if (!free_i->free_segmap) |
1442 | return -ENOMEM; | 1441 | return -ENOMEM; |
1443 | 1442 | ||
1444 | sec_bitmap_size = f2fs_bitmap_size(sbi->total_sections); | 1443 | sec_bitmap_size = f2fs_bitmap_size(TOTAL_SECS(sbi)); |
1445 | free_i->free_secmap = kmalloc(sec_bitmap_size, GFP_KERNEL); | 1444 | free_i->free_secmap = kmalloc(sec_bitmap_size, GFP_KERNEL); |
1446 | if (!free_i->free_secmap) | 1445 | if (!free_i->free_secmap) |
1447 | return -ENOMEM; | 1446 | return -ENOMEM; |
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index c0d774076ab9..fea9245d4774 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h | |||
@@ -81,6 +81,7 @@ | |||
81 | #define f2fs_bitmap_size(nr) \ | 81 | #define f2fs_bitmap_size(nr) \ |
82 | (BITS_TO_LONGS(nr) * sizeof(unsigned long)) | 82 | (BITS_TO_LONGS(nr) * sizeof(unsigned long)) |
83 | #define TOTAL_SEGS(sbi) (SM_I(sbi)->main_segments) | 83 | #define TOTAL_SEGS(sbi) (SM_I(sbi)->main_segments) |
84 | #define TOTAL_SECS(sbi) (sbi->total_sections) | ||
84 | 85 | ||
85 | #define SECTOR_FROM_BLOCK(sbi, blk_addr) \ | 86 | #define SECTOR_FROM_BLOCK(sbi, blk_addr) \ |
86 | (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) | 87 | (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) |