diff mbox

[2/4] btrfs: SETFLAGS ioctl: use helper for compression type conversion

Message ID 233097e27401c0f3163e7dc7c72442f50309705a.1512058075.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Sterba Nov. 30, 2017, 4:09 p.m. UTC
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Anand Jain Nov. 30, 2017, 10:08 p.m. UTC | #1
On 12/01/2017 12:09 AM, David Sterba wrote:
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>   fs/btrfs/ioctl.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index e8adebc8c1b0..c41c259d9283 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -307,12 +307,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
>   		ip->flags |= BTRFS_INODE_COMPRESS;
>   		ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
>   
> -		if (fs_info->compress_type == BTRFS_COMPRESS_LZO)
> -			comp = "lzo";
> -		else if (fs_info->compress_type == BTRFS_COMPRESS_ZLIB)
> -			comp = "zlib";
> -		else
> -			comp = "zstd";

  Bit deviating from the stuff here. Looks like zstd changed the default
  compression algo to zstd (from zlib). I remember seeing your comment
  on that too which I thought is fixed, but now I can't locate. Shouldn't
  this be a bug ?

Thanks, Anand


> +		comp = btrfs_compress_type2str(fs_info->compress_type);
> +		if (!comp || comp[0] == 0)
> +			comp = btrfs_compress_type2str(BTRFS_COMPRESS_ZLIB);
> +
>   		ret = btrfs_set_prop(inode, "btrfs.compression",
>   				     comp, strlen(comp), 0);
>   		if (ret)
> 
--
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
David Sterba Dec. 4, 2017, 2:29 p.m. UTC | #2
On Fri, Dec 01, 2017 at 06:08:53AM +0800, Anand Jain wrote:
> 
> 
> On 12/01/2017 12:09 AM, David Sterba wrote:
> > Signed-off-by: David Sterba <dsterba@suse.com>
> > ---
> >   fs/btrfs/ioctl.c | 10 ++++------
> >   1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> > index e8adebc8c1b0..c41c259d9283 100644
> > --- a/fs/btrfs/ioctl.c
> > +++ b/fs/btrfs/ioctl.c
> > @@ -307,12 +307,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
> >   		ip->flags |= BTRFS_INODE_COMPRESS;
> >   		ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
> >   
> > -		if (fs_info->compress_type == BTRFS_COMPRESS_LZO)
> > -			comp = "lzo";
> > -		else if (fs_info->compress_type == BTRFS_COMPRESS_ZLIB)
> > -			comp = "zlib";
> > -		else
> > -			comp = "zstd";
> 
>   Bit deviating from the stuff here. Looks like zstd changed the default
>   compression algo to zstd (from zlib). I remember seeing your comment
>   on that too which I thought is fixed, but now I can't locate. Shouldn't
>   this be a bug ?

It's not a bug, zlib is still the default, but proving that needs more
code for the context.

https://patchwork.kernel.org/patch/10034957/
--
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
diff mbox

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e8adebc8c1b0..c41c259d9283 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -307,12 +307,10 @@  static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 		ip->flags |= BTRFS_INODE_COMPRESS;
 		ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
 
-		if (fs_info->compress_type == BTRFS_COMPRESS_LZO)
-			comp = "lzo";
-		else if (fs_info->compress_type == BTRFS_COMPRESS_ZLIB)
-			comp = "zlib";
-		else
-			comp = "zstd";
+		comp = btrfs_compress_type2str(fs_info->compress_type);
+		if (!comp || comp[0] == 0)
+			comp = btrfs_compress_type2str(BTRFS_COMPRESS_ZLIB);
+
 		ret = btrfs_set_prop(inode, "btrfs.compression",
 				     comp, strlen(comp), 0);
 		if (ret)