From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v5 3/8] btrfs-progs: dedup: Add disable support for inband deduplication
Date: Fri, 5 Feb 2016 09:22:59 +0800 [thread overview]
Message-ID: <1454635384-10106-4-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1454635384-10106-1-git-send-email-quwenruo@cn.fujitsu.com>
Add disable subcommand for dedup command group.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
Documentation/btrfs-dedup.asciidoc | 5 +++++
cmds-dedup.c | 42 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/Documentation/btrfs-dedup.asciidoc b/Documentation/btrfs-dedup.asciidoc
index aa378df..12ca91d 100644
--- a/Documentation/btrfs-dedup.asciidoc
+++ b/Documentation/btrfs-dedup.asciidoc
@@ -21,6 +21,11 @@ use with caution.
SUBCOMMAND
----------
+*disable* <path>::
+Disable in-band de-duplication for a filesystem.
++
+This will trash all stored dedup hash.
++
*enable* [options] <path>::
Enable in-band de-duplication for a filesystem.
+
diff --git a/cmds-dedup.c b/cmds-dedup.c
index 1da416f..c85bb5b 100644
--- a/cmds-dedup.c
+++ b/cmds-dedup.c
@@ -173,9 +173,51 @@ out:
return ret;
}
+static const char * const cmd_dedup_disable_usage[] = {
+ "btrfs dedup disable <path>",
+ "Disable in-band(write time) de-duplication of a btrfs.",
+ NULL
+};
+
+static int cmd_dedup_disable(int argc, char **argv)
+{
+ struct btrfs_ioctl_dedup_args dargs;
+ DIR *dirstream;
+ char *path;
+ int fd;
+ int ret;
+
+ if (check_argc_exact(argc, 2))
+ usage(cmd_dedup_disable_usage);
+
+ path = argv[1];
+ fd = open_file_or_dir(path, &dirstream);
+ if (fd < 0) {
+ error("failed to open file or directory: %s", path);
+ return 1;
+ }
+ memset(&dargs, 0, sizeof(dargs));
+ dargs.cmd = BTRFS_DEDUP_CTL_DISABLE;
+
+ ret = ioctl(fd, BTRFS_IOC_DEDUP_CTL, &dargs);
+ if (ret < 0) {
+ error("failed to disable inband deduplication: %s",
+ strerror(errno));
+ ret = 1;
+ goto out;
+ }
+ ret = 0;
+
+out:
+ close_file_or_dir(fd, dirstream);
+ return 0;
+}
+
const struct cmd_group dedup_cmd_group = {
dedup_cmd_group_usage, dedup_cmd_group_info, {
{ "enable", cmd_dedup_enable, cmd_dedup_enable_usage, NULL, 0},
+ { "disable", cmd_dedup_disable, cmd_dedup_disable_usage,
+ NULL, 0},
NULL_CMD_STRUCT
}
};
--
2.7.0
next prev parent reply other threads:[~2016-02-05 1:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 1:22 [PATCH v5 0/8] btrfs-progs: Support in-band de-duplication Qu Wenruo
2016-02-05 1:22 ` [PATCH v5 1/8] btrfs-progs: Basic framework for dedup command group Qu Wenruo
2016-02-05 1:22 ` [PATCH v5 2/8] btrfs-progs: dedup: Add enable command " Qu Wenruo
2016-02-05 1:22 ` Qu Wenruo [this message]
2016-02-05 1:23 ` [PATCH v5 4/8] btrfs-progs: dedup: Add status subcommand Qu Wenruo
2016-02-05 1:23 ` [PATCH v5 5/8] btrfs-progs: Add dedup feature for mkfs and convert Qu Wenruo
2016-02-05 1:23 ` [PATCH v5 6/8] btrfs-progs: Add show-super support for new DEDUP flag Qu Wenruo
2016-02-05 1:23 ` [PATCH v5 7/8] btrfs-progs: debug-tree: Add dedup tree support Qu Wenruo
2016-02-05 1:23 ` [PATCH v5 8/8] btrfs-progs: property: add a dedup property Qu Wenruo
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=1454635384-10106-4-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
/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).