Skip to contentSkip to conversation

f2fs: fix a last_victim overflow problem

PATCH In review Yunlei He 2 participants 2 messages Mar 22, 2017 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: fix a last_victim overflow problem

This patch fix a last_victim overflow problem

---
 fs/f2fs/gc.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/gc.c +2 -0
index 418fd98..3b5e799a 100644
@@ -361,6 +361,8 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
 				sbi->last_victim[p.gc_mode] = last_victim + 1;
 			else
 				sbi->last_victim[p.gc_mode] = segno + 1;
+
+			sbi->last_victim[p.gc_mode] %= MAIN_SEGS(sbi);
 			break;
 		}
 	}
Signature · 6 lines
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#1 lore raw

Hi Yunlei,

Have sent a patch for fixing this issue.

[PATCH 2/2] f2fs: fix recording invalid last_victim

Thanks,

Quoted 13 lines · Yunlei He

This patch fix a last_victim overflow problem

---
 fs/f2fs/gc.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/gc.c +0 -0
index 418fd98..3b5e799a 100644

fs/f2fs/gc.c static int get_victim_by_default(struct f2fs_sb_info *sbi, · line 368

Quoted 8 lines
fs/f2fs/gc.c +2 -0
@@ -361,6 +361,8 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
 				sbi->last_victim[p.gc_mode] = last_victim + 1;
 			else
 				sbi->last_victim[p.gc_mode] = segno + 1;
+
+			sbi->last_victim[p.gc_mode] %= MAIN_SEGS(sbi);
 			break;
 		}
 	}

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot