From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 4/4] f2fs_io: add gc_urgent
Date: Wed, 20 Feb 2019 09:07:45 -0800 [thread overview]
Message-ID: <20190220170745.7328-4-jaegeuk@kernel.org> (raw)
In-Reply-To: <20190220170745.7328-1-jaegeuk@kernel.org>
e.g.,
f2fs_io gc_urgent dm-4 [start/end/run] [time in sec]
This controls sysfs/gc_urgent to run f2fs_gc urgently.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
tools/f2fs_io/f2fs_io.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 70fde6e..cb28ff8 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -359,6 +359,40 @@ static void do_fiemap(int argc, char **argv, const struct cmd_desc *cmd)
exit(0);
}
+#define gc_urgent_desc "start/end/run gc_urgent for given time period"
+#define gc_urgent_help \
+"f2fs_io gc_urgent $dev [start/end/run] [time in sec]\n\n"\
+" - f2fs_io gc_urgent sda21 start\n" \
+" - f2fs_io gc_urgent sda21 end\n" \
+" - f2fs_io gc_urgent sda21 run 10\n" \
+
+static void do_gc_urgent(int argc, char **argv, const struct cmd_desc *cmd)
+{
+ char command[255];
+
+ if (argc == 3 && !strcmp(argv[2], "start")) {
+ printf("gc_urgent: start on %s\n", argv[1]);
+ sprintf(command, "echo %d > %s/%s/gc_urgent", 1, "/sys/fs/f2fs/", argv[1]);
+ system(command);
+ } else if (argc == 3 && !strcmp(argv[2], "end")) {
+ printf("gc_urgent: end on %s\n", argv[1]);
+ sprintf(command, "echo %d > %s/%s/gc_urgent", 0, "/sys/fs/f2fs/", argv[1]);
+ system(command);
+ } else if (argc == 4 && !strcmp(argv[2], "run")) {
+ printf("gc_urgent: start on %s for %d secs\n", argv[1], atoi(argv[3]));
+ sprintf(command, "echo %d > %s/%s/gc_urgent", 1, "/sys/fs/f2fs/", argv[1]);
+ system(command);
+ sleep(atoi(argv[3]));
+ printf("gc_urgent: end on %s for %d secs\n", argv[1], atoi(argv[3]));
+ sprintf(command, "echo %d > %s/%s/gc_urgent", 0, "/sys/fs/f2fs/", argv[1]);
+ system(command);
+ } else {
+ fputs("Excess arguments\n\n", stderr);
+ fputs(cmd->cmd_help, stderr);
+ exit(1);
+ }
+}
+
#define CMD_HIDDEN 0x0001
#define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 }
#define _CMD(name) { #name, do_##name, NULL, NULL, CMD_HIDDEN }
@@ -371,6 +405,7 @@ const struct cmd_desc cmd_list[] = {
CMD(write),
CMD(read),
CMD(fiemap),
+ CMD(gc_urgent),
{ NULL, NULL, NULL, NULL, 0 }
};
--
2.19.0.605.g01d371f741-goog
next prev parent reply other threads:[~2019-02-20 17:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 17:07 [PATCH 1/4] f2fs_io: add write Jaegeuk Kim
2019-02-20 17:07 ` [PATCH 2/4] f2fs_io: add read Jaegeuk Kim
2019-02-20 17:07 ` [PATCH 3/4] f2fs_io: add fiemap Jaegeuk Kim
2019-02-20 17:07 ` Jaegeuk Kim [this message]
2019-02-28 1:23 ` [PATCH 1/4] f2fs_io: add write Chao Yu
2019-02-28 3:12 ` Jaegeuk Kim
2019-02-28 1:35 ` Chao Yu
2019-02-28 3:11 ` Jaegeuk Kim
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=20190220170745.7328-4-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.