Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332581
b: refs/heads/master
c: 7e97b8d
h: refs/heads/master
i:
  332579: 75b5ab3
v: v3
  • Loading branch information
David Sterba authored and Chris Mason committed Oct 4, 2012
1 parent 05aa1df commit e400332
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c3308f84c1743eabb91f4976a314d118d5ea2342
refs/heads/master: 7e97b8daf63487c20f78487bd4045f39b0d97cf4
31 changes: 27 additions & 4 deletions trunk/fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
int ret;
u64 ip_oldflags;
unsigned int i_oldflags;
umode_t mode;

if (btrfs_root_readonly(root))
return -EROFS;
Expand All @@ -203,6 +204,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)

ip_oldflags = ip->flags;
i_oldflags = inode->i_flags;
mode = inode->i_mode;

flags = btrfs_mask_flags(inode->i_mode, flags);
oldflags = btrfs_flags_to_ioctl(ip->flags);
Expand Down Expand Up @@ -237,10 +239,31 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
ip->flags |= BTRFS_INODE_DIRSYNC;
else
ip->flags &= ~BTRFS_INODE_DIRSYNC;
if (flags & FS_NOCOW_FL)
ip->flags |= BTRFS_INODE_NODATACOW;
else
ip->flags &= ~BTRFS_INODE_NODATACOW;
if (flags & FS_NOCOW_FL) {
if (S_ISREG(mode)) {
/*
* It's safe to turn csums off here, no extents exist.
* Otherwise we want the flag to reflect the real COW
* status of the file and will not set it.
*/
if (inode->i_size == 0)
ip->flags |= BTRFS_INODE_NODATACOW
| BTRFS_INODE_NODATASUM;
} else {
ip->flags |= BTRFS_INODE_NODATACOW;
}
} else {
/*
* Revert back under same assuptions as above
*/
if (S_ISREG(mode)) {
if (inode->i_size == 0)
ip->flags &= ~(BTRFS_INODE_NODATACOW
| BTRFS_INODE_NODATASUM);
} else {
ip->flags &= ~BTRFS_INODE_NODATACOW;
}
}

/*
* The COMPRESS flag can only be changed by users, while the NOCOMPRESS
Expand Down

0 comments on commit e400332

Please sign in to comment.