From: Liu Bo <bo.li.liu@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Btrfs-progs: add dedup register
Date: Thu, 2 May 2013 00:27:39 +0800 [thread overview]
Message-ID: <1367425659-10803-4-git-send-email-bo.li.liu@oracle.com> (raw)
In-Reply-To: <1367425659-10803-1-git-send-email-bo.li.liu@oracle.com>
This aims to add 'btrfs filesystem dedup-register', and it can be used
to enable dedup on a filesystem.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
cmds-filesystem.c | 36 ++++++++++++++++++++++++++++++++++++
ioctl.h | 1 +
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 3f386e2..aa21cf6 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -515,6 +515,41 @@ static int cmd_label(int argc, char **argv)
return get_label(argv[1]);
}
+static const char * const cmd_dedup_usage[] = {
+ "btrfs filesystem dedup-register <path>",
+ "Register a dedup tree",
+ NULL
+};
+
+static int cmd_dedup(int argc, char **argv)
+{
+ int fd, res, e;
+ char *path;
+
+ if (check_argc_exact(argc, 2))
+ usage(cmd_dedup_usage);
+
+ path = argv[1];
+
+ fd = open_file_or_dir(path);
+ if (fd < 0) {
+ fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+ return 12;
+ }
+
+ printf("register dedup on '%s'\n", path);
+ res = ioctl(fd, BTRFS_IOC_DEDUP_REGISTER);
+ e = errno;
+ close(fd);
+ if( res < 0 ){
+ fprintf(stderr, "ERROR: unable to register dedup '%s' - %s\n",
+ path, strerror(e));
+ return 32;
+ }
+
+ return 0;
+}
+
const struct cmd_group filesystem_cmd_group = {
filesystem_cmd_group_usage, NULL, {
{ "df", cmd_df, cmd_df_usage, NULL, 0 },
@@ -524,6 +559,7 @@ const struct cmd_group filesystem_cmd_group = {
{ "balance", cmd_balance, NULL, &balance_cmd_group, 1 },
{ "resize", cmd_resize, cmd_resize_usage, NULL, 0 },
{ "label", cmd_label, cmd_label_usage, NULL, 0 },
+ { "dedup-register", cmd_dedup, cmd_dedup_usage, NULL, 0 },
{ 0, 0, 0, 0, 0 },
}
};
diff --git a/ioctl.h b/ioctl.h
index e841913..1bea98a 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -528,6 +528,7 @@ struct btrfs_ioctl_clone_range_args {
struct btrfs_ioctl_get_dev_stats)
#define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
struct btrfs_ioctl_dev_replace_args)
+#define BTRFS_IOC_DEDUP_REGISTER _IO(BTRFS_IOCTL_MAGIC, 54)
#ifdef __cplusplus
}
--
1.7.7
next prev parent reply other threads:[~2013-05-01 16:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 16:27 [RFC PATCH v3 0/2] Online data deduplication Liu Bo
2013-05-01 16:27 ` [PATCH v3 1/2] Btrfs: skip merge part for delayed data refs Liu Bo
2013-05-01 16:27 ` [PATCH v3 2/2] Btrfs: online data deduplication Liu Bo
2013-05-01 17:30 ` Josef Bacik
2013-05-01 18:07 ` Gabriel de Perthuis
2013-05-01 16:27 ` Liu Bo [this message]
2013-05-13 15:55 ` [PATCH] Btrfs-progs: add dedup register David Sterba
2013-05-14 0:29 ` Liu Bo
2013-05-01 17:37 ` [RFC PATCH v3 0/2] Online data deduplication Josef Bacik
2013-05-03 7:54 ` Liu Bo
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=1367425659-10803-4-git-send-email-bo.li.liu@oracle.com \
--to=bo.li.liu@oracle.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).