aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMitch Harder <mitch.harder@sabayonlinux.org>2012-07-24 13:58:43 -0400
committerChris Mason <chris.mason@fusionio.com>2012-07-25 16:14:31 -0400
commit2b0ce2c2909368d124a78a88e5c7106fdcba6221 (patch)
tree8a8e2f4de870c73174b9720d25f69e4ad5f27608 /fs/btrfs
parentb478b2baa37ac99fc04a30809c780dd5dfd43595 (diff)
Btrfs: Check INCOMPAT flags on remount and add helper function
In support of the recently added capability to remount with lzo compression, provide a helper function to check the compression INCOMPAT flags when remounting with lzo compression, and set the flags if necessary. Also, implement the new helper function when defragmenting with explicit lzo compression and when setting the default subvolume. Signed-off-by: Mitch Harder <mitch.harder@sabayonlinux.org> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ctree.h17
-rw-r--r--fs/btrfs/ioctl.c16
-rw-r--r--fs/btrfs/super.c1
3 files changed, 20 insertions, 14 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 00f9a50f986d..0f369da5cd97 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3288,6 +3288,23 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
3288 struct btrfs_root *root, const char *function, 3288 struct btrfs_root *root, const char *function,
3289 unsigned int line, int errno); 3289 unsigned int line, int errno);
3290 3290
3291#define btrfs_set_fs_incompat(__fs_info, opt) \
3292 __btrfs_set_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
3293
3294static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
3295 u64 flag)
3296{
3297 struct btrfs_super_block *disk_super;
3298 u64 features;
3299
3300 disk_super = fs_info->super_copy;
3301 features = btrfs_super_incompat_flags(disk_super);
3302 if (!(features & flag)) {
3303 features |= flag;
3304 btrfs_set_super_incompat_flags(disk_super, features);
3305 }
3306}
3307
3291#define btrfs_abort_transaction(trans, root, errno) \ 3308#define btrfs_abort_transaction(trans, root, errno) \
3292do { \ 3309do { \
3293 __btrfs_abort_transaction(trans, root, __func__, \ 3310 __btrfs_abort_transaction(trans, root, __func__, \
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e54b663fd3aa..3f3cbe928a1a 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1053,11 +1053,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
1053 u64 newer_than, unsigned long max_to_defrag) 1053 u64 newer_than, unsigned long max_to_defrag)
1054{ 1054{
1055 struct btrfs_root *root = BTRFS_I(inode)->root; 1055 struct btrfs_root *root = BTRFS_I(inode)->root;
1056 struct btrfs_super_block *disk_super;
1057 struct file_ra_state *ra = NULL; 1056 struct file_ra_state *ra = NULL;
1058 unsigned long last_index; 1057 unsigned long last_index;
1059 u64 isize = i_size_read(inode); 1058 u64 isize = i_size_read(inode);
1060 u64 features;
1061 u64 last_len = 0; 1059 u64 last_len = 0;
1062 u64 skip = 0; 1060 u64 skip = 0;
1063 u64 defrag_end = 0; 1061 u64 defrag_end = 0;
@@ -1244,11 +1242,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
1244 mutex_unlock(&inode->i_mutex); 1242 mutex_unlock(&inode->i_mutex);
1245 } 1243 }
1246 1244
1247 disk_super = root->fs_info->super_copy;
1248 features = btrfs_super_incompat_flags(disk_super);
1249 if (range->compress_type == BTRFS_COMPRESS_LZO) { 1245 if (range->compress_type == BTRFS_COMPRESS_LZO) {
1250 features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO; 1246 btrfs_set_fs_incompat(root->fs_info, COMPRESS_LZO);
1251 btrfs_set_super_incompat_flags(disk_super, features);
1252 } 1247 }
1253 1248
1254 ret = defrag_count; 1249 ret = defrag_count;
@@ -2784,8 +2779,6 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
2784 struct btrfs_path *path; 2779 struct btrfs_path *path;
2785 struct btrfs_key location; 2780 struct btrfs_key location;
2786 struct btrfs_disk_key disk_key; 2781 struct btrfs_disk_key disk_key;
2787 struct btrfs_super_block *disk_super;
2788 u64 features;
2789 u64 objectid = 0; 2782 u64 objectid = 0;
2790 u64 dir_id; 2783 u64 dir_id;
2791 2784
@@ -2836,12 +2829,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
2836 btrfs_mark_buffer_dirty(path->nodes[0]); 2829 btrfs_mark_buffer_dirty(path->nodes[0]);
2837 btrfs_free_path(path); 2830 btrfs_free_path(path);
2838 2831
2839 disk_super = root->fs_info->super_copy; 2832 btrfs_set_fs_incompat(root->fs_info, DEFAULT_SUBVOL);
2840 features = btrfs_super_incompat_flags(disk_super);
2841 if (!(features & BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL)) {
2842 features |= BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL;
2843 btrfs_set_super_incompat_flags(disk_super, features);
2844 }
2845 btrfs_end_transaction(trans, root); 2833 btrfs_end_transaction(trans, root);
2846 2834
2847 return 0; 2835 return 0;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 26da344231ac..75ee2c7791f0 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -401,6 +401,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
401 compress_type = "lzo"; 401 compress_type = "lzo";
402 info->compress_type = BTRFS_COMPRESS_LZO; 402 info->compress_type = BTRFS_COMPRESS_LZO;
403 btrfs_set_opt(info->mount_opt, COMPRESS); 403 btrfs_set_opt(info->mount_opt, COMPRESS);
404 btrfs_set_fs_incompat(info, COMPRESS_LZO);
404 } else if (strncmp(args[0].from, "no", 2) == 0) { 405 } else if (strncmp(args[0].from, "no", 2) == 0) {
405 compress_type = "no"; 406 compress_type = "no";
406 info->compress_type = BTRFS_COMPRESS_NONE; 407 info->compress_type = BTRFS_COMPRESS_NONE;