aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2013-02-24 23:04:42 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-26 11:01:19 -0500
commit8c4ce81e911ab6c84e4f75e18d4ceb3fa555c35b (patch)
treeefaf7d66ae75071318f3532c140f2b149e81f83b /fs
parent2382c5cc7ed0396b61a359765bf5ee125b0a2f46 (diff)
Btrfs: do not change inode flags in rename
Before we forced to change a file's NOCOW and COMPRESS flag due to the parent directory's, but this ends up a bad idea, because it confuses end users a lot about file's NOCOW status, eg. if someone change a file to NOCOW via 'chattr' and then rename it in the current directory which is without NOCOW attribute, the file will lose the NOCOW flag silently. This diables 'change flags in rename', so from now on we'll only inherit flags from the parent directory on creation stage while in other places we can use 'chattr' to set NOCOW or COMPRESS flags. Reported-by: Marios Titas <redneb8888@gmail.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/inode.c25
1 files changed, 0 insertions, 25 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 14c82cdbb696..be09654e11b9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8060,29 +8060,6 @@ static int btrfs_getattr(struct vfsmount *mnt,
8060 return 0; 8060 return 0;
8061} 8061}
8062 8062
8063/*
8064 * If a file is moved, it will inherit the cow and compression flags of the new
8065 * directory.
8066 */
8067static void fixup_inode_flags(struct inode *dir, struct inode *inode)
8068{
8069 struct btrfs_inode *b_dir = BTRFS_I(dir);
8070 struct btrfs_inode *b_inode = BTRFS_I(inode);
8071
8072 if (b_dir->flags & BTRFS_INODE_NODATACOW)
8073 b_inode->flags |= BTRFS_INODE_NODATACOW;
8074 else
8075 b_inode->flags &= ~BTRFS_INODE_NODATACOW;
8076
8077 if (b_dir->flags & BTRFS_INODE_COMPRESS) {
8078 b_inode->flags |= BTRFS_INODE_COMPRESS;
8079 b_inode->flags &= ~BTRFS_INODE_NOCOMPRESS;
8080 } else {
8081 b_inode->flags &= ~(BTRFS_INODE_COMPRESS |
8082 BTRFS_INODE_NOCOMPRESS);
8083 }
8084}
8085
8086static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, 8063static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
8087 struct inode *new_dir, struct dentry *new_dentry) 8064 struct inode *new_dir, struct dentry *new_dentry)
8088{ 8065{
@@ -8248,8 +8225,6 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
8248 } 8225 }
8249 } 8226 }
8250 8227
8251 fixup_inode_flags(new_dir, old_inode);
8252
8253 ret = btrfs_add_link(trans, new_dir, old_inode, 8228 ret = btrfs_add_link(trans, new_dir, old_inode,
8254 new_dentry->d_name.name, 8229 new_dentry->d_name.name,
8255 new_dentry->d_name.len, 0, index); 8230 new_dentry->d_name.len, 0, index);