e464725
From: Filipe Manana <fdmanana@suse.com>
e464725
Date: Thu, 11 Sep 2014 11:44:49 +0100
e464725
Subject: [PATCH] Btrfs: add missing compression property remove in
e464725
 btrfs_ioctl_setflags
e464725
e464725
(cherry picked from commit 78a017a2c92df9b571db0a55a016280f9019c65e)
e464725
e464725
The behaviour of a 'chattr -c' consists of getting the current flags,
e464725
clearing the FS_COMPR_FL bit and then sending the result to the set
e464725
flags ioctl - this means the bit FS_NOCOMP_FL isn't set in the flags
e464725
passed to the ioctl. This results in the compression property not being
e464725
cleared from the inode - it was cleared only if the bit FS_NOCOMP_FL
e464725
was set in the received flags.
e464725
e464725
Reproducer:
e464725
e464725
    $ mkfs.btrfs -f /dev/sdd
e464725
    $ mount /dev/sdd /mnt && cd /mnt
e464725
    $ mkdir a
e464725
    $ chattr +c a
e464725
    $ touch a/file
e464725
    $ lsattr a/file
e464725
    --------c------- a/file
e464725
    $ chattr -c a
e464725
    $ touch a/file2
e464725
    $ lsattr a/file2
e464725
    --------c------- a/file2
e464725
    $ lsattr -d a
e464725
    ---------------- a
e464725
e464725
Reported-by: Andreas Schneider <asn@cryptomilk.org>
e464725
Signed-off-by: Filipe Manana <fdmanana@suse.com>
e464725
Signed-off-by: Chris Mason <clm@fb.com>
e464725
---
e464725
 fs/btrfs/ioctl.c | 3 +++
e464725
 1 file changed, 3 insertions(+)
e464725
e464725
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
e464725
index 13d577b39bfa..91269bd9ad05 100644
e464725
--- a/fs/btrfs/ioctl.c
e464725
+++ b/fs/btrfs/ioctl.c
e464725
@@ -332,6 +332,9 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
e464725
 			goto out_drop;
e464725
 
e464725
 	} else {
e464725
+		ret = btrfs_set_prop(inode, "btrfs.compression", NULL, 0, 0);
e464725
+		if (ret && ret != -ENODATA)
e464725
+			goto out_drop;
e464725
 		ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
e464725
 	}
e464725
 
e464725
-- 
e464725
1.9.3
e464725