aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r--fs/f2fs/gc.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 644aa3808273..b0ec721e984a 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -390,9 +390,7 @@ next_step:
390 } 390 }
391 391
392 err = check_valid_map(sbi, segno, off); 392 err = check_valid_map(sbi, segno, off);
393 if (err == GC_ERROR) 393 if (err == GC_NEXT)
394 return err;
395 else if (err == GC_NEXT)
396 continue; 394 continue;
397 395
398 if (initial) { 396 if (initial) {
@@ -430,28 +428,22 @@ next_step:
430 */ 428 */
431block_t start_bidx_of_node(unsigned int node_ofs) 429block_t start_bidx_of_node(unsigned int node_ofs)
432{ 430{
433 block_t start_bidx; 431 unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4;
434 unsigned int bidx, indirect_blks; 432 unsigned int bidx;
435 int dec;
436 433
437 indirect_blks = 2 * NIDS_PER_BLOCK + 4; 434 if (node_ofs == 0)
435 return 0;
438 436
439 start_bidx = 1; 437 if (node_ofs <= 2) {
440 if (node_ofs == 0) {
441 start_bidx = 0;
442 } else if (node_ofs <= 2) {
443 bidx = node_ofs - 1; 438 bidx = node_ofs - 1;
444 } else if (node_ofs <= indirect_blks) { 439 } else if (node_ofs <= indirect_blks) {
445 dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1); 440 int dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1);
446 bidx = node_ofs - 2 - dec; 441 bidx = node_ofs - 2 - dec;
447 } else { 442 } else {
448 dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1); 443 int dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1);
449 bidx = node_ofs - 5 - dec; 444 bidx = node_ofs - 5 - dec;
450 } 445 }
451 446 return bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE;
452 if (start_bidx)
453 start_bidx = bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE;
454 return start_bidx;
455} 447}
456 448
457static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, 449static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
@@ -556,9 +548,7 @@ next_step:
556 } 548 }
557 549
558 err = check_valid_map(sbi, segno, off); 550 err = check_valid_map(sbi, segno, off);
559 if (err == GC_ERROR) 551 if (err == GC_NEXT)
560 goto stop;
561 else if (err == GC_NEXT)
562 continue; 552 continue;
563 553
564 if (phase == 0) { 554 if (phase == 0) {
@@ -568,9 +558,7 @@ next_step:
568 558
569 /* Get an inode by ino with checking validity */ 559 /* Get an inode by ino with checking validity */
570 err = check_dnode(sbi, entry, &dni, start_addr + off, &nofs); 560 err = check_dnode(sbi, entry, &dni, start_addr + off, &nofs);
571 if (err == GC_ERROR) 561 if (err == GC_NEXT)
572 goto stop;
573 else if (err == GC_NEXT)
574 continue; 562 continue;
575 563
576 if (phase == 1) { 564 if (phase == 1) {