From: Andrew Mahone <andrew.mahone@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Andrew Mahone <andrew.mahone@gmail.com>
Subject: [PATCH 2/5] btrfs: lz4: add incompat flags and compression types
Date: Sat, 23 Jun 2012 04:05:45 -0400 [thread overview]
Message-ID: <1340438748-348-3-git-send-email-andrew.mahone@gmail.com> (raw)
In-Reply-To: <1340438748-348-1-git-send-email-andrew.mahone@gmail.com>
Signed-off-by: Andrew Mahone <andrew.mahone@gmail.com>
---
fs/btrfs/ctree.h | 16 ++++++++++++----
fs/btrfs/disk-io.c | 4 ++++
fs/btrfs/ioctl.c | 5 +++++
fs/btrfs/super.c | 22 +++++++++++++++++++++-
4 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index fa5c45b..6d59831 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -478,7 +478,12 @@ struct btrfs_super_block {
* Note we don't actually support it, we're just reserving the
* number
*/
-#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZOv2 (1ULL << 4)
+/*
+ * This covers adding LZ4 in real-time and high-compression modes
+ *
+ * TODO: cover also the other container formats
+ */
+#define BTRFS_FEATURE_INCOMPAT_COMPRESSION_LZ4 (1ULL << 4)
/*
* older kernels tried to do bigger metadata blocks, but the
@@ -492,8 +497,9 @@ struct btrfs_super_block {
(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
+ BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \
- BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO)
+ BTRFS_FEATURE_INCOMPAT_COMPRESSION_LZ4)
/*
* A leaf is full of items. offset and size tell us where to find
@@ -649,8 +655,10 @@ enum btrfs_compression_type {
BTRFS_COMPRESS_NONE = 0,
BTRFS_COMPRESS_ZLIB = 1,
BTRFS_COMPRESS_LZO = 2,
- BTRFS_COMPRESS_TYPES = 2,
- BTRFS_COMPRESS_LAST = 3,
+ BTRFS_COMPRESS_LZ4 = 3,
+ BTRFS_COMPRESS_LZ4HC = 4,
+ BTRFS_COMPRESS_TYPES = 5,
+ BTRFS_COMPRESS_LAST = 5,
};
struct btrfs_inode_item {
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 7b845ff..20f7632 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2121,6 +2121,10 @@ int open_ctree(struct super_block *sb,
features |= BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF;
if (tree_root->fs_info->compress_type == BTRFS_COMPRESS_LZO)
features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO;
+ if (tree_root->fs_info->compress_type == BTRFS_COMPRESS_LZ4)
+ features |= BTRFS_FEATURE_INCOMPAT_COMPRESSION_LZ4;
+ if (tree_root->fs_info->compress_type == BTRFS_COMPRESS_LZ4HC)
+ features |= BTRFS_FEATURE_INCOMPAT_COMPRESSION_LZ4;
/*
* flag our filesystem as having big metadata blocks if
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9ec23b9..bc92da4 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1245,6 +1245,11 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO;
btrfs_set_super_incompat_flags(disk_super, features);
}
+ if (range->compress_type == BTRFS_COMPRESS_LZ4 ||
+ range->compress_type == BTRFS_COMPRESS_LZ4) {
+ features |= BTRFS_FEATURE_INCOMPAT_COMPRESSION_LZ4;
+ btrfs_set_super_incompat_flags(disk_super, features);
+ }
ret = defrag_count;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 23fc7e8..5824886 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -401,6 +401,20 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
compress_type = "lzo";
info->compress_type = BTRFS_COMPRESS_LZO;
btrfs_set_opt(info->mount_opt, COMPRESS);
+ } else if (strcmp(args[0].from, "lz4") == 0) {
+ compress_type = "lz4";
+ info->compress_type = BTRFS_COMPRESS_LZ4;
+ btrfs_set_opt(info->mount_opt, COMPRESS);
+ /* remove when implemented */
+ ret = -EINVAL;
+ goto out;
+ } else if (strcmp(args[0].from, "lz4hc") == 0) {
+ compress_type = "lz4hc";
+ info->compress_type = BTRFS_COMPRESS_LZ4HC;
+ btrfs_set_opt(info->mount_opt, COMPRESS);
+ /* remove when implemented */
+ ret = -EINVAL;
+ goto out;
} else if (strncmp(args[0].from, "no", 2) == 0) {
compress_type = "no";
info->compress_type = BTRFS_COMPRESS_NONE;
@@ -856,8 +870,14 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
if (btrfs_test_opt(root, COMPRESS)) {
if (info->compress_type == BTRFS_COMPRESS_ZLIB)
compress_type = "zlib";
- else
+ else if (info->compress_type == BTRFS_COMPRESS_LZ4)
+ compress_type = "lz4";
+ else if (info->compress_type == BTRFS_COMPRESS_LZ4HC)
+ compress_type = "lz4hc";
+ else if (info->compress_type == BTRFS_COMPRESS_LZO)
compress_type = "lzo";
+ else
+ compress_type = "none";
if (btrfs_test_opt(root, FORCE_COMPRESS))
seq_printf(seq, ",compress-force=%s", compress_type);
else
--
1.7.11
next prev parent reply other threads:[~2012-06-23 8:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-23 8:05 [PATCH 0/5] btrfs: lz4/lz4hc compression Andrew Mahone
2012-06-23 8:05 ` [PATCH 1/5] btrfs: lz4: import lz4/lz4hc C and header files Andrew Mahone
2012-06-23 8:05 ` Andrew Mahone [this message]
2012-06-23 20:21 ` [PATCH 2/5] btrfs: lz4: add incompat flags and compression types Andrew Mahone
2012-06-23 8:05 ` [PATCH 3/5] btrfs: lz4: add lz4_wrapper implementing btrfs compression interface Andrew Mahone
2012-06-23 8:05 ` [PATCH 4/5] btrfs: lz4: add lz4 files in Makefile Andrew Mahone
2012-06-23 8:05 ` [PATCH 5/5] btrfs: enable lz4/lz4hc compression Andrew Mahone
2012-06-25 13:19 ` [PATCH 0/5] btrfs: " David Sterba
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=1340438748-348-3-git-send-email-andrew.mahone@gmail.com \
--to=andrew.mahone@gmail.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).