linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] f2fs: fix a missing discard prefree segments
@ 2016-12-20  3:11 Yunlei He
  2016-12-20  3:11 ` [PATCH 2/2 v2] f2fs: add a case of no need to read a page in write begin Yunlei He
  2016-12-21  2:02 ` [PATCH 1/2 v2] f2fs: fix a missing discard prefree segments Chao Yu
  0 siblings, 2 replies; 10+ messages in thread
From: Yunlei He @ 2016-12-20  3:11 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei

If userspace issue a fstrim with a range not involve prefree segments,
it will reuse these segments without discard. This patch fix it.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fs/f2fs/segment.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0738f48..a40a34b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -916,7 +916,11 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
 		dirty_i->nr_dirty[PRE] -= end - start;
 
-		if (force || !test_opt(sbi, DISCARD))
+		if (!test_opt(sbi, DISCARD))
+			continue;
+
+		if (force && start * sbi->blocks_per_seg >= cpc->trim_start &&
+						end * sbi->blocks_per_seg <= cpc->trim_end)
 			continue;
 
 		if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) {
-- 
2.10.1


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-12-21 17:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-20  3:11 [PATCH 1/2 v2] f2fs: fix a missing discard prefree segments Yunlei He
2016-12-20  3:11 ` [PATCH 2/2 v2] f2fs: add a case of no need to read a page in write begin Yunlei He
2016-12-20 18:03   ` Jaegeuk Kim
2016-12-21  1:28     ` Chao Yu
2016-12-21 17:58       ` Jaegeuk Kim
2016-12-21  2:02 ` [PATCH 1/2 v2] f2fs: fix a missing discard prefree segments Chao Yu
2016-12-21  2:27   ` Chao Yu
2016-12-21  3:35     ` heyunlei
2016-12-21  3:55       ` Chao Yu
2016-12-21  9:00         ` heyunlei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).