Btrfs: fix FS_IOC_SETFLAGS ioctl
authorLi Zefan <lizf@cn.fujitsu.com>
Fri, 15 Apr 2011 03:03:17 +0000 (03:03 +0000)
committerChris Mason <chris.mason@oracle.com>
Sat, 14 May 2011 20:10:28 +0000 (16:10 -0400)
Steps to reproduce the bug:

  - Call FS_IOC_SETLFAGS ioctl with flags=FS_COMPR_FL
  - Call FS_IOC_SETFLAGS ioctl with flags=0
  - Call FS_IOC_GETFLAGS ioctl, and you'll see FS_COMPR_FL is still set!

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ioctl.c

index aeabf6b6ccc8122f6831601698277bc02231cedf..3e7031d32eeffc1b03887a60ffff067eea499f22 100644 (file)
@@ -238,6 +238,8 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
        } else if (flags & FS_COMPR_FL) {
                ip->flags |= BTRFS_INODE_COMPRESS;
                ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
+       } else {
+               ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
        }
 
        trans = btrfs_join_transaction(root, 1);