Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable

* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
  Btrfs: fix FS_IOC_SETFLAGS ioctl
  Btrfs: fix FS_IOC_GETFLAGS ioctl
  fs: remove FS_COW_FL
  Btrfs: fix easily get into ENOSPC in mixed case
  Prevent oopsing in posix_acl_valid()
This commit is contained in:
Linus Torvalds 2011-05-15 10:22:10 -07:00
commit eed631e0d7
4 changed files with 44 additions and 23 deletions

View File

@ -178,12 +178,13 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
if (value) { if (value) {
acl = posix_acl_from_xattr(value, size); acl = posix_acl_from_xattr(value, size);
if (IS_ERR(acl))
return PTR_ERR(acl);
if (acl) { if (acl) {
ret = posix_acl_valid(acl); ret = posix_acl_valid(acl);
if (ret) if (ret)
goto out; goto out;
} else if (IS_ERR(acl)) {
return PTR_ERR(acl);
} }
} }

View File

@ -8856,23 +8856,38 @@ out:
int btrfs_init_space_info(struct btrfs_fs_info *fs_info) int btrfs_init_space_info(struct btrfs_fs_info *fs_info)
{ {
struct btrfs_space_info *space_info; struct btrfs_space_info *space_info;
struct btrfs_super_block *disk_super;
u64 features;
u64 flags;
int mixed = 0;
int ret; int ret;
ret = update_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM, 0, 0, disk_super = &fs_info->super_copy;
&space_info); if (!btrfs_super_root(disk_super))
if (ret) return 1;
return ret;
ret = update_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA, 0, 0, features = btrfs_super_incompat_flags(disk_super);
&space_info); if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)
if (ret) mixed = 1;
return ret;
ret = update_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA, 0, 0, flags = BTRFS_BLOCK_GROUP_SYSTEM;
&space_info); ret = update_space_info(fs_info, flags, 0, 0, &space_info);
if (ret) if (ret)
return ret; goto out;
if (mixed) {
flags = BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA;
ret = update_space_info(fs_info, flags, 0, 0, &space_info);
} else {
flags = BTRFS_BLOCK_GROUP_METADATA;
ret = update_space_info(fs_info, flags, 0, 0, &space_info);
if (ret)
goto out;
flags = BTRFS_BLOCK_GROUP_DATA;
ret = update_space_info(fs_info, flags, 0, 0, &space_info);
}
out:
return ret; return ret;
} }

View File

@ -81,6 +81,13 @@ static unsigned int btrfs_flags_to_ioctl(unsigned int flags)
iflags |= FS_NOATIME_FL; iflags |= FS_NOATIME_FL;
if (flags & BTRFS_INODE_DIRSYNC) if (flags & BTRFS_INODE_DIRSYNC)
iflags |= FS_DIRSYNC_FL; iflags |= FS_DIRSYNC_FL;
if (flags & BTRFS_INODE_NODATACOW)
iflags |= FS_NOCOW_FL;
if ((flags & BTRFS_INODE_COMPRESS) && !(flags & BTRFS_INODE_NOCOMPRESS))
iflags |= FS_COMPR_FL;
else if (flags & BTRFS_INODE_NOCOMPRESS)
iflags |= FS_NOCOMP_FL;
return iflags; return iflags;
} }
@ -144,16 +151,13 @@ static int check_flags(unsigned int flags)
if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \ if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
FS_NOATIME_FL | FS_NODUMP_FL | \ FS_NOATIME_FL | FS_NODUMP_FL | \
FS_SYNC_FL | FS_DIRSYNC_FL | \ FS_SYNC_FL | FS_DIRSYNC_FL | \
FS_NOCOMP_FL | FS_COMPR_FL | \ FS_NOCOMP_FL | FS_COMPR_FL |
FS_NOCOW_FL | FS_COW_FL)) FS_NOCOW_FL))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL)) if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL))
return -EINVAL; return -EINVAL;
if ((flags & FS_NOCOW_FL) && (flags & FS_COW_FL))
return -EINVAL;
return 0; return 0;
} }
@ -218,6 +222,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
ip->flags |= BTRFS_INODE_DIRSYNC; ip->flags |= BTRFS_INODE_DIRSYNC;
else else
ip->flags &= ~BTRFS_INODE_DIRSYNC; ip->flags &= ~BTRFS_INODE_DIRSYNC;
if (flags & FS_NOCOW_FL)
ip->flags |= BTRFS_INODE_NODATACOW;
else
ip->flags &= ~BTRFS_INODE_NODATACOW;
/* /*
* The COMPRESS flag can only be changed by users, while the NOCOMPRESS * The COMPRESS flag can only be changed by users, while the NOCOMPRESS
@ -230,11 +238,9 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
} else if (flags & FS_COMPR_FL) { } else if (flags & FS_COMPR_FL) {
ip->flags |= BTRFS_INODE_COMPRESS; ip->flags |= BTRFS_INODE_COMPRESS;
ip->flags &= ~BTRFS_INODE_NOCOMPRESS; ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
} else {
ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
} }
if (flags & FS_NOCOW_FL)
ip->flags |= BTRFS_INODE_NODATACOW;
else if (flags & FS_COW_FL)
ip->flags &= ~BTRFS_INODE_NODATACOW;
trans = btrfs_join_transaction(root, 1); trans = btrfs_join_transaction(root, 1);
BUG_ON(IS_ERR(trans)); BUG_ON(IS_ERR(trans));

View File

@ -358,7 +358,6 @@ struct inodes_stat_t {
#define FS_EXTENT_FL 0x00080000 /* Extents */ #define FS_EXTENT_FL 0x00080000 /* Extents */
#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */ #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
#define FS_NOCOW_FL 0x00800000 /* Do not cow file */ #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
#define FS_COW_FL 0x02000000 /* Cow file */
#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */