aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 48aee9846329..053e677839fe 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -59,6 +59,8 @@
59#include "props.h" 59#include "props.h"
60#include "sysfs.h" 60#include "sysfs.h"
61#include "qgroup.h" 61#include "qgroup.h"
62#include "tree-log.h"
63#include "compression.h"
62 64
63#ifdef CONFIG_64BIT 65#ifdef CONFIG_64BIT
64/* If we have a 32-bit userspace and 64-bit kernel, then the UAPI 66/* If we have a 32-bit userspace and 64-bit kernel, then the UAPI
@@ -347,7 +349,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
347 349
348 btrfs_update_iflags(inode); 350 btrfs_update_iflags(inode);
349 inode_inc_iversion(inode); 351 inode_inc_iversion(inode);
350 inode->i_ctime = CURRENT_TIME; 352 inode->i_ctime = current_fs_time(inode->i_sb);
351 ret = btrfs_update_inode(trans, root, inode); 353 ret = btrfs_update_inode(trans, root, inode);
352 354
353 btrfs_end_transaction(trans, root); 355 btrfs_end_transaction(trans, root);
@@ -443,7 +445,7 @@ static noinline int create_subvol(struct inode *dir,
443 struct btrfs_root *root = BTRFS_I(dir)->root; 445 struct btrfs_root *root = BTRFS_I(dir)->root;
444 struct btrfs_root *new_root; 446 struct btrfs_root *new_root;
445 struct btrfs_block_rsv block_rsv; 447 struct btrfs_block_rsv block_rsv;
446 struct timespec cur_time = CURRENT_TIME; 448 struct timespec cur_time = current_fs_time(dir->i_sb);
447 struct inode *inode; 449 struct inode *inode;
448 int ret; 450 int ret;
449 int err; 451 int err;
@@ -844,10 +846,6 @@ static noinline int btrfs_mksubvol(struct path *parent,
844 if (IS_ERR(dentry)) 846 if (IS_ERR(dentry))
845 goto out_unlock; 847 goto out_unlock;
846 848
847 error = -EEXIST;
848 if (d_really_is_positive(dentry))
849 goto out_dput;
850
851 error = btrfs_may_create(dir, dentry); 849 error = btrfs_may_create(dir, dentry);
852 if (error) 850 if (error)
853 goto out_dput; 851 goto out_dput;
@@ -2097,8 +2095,6 @@ static noinline int search_ioctl(struct inode *inode,
2097 key.offset = (u64)-1; 2095 key.offset = (u64)-1;
2098 root = btrfs_read_fs_root_no_name(info, &key); 2096 root = btrfs_read_fs_root_no_name(info, &key);
2099 if (IS_ERR(root)) { 2097 if (IS_ERR(root)) {
2100 btrfs_err(info, "could not find root %llu",
2101 sk->tree_id);
2102 btrfs_free_path(path); 2098 btrfs_free_path(path);
2103 return -ENOENT; 2099 return -ENOENT;
2104 } 2100 }
@@ -2476,6 +2472,8 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2476 trans->block_rsv = &block_rsv; 2472 trans->block_rsv = &block_rsv;
2477 trans->bytes_reserved = block_rsv.size; 2473 trans->bytes_reserved = block_rsv.size;
2478 2474
2475 btrfs_record_snapshot_destroy(trans, dir);
2476
2479 ret = btrfs_unlink_subvol(trans, root, dir, 2477 ret = btrfs_unlink_subvol(trans, root, dir,
2480 dest->root_key.objectid, 2478 dest->root_key.objectid,
2481 dentry->d_name.name, 2479 dentry->d_name.name,
@@ -2960,8 +2958,8 @@ static int btrfs_cmp_data_prepare(struct inode *src, u64 loff,
2960 * of the array is bounded by len, which is in turn bounded by 2958 * of the array is bounded by len, which is in turn bounded by
2961 * BTRFS_MAX_DEDUPE_LEN. 2959 * BTRFS_MAX_DEDUPE_LEN.
2962 */ 2960 */
2963 src_pgarr = kzalloc(num_pages * sizeof(struct page *), GFP_NOFS); 2961 src_pgarr = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
2964 dst_pgarr = kzalloc(num_pages * sizeof(struct page *), GFP_NOFS); 2962 dst_pgarr = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
2965 if (!src_pgarr || !dst_pgarr) { 2963 if (!src_pgarr || !dst_pgarr) {
2966 kfree(src_pgarr); 2964 kfree(src_pgarr);
2967 kfree(dst_pgarr); 2965 kfree(dst_pgarr);
@@ -3068,6 +3066,9 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
3068 ret = extent_same_check_offsets(src, loff, &len, olen); 3066 ret = extent_same_check_offsets(src, loff, &len, olen);
3069 if (ret) 3067 if (ret)
3070 goto out_unlock; 3068 goto out_unlock;
3069 ret = extent_same_check_offsets(src, dst_loff, &len, olen);
3070 if (ret)
3071 goto out_unlock;
3071 3072
3072 /* 3073 /*
3073 * Single inode case wants the same checks, except we 3074 * Single inode case wants the same checks, except we
@@ -3217,7 +3218,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
3217 3218
3218 inode_inc_iversion(inode); 3219 inode_inc_iversion(inode);
3219 if (!no_time_update) 3220 if (!no_time_update)
3220 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 3221 inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
3221 /* 3222 /*
3222 * We round up to the block size at eof when determining which 3223 * We round up to the block size at eof when determining which
3223 * extents to clone above, but shouldn't round up the file size. 3224 * extents to clone above, but shouldn't round up the file size.
@@ -3889,8 +3890,9 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
3889 * Truncate page cache pages so that future reads will see the cloned 3890 * Truncate page cache pages so that future reads will see the cloned
3890 * data immediately and not the previous data. 3891 * data immediately and not the previous data.
3891 */ 3892 */
3892 truncate_inode_pages_range(&inode->i_data, destoff, 3893 truncate_inode_pages_range(&inode->i_data,
3893 PAGE_CACHE_ALIGN(destoff + len) - 1); 3894 round_down(destoff, PAGE_CACHE_SIZE),
3895 round_up(destoff + len, PAGE_CACHE_SIZE) - 1);
3894out_unlock: 3896out_unlock:
3895 if (!same_inode) 3897 if (!same_inode)
3896 btrfs_double_inode_unlock(src, inode); 3898 btrfs_double_inode_unlock(src, inode);
@@ -5031,7 +5033,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
5031 struct btrfs_root *root = BTRFS_I(inode)->root; 5033 struct btrfs_root *root = BTRFS_I(inode)->root;
5032 struct btrfs_root_item *root_item = &root->root_item; 5034 struct btrfs_root_item *root_item = &root->root_item;
5033 struct btrfs_trans_handle *trans; 5035 struct btrfs_trans_handle *trans;
5034 struct timespec ct = CURRENT_TIME; 5036 struct timespec ct = current_fs_time(inode->i_sb);
5035 int ret = 0; 5037 int ret = 0;
5036 int received_uuid_changed; 5038 int received_uuid_changed;
5037 5039
@@ -5262,8 +5264,7 @@ out_unlock:
5262 .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_##suffix, \ 5264 .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_##suffix, \
5263 .incompat_flags = BTRFS_FEATURE_INCOMPAT_##suffix } 5265 .incompat_flags = BTRFS_FEATURE_INCOMPAT_##suffix }
5264 5266
5265static int btrfs_ioctl_get_supported_features(struct file *file, 5267int btrfs_ioctl_get_supported_features(void __user *arg)
5266 void __user *arg)
5267{ 5268{
5268 static const struct btrfs_ioctl_feature_flags features[3] = { 5269 static const struct btrfs_ioctl_feature_flags features[3] = {
5269 INIT_FEATURE_FLAGS(SUPP), 5270 INIT_FEATURE_FLAGS(SUPP),
@@ -5542,7 +5543,7 @@ long btrfs_ioctl(struct file *file, unsigned int
5542 case BTRFS_IOC_SET_FSLABEL: 5543 case BTRFS_IOC_SET_FSLABEL:
5543 return btrfs_ioctl_set_fslabel(file, argp); 5544 return btrfs_ioctl_set_fslabel(file, argp);
5544 case BTRFS_IOC_GET_SUPPORTED_FEATURES: 5545 case BTRFS_IOC_GET_SUPPORTED_FEATURES:
5545 return btrfs_ioctl_get_supported_features(file, argp); 5546 return btrfs_ioctl_get_supported_features(argp);
5546 case BTRFS_IOC_GET_FEATURES: 5547 case BTRFS_IOC_GET_FEATURES:
5547 return btrfs_ioctl_get_features(file, argp); 5548 return btrfs_ioctl_get_features(file, argp);
5548 case BTRFS_IOC_SET_FEATURES: 5549 case BTRFS_IOC_SET_FEATURES: