The following patches are against Josef''s btrfs-next repository, and depend on Arnd Hannemann''s "Btrfs: allow mount -o remount,compress=no" patch. The method was based on a previous example of checking for lzo INCOMPAT used by Li Zefan when defragmenting with explicit compression ("btrfs: Allow to specify compress method when defrag") in ioctl.c. The second patch uses the new function in the above referenced existing check for lzo INCOMPAT performed when defragmenting with explicit lzo compression. This patch provides no functional changes. Mitch Harder (2): Btrfs: Check INCOMPAT flags on remount with lzo compression Btrfs: Use common function to check lzo INCOMPAT on defrag. fs/btrfs/ctree.h | 1 + fs/btrfs/ioctl.c | 7 +------ fs/btrfs/super.c | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 7 deletions(-) -- 1.7.8.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mitch Harder
2012-Jul-20 17:36 UTC
[PATCH 1/2] Btrfs: Check INCOMPAT flags on remount with lzo compression
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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mitch Harder
2012-Jul-20 17:36 UTC
[PATCH 2/2] Btrfs: Use common function to check lzo INCOMPAT on defrag.
When defragmenting with explicit lzo compression, simplify the check for lzo INCOMPAT by using the new common function introduced to support remounting with lzo compression. Signed-off-by: Mitch Harder <mitch.harder@sabayonlinux.org> --- fs/btrfs/ioctl.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 17facea..d5fd69e 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1042,11 +1042,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, u64 newer_than, unsigned long max_to_defrag) { struct btrfs_root *root = BTRFS_I(inode)->root; - struct btrfs_super_block *disk_super; struct file_ra_state *ra = NULL; unsigned long last_index; u64 isize = i_size_read(inode); - u64 features; u64 last_len = 0; u64 skip = 0; u64 defrag_end = 0; @@ -1233,11 +1231,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, mutex_unlock(&inode->i_mutex); } - disk_super = root->fs_info->super_copy; - features = btrfs_super_incompat_flags(disk_super); if (range->compress_type == BTRFS_COMPRESS_LZO) { - features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO; - btrfs_set_super_incompat_flags(disk_super, features); + btrfs_chk_lzo_incompat(root); } ret = defrag_count; -- 1.7.8.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Josef Bacik
2012-Jul-20 17:39 UTC
Re: [PATCH 1/2] Btrfs: Check INCOMPAT flags on remount with lzo compression
On Fri, Jul 20, 2012 at 11:36:20AM -0600, Mitch Harder wrote:> 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);Please don''t include format changes that aren''t related to the patch, I stared at this for 5 seconds too long trying to figure out what you changed. Thanks, Josef -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html