linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Qilong Zhang <zhangqilong3@huawei.com>
To: <yuchao0@huawei.com>, <jaegeuk@kernel.org>
Cc: zhangqilong3@huawei.com, linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH v1] f2fs: add f2fs_gc exception handle in f2fs_ioc_gc_range
Date: Tue, 23 Jun 2020 22:34:07 +0800	[thread overview]
Message-ID: <20200623143407.78400-1-zhangqilong3@huawei.com> (raw)

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

             reply	other threads:[~2020-06-23 14:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 14:34 Qilong Zhang [this message]
2020-06-24  2:44 ` [f2fs-dev] [PATCH v1] f2fs: add f2fs_gc exception handle in f2fs_ioc_gc_range Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200623143407.78400-1-zhangqilong3@huawei.com \
    --to=zhangqilong3@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).