linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v1] f2fs: add f2fs_gc exception handle in f2fs_ioc_gc_range
@ 2020-06-23 14:34 Qilong Zhang
  2020-06-24  2:44 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Qilong Zhang @ 2020-06-23 14:34 UTC (permalink / raw)
  To: yuchao0, jaegeuk; +Cc: zhangqilong3, linux-f2fs-devel

When f2fs_ioc_gc_range performs multiple segments gc ops, the return
value of f2fs_ioc_gc_range is determined by the last segment gc ops.
If its ops failed, the f2fs_ioc_gc_range will be considered to be failed
despite some of previous segments gc ops succeeded. Therefore, so we
fix: only all of segments gc ops are finished will return success. In
particular, 1).if target has no valid blopcks, it will go on. 2).if
target sectoion has valid blocks, but it is current segment, we will
reminder the caller.

Signed-off-by: Qilong Zhang <zhangqilong3@huawei.com>
---
v1:
- handle the -ENODATA exceptions of f2fs_gc.
 fs/f2fs/file.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 3268f8dd59bb..64415bd72ac4 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2527,6 +2527,18 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)
 	}
 
 	ret = f2fs_gc(sbi, range.sync, true, GET_SEGNO(sbi, range.start));
+	if (ret) {
+		if (ret == -ENODATA) {
+			if (IS_CURSEG(sbi, range.start)) {
+				/* it is opened, could try later*/
+				ret = -EBUSY;
+				goto out;
+			}
+		} else {
+			ret = -EAGAIN;
+			goto out;
+		}
+	}
 	range.start += BLKS_PER_SEC(sbi);
 	if (range.start <= end)
 		goto do_more;
-- 
2.17.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2020-06-24  2:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 14:34 [f2fs-dev] [PATCH v1] f2fs: add f2fs_gc exception handle in f2fs_ioc_gc_range Qilong Zhang
2020-06-24  2:44 ` Chao Yu

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).