Skip to contentSkip to conversation

f2fs: add a judgment in add_discard_addrs

PATCH In review Yunlei He 2 participants 5 messages Sep 8, 2015 – Sep 9, 2015 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: add a judgment in add_discard_addrs

CP_DISCARD traverse all segments in fstrim_range to add small discards, it is better to select entry->len bigger than trim_minlen.

---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 78e6d06..a0dab7a 100644
@@ -599,7 +599,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 			break;
 
 		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
-		__add_discard_entry(sbi, cpc, se, start, end);
+		if(force && cpc->trim_minlen >= (end - start))
+			__add_discard_entry(sbi, cpc, se, start, end);
 	}
 }
 
Signature · 4 lines
1.9.1


------------------------------------------------------------------------------
#1 lore raw

Hi Yunlei,

Quoted 9 lines

-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Tuesday, September 08, 2015 6:51 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He
Subject: [f2fs-dev] [PATCH] f2fs: add a judgment in add_discard_addrs

CP_DISCARD traverse all segments in fstrim_range to add small discards, it is better to select entry->len bigger than trim_minlen.

If we mount with 'discard' option, f2fs will trigger real-time discard when do checkpoint. If we add judgment condition here, fragmented invalid blocks will not be discarded since we stop adding them in pending list through __add_discard_entry.

Thanks,

Quoted 22 lines
---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -2
index 78e6d06..a0dab7a 100644
@@ -599,7 +599,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control
 *cpc)
 			break;
 
 		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
-		__add_discard_entry(sbi, cpc, se, start, end);
+		if(force && cpc->trim_minlen >= (end - start))
+			__add_discard_entry(sbi, cpc, se, start, end);
 	}
 }
 
--
Quoted 1 line

1.9.1

------------------------------------------------------------------------------

author
#2 lore raw
Quoted 9 lines · Chao Yu

Hi Yunlei,

Quoted 7 lines

-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Tuesday, September 08, 2015 6:51 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He
Subject: [f2fs-dev] [PATCH] f2fs: add a judgment in add_discard_addrs

Quoted 7 lines
Quoted 2 lines

CP_DISCARD traverse all segments in fstrim_range to add small discards, it is better to select entry->len bigger than trim_minlen.

If we mount with 'discard' option, f2fs will trigger real-time discard when do checkpoint. If we add judgment condition here, fragmented invalid blocks will not be discarded since we stop adding them in pending list through __add_discard_entry.

This judgment condition is only valid for cp reason CP_DISCARD, and has no influence to other checkpoint. The process of fstrim adds all invalid blocks in pending list and deletes entries which len < trim_minlen when issue discard. Can we do the selection when added?

Thanks,

Quoted 24 lines

Thanks,

Quoted 21 lines
---
  fs/f2fs/segment.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 78e6d06..a0dab7a 100644
@@ -599,7 +599,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control
 *cpc)
  			break;
 
  		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
-		__add_discard_entry(sbi, cpc, se, start, end);
+		if(force && cpc->trim_minlen >= (end - start))
+			__add_discard_entry(sbi, cpc, se, start, end);
  	}
  }
Quoted 5 lines
Quoted 2 lines

--
1.9.1

------------------------------------------------------------------------------

#3 lore raw
Quoted 25 lines

-----Original Message-----
From: He YunLei [mailto:[email protected]]
Sent: Wednesday, September 09, 2015 7:54 AM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: add a judgment in add_discard_addrs

Quoted 9 lines · Chao Yu

Hi Yunlei,

Quoted 7 lines

-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Tuesday, September 08, 2015 6:51 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He
Subject: [f2fs-dev] [PATCH] f2fs: add a judgment in add_discard_addrs

Quoted 7 lines
Quoted 2 lines

CP_DISCARD traverse all segments in fstrim_range to add small discards, it is better to select entry->len bigger than trim_minlen.

If we mount with 'discard' option, f2fs will trigger real-time discard when do checkpoint. If we add judgment condition here, fragmented invalid blocks will not be discarded since we stop adding them in pending list through __add_discard_entry.

Quoted 4 lines

This judgment condition is only valid for cp reason CP_DISCARD, and has no influence to other checkpoint. The process of fstrim adds all invalid blocks in pending list and deletes entries which len < trim_minlen when issue discard. Can we do the selection when added?

__add_discard_entry will try to merge small discards in pending list, and merged discard may be the eligible candidate, so we'd better not skip that.

Thanks,

Quoted 32 lines

Thanks,

Quoted 29 lines

Thanks,

Quoted 23 lines
---
  fs/f2fs/segment.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -2
index 78e6d06..a0dab7a 100644
@@ -599,7 +599,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control
 *cpc)
  			break;
 
  		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
-		__add_discard_entry(sbi, cpc, se, start, end);
+		if(force && cpc->trim_minlen >= (end - start))
+			__add_discard_entry(sbi, cpc, se, start, end);
  	}
  }
 
--

1.9.1

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140

author
#4 lore raw
Quoted 25 lines · Chao Yu
Quoted 25 lines

-----Original Message-----
From: He YunLei [mailto:[email protected]]
Sent: Wednesday, September 09, 2015 7:54 AM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: add a judgment in add_discard_addrs

Quoted 16 lines · Chao Yu

Hi Yunlei,

Quoted 9 lines

-----Original Message-----
From: Yunlei He [mailto:[email protected]]
Sent: Tuesday, September 08, 2015 6:51 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Yunlei He
Subject: [f2fs-dev] [PATCH] f2fs: add a judgment in add_discard_addrs

CP_DISCARD traverse all segments in fstrim_range to add small discards, it is better to select entry->len bigger than trim_minlen.

If we mount with 'discard' option, f2fs will trigger real-time discard when do checkpoint. If we add judgment condition here, fragmented invalid blocks will not be discarded since we stop adding them in pending list through __add_discard_entry.

Quoted 8 lines
Quoted 4 lines

This judgment condition is only valid for cp reason CP_DISCARD, and has no influence to other checkpoint. The process of fstrim adds all invalid blocks in pending list and deletes entries which len < trim_minlen when issue discard. Can we do the selection when added?

__add_discard_entry will try to merge small discards in pending list, and merged discard may be the eligible candidate, so we'd better not skip that.

Yeah, I got it. But I think the probability of merge will not be too high. Thanks,

Quoted 29 lines

Thanks,

Quoted 27 lines

Thanks,

Quoted 24 lines

Thanks,

Quoted 21 lines
---
   fs/f2fs/segment.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 78e6d06..a0dab7a 100644
@@ -599,7 +599,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control
 *cpc)
   			break;
 
   		end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
-		__add_discard_entry(sbi, cpc, se, start, end);
+		if(force && cpc->trim_minlen >= (end - start))
+			__add_discard_entry(sbi, cpc, se, start, end);
   	}
   }
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

--
1.9.1

.

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140