All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mitch Harder <mitch.harder@sabayonlinux.org>
To: linux-btrfs@vger.kernel.org
Cc: Mitch Harder <mitch.harder@sabayonlinux.org>
Subject: [PATCH 1/2] Btrfs: Check INCOMPAT flags on remount with lzo compression
Date: Fri, 20 Jul 2012 12:36:20 -0500	[thread overview]
Message-ID: <1342805781-12162-2-git-send-email-mitch.harder@sabayonlinux.org> (raw)
In-Reply-To: <1342805781-12162-1-git-send-email-mitch.harder@sabayonlinux.org>

In support of the recently added capability to remount with lzo
compression, check the compression INCOMPAT flags when remounting
with lzo compression, and set the flags if necessary.

Signed-off-by: Mitch Harder <mitch.harder@sabayonlinux.org>
---
 fs/btrfs/ctree.h |    1 +
 fs/btrfs/super.c |   21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a0ee2f8..8bee032 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3094,6 +3094,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 
 /* super.c */
 int btrfs_parse_options(struct btrfs_root *root, char *options);
+void btrfs_chk_lzo_incompat(struct btrfs_root *root);
 int btrfs_sync_fs(struct super_block *sb, int wait);
 void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...);
 void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 26da344..4398fd2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -401,11 +401,13 @@ 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);
+				btrfs_chk_lzo_incompat(root);
 			} else if (strncmp(args[0].from, "no", 2) == 0) {
 				compress_type = "no";
 				info->compress_type = BTRFS_COMPRESS_NONE;
 				btrfs_clear_opt(info->mount_opt, COMPRESS);
-				btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
+				btrfs_clear_opt(info->mount_opt,
+						FORCE_COMPRESS);
 				compress_force = false;
 			} else {
 				ret = -EINVAL;
@@ -587,6 +589,23 @@ out:
 }
 
 /*
+ * Check the INCOMPAT features in the super block, and set the
+ * LZO INCOMPAT flag if it has not been set.
+ */
+void btrfs_chk_lzo_incompat(struct btrfs_root *root)
+{
+	struct btrfs_super_block *disk_super;
+	u64 features;
+
+	disk_super = root->fs_info->super_copy;
+	features = btrfs_super_incompat_flags(disk_super);
+	if (!(features & BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO)) {
+		features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO;
+		btrfs_set_super_incompat_flags(disk_super, features);
+	}
+}
+
+/*
  * Parse mount options that are required early in the mount process.
  *
  * All other options will be parsed on much later in the mount process and
-- 
1.7.8.6


  reply	other threads:[~2012-07-20 17:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 17:36 [PATCH 0/2] LZO INCOMPAT Checking Mitch Harder
2012-07-20 17:36 ` Mitch Harder [this message]
2012-07-20 17:39   ` [PATCH 1/2] Btrfs: Check INCOMPAT flags on remount with lzo compression Josef Bacik
2012-07-20 17:36 ` [PATCH 2/2] Btrfs: Use common function to check lzo INCOMPAT on defrag Mitch Harder

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=1342805781-12162-2-git-send-email-mitch.harder@sabayonlinux.org \
    --to=mitch.harder@sabayonlinux.org \
    --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 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.