Skip to contentSkip to conversation

f2fs: fix to issue small discard in real-time mode discard

PATCH In review Chao Yu 2 participants 2 messages Feb 28, 2015 – Mar 2, 2015 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: fix to issue small discard in real-time mode discard

Now in f2fs, we share functions and structures for batch mode and real-time mode discard. For real-time mode discard, in shared function add_discard_addrs, we will use uninitialized trim_minlen in struct cp_control to compare with length of contiguous free blocks to decide whether skipping discard fragmented freespace or not, this makes us ignore small discard sometimes. Fix it.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
index daee4ab..fcc1cc2 100644
@@ -549,7 +549,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
 		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
 
-		if (end - start < cpc->trim_minlen)
+		if (force && end - start < cpc->trim_minlen)
 			continue;
 
 		__add_discard_entry(sbi, cpc, start, end);
Signature · 1 line
2.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Chao Yu

Now in f2fs, we share functions and structures for batch mode and real-time mode discard. For real-time mode discard, in shared function add_discard_addrs, we will use uninitialized trim_minlen in struct cp_control to compare with length of contiguous free blocks to decide whether skipping discard fragmented freespace or not, this makes us ignore small discard sometimes. Fix it.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index daee4ab..fcc1cc2 100644

fs/f2fs/segment.c static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 553

Quoted 6 lines
fs/f2fs/segment.c +1 -1
@@ -549,7 +549,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
 		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
 
-		if (end - start < cpc->trim_minlen)
+		if (force && end - start < cpc->trim_minlen)
 			continue;
Quoted 5 lines
fs/f2fs/segment.c +0 -0
 		__add_discard_entry(sbi, cpc, start, end);
Signature · 1 line
2.3.1