Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
[pandora-kernel.git] / fs / btrfs / ioctl.c
index d6836af..e568c47 100644 (file)
@@ -599,13 +599,13 @@ fail:
 */
 static inline int btrfs_check_sticky(struct inode *dir, struct inode *inode)
 {
-       uid_t fsuid = current_fsuid();
+       kuid_t fsuid = current_fsuid();
 
        if (!(dir->i_mode & S_ISVTX))
                return 0;
-       if (inode->i_uid == fsuid)
+       if (uid_eq(inode->i_uid, fsuid))
                return 0;
-       if (dir->i_uid == fsuid)
+       if (uid_eq(dir->i_uid, fsuid))
                return 0;
        return !capable(CAP_FOWNER);
 }
@@ -1421,7 +1421,6 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
                                u64 *transid, bool readonly,
                                struct btrfs_qgroup_inherit **inherit)
 {
-       struct file *src_file;
        int namelen;
        int ret = 0;
 
@@ -1445,25 +1444,24 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
                ret = btrfs_mksubvol(&file->f_path, name, namelen,
                                     NULL, transid, readonly, inherit);
        } else {
+               struct fd src = fdget(fd);
                struct inode *src_inode;
-               src_file = fget(fd);
-               if (!src_file) {
+               if (!src.file) {
                        ret = -EINVAL;
                        goto out_drop_write;
                }
 
-               src_inode = src_file->f_path.dentry->d_inode;
+               src_inode = src.file->f_path.dentry->d_inode;
                if (src_inode->i_sb != file->f_path.dentry->d_inode->i_sb) {
                        printk(KERN_INFO "btrfs: Snapshot src from "
                               "another FS\n");
                        ret = -EINVAL;
-                       fput(src_file);
-                       goto out_drop_write;
+               } else {
+                       ret = btrfs_mksubvol(&file->f_path, name, namelen,
+                                            BTRFS_I(src_inode)->root,
+                                            transid, readonly, inherit);
                }
-               ret = btrfs_mksubvol(&file->f_path, name, namelen,
-                                    BTRFS_I(src_inode)->root,
-                                    transid, readonly, inherit);
-               fput(src_file);
+               fdput(src);
        }
 out_drop_write:
        mnt_drop_write_file(file);
@@ -2365,7 +2363,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
 {
        struct inode *inode = fdentry(file)->d_inode;
        struct btrfs_root *root = BTRFS_I(inode)->root;
-       struct file *src_file;
+       struct fsrc_file;
        struct inode *src;
        struct btrfs_trans_handle *trans;
        struct btrfs_path *path;
@@ -2399,24 +2397,24 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
        if (ret)
                return ret;
 
-       src_file = fget(srcfd);
-       if (!src_file) {
+       src_file = fdget(srcfd);
+       if (!src_file.file) {
                ret = -EBADF;
                goto out_drop_write;
        }
 
        ret = -EXDEV;
-       if (src_file->f_path.mnt != file->f_path.mnt)
+       if (src_file.file->f_path.mnt != file->f_path.mnt)
                goto out_fput;
 
-       src = src_file->f_dentry->d_inode;
+       src = src_file.file->f_dentry->d_inode;
 
        ret = -EINVAL;
        if (src == inode)
                goto out_fput;
 
        /* the src must be open for reading */
-       if (!(src_file->f_mode & FMODE_READ))
+       if (!(src_file.file->f_mode & FMODE_READ))
                goto out_fput;
 
        /* don't make the dst file partly checksummed */
@@ -2747,7 +2745,7 @@ out_unlock:
        vfree(buf);
        btrfs_free_path(path);
 out_fput:
-       fput(src_file);
+       fdput(src_file);
 out_drop_write:
        mnt_drop_write_file(file);
        return ret;
@@ -2875,8 +2873,8 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
        return 0;
 }
 
-static void get_block_group_info(struct list_head *groups_list,
-                                struct btrfs_ioctl_space_info *space)
+void btrfs_get_block_group_info(struct list_head *groups_list,
+                               struct btrfs_ioctl_space_info *space)
 {
        struct btrfs_block_group_cache *block_group;
 
@@ -2984,8 +2982,8 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
                down_read(&info->groups_sem);
                for (c = 0; c < BTRFS_NR_RAID_TYPES; c++) {
                        if (!list_empty(&info->block_groups[c])) {
-                               get_block_group_info(&info->block_groups[c],
-                                                    &space);
+                               btrfs_get_block_group_info(
+                                       &info->block_groups[c], &space);
                                memcpy(dest, &space, sizeof(space));
                                dest++;
                                space_args.total_spaces++;