diff options
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a506a22b522a..be2d4f6aaa5e 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -203,7 +203,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) | |||
203 | 203 | ||
204 | 204 | ||
205 | trans = btrfs_join_transaction(root, 1); | 205 | trans = btrfs_join_transaction(root, 1); |
206 | BUG_ON(!trans); | 206 | BUG_ON(IS_ERR(trans)); |
207 | 207 | ||
208 | ret = btrfs_update_inode(trans, root, inode); | 208 | ret = btrfs_update_inode(trans, root, inode); |
209 | BUG_ON(ret); | 209 | BUG_ON(ret); |
@@ -907,6 +907,10 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root, | |||
907 | 907 | ||
908 | if (new_size > old_size) { | 908 | if (new_size > old_size) { |
909 | trans = btrfs_start_transaction(root, 0); | 909 | trans = btrfs_start_transaction(root, 0); |
910 | if (IS_ERR(trans)) { | ||
911 | ret = PTR_ERR(trans); | ||
912 | goto out_unlock; | ||
913 | } | ||
910 | ret = btrfs_grow_device(trans, device, new_size); | 914 | ret = btrfs_grow_device(trans, device, new_size); |
911 | btrfs_commit_transaction(trans, root); | 915 | btrfs_commit_transaction(trans, root); |
912 | } else { | 916 | } else { |
@@ -1898,7 +1902,10 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1898 | 1902 | ||
1899 | memcpy(&new_key, &key, sizeof(new_key)); | 1903 | memcpy(&new_key, &key, sizeof(new_key)); |
1900 | new_key.objectid = inode->i_ino; | 1904 | new_key.objectid = inode->i_ino; |
1901 | new_key.offset = key.offset + destoff - off; | 1905 | if (off <= key.offset) |
1906 | new_key.offset = key.offset + destoff - off; | ||
1907 | else | ||
1908 | new_key.offset = destoff; | ||
1902 | 1909 | ||
1903 | trans = btrfs_start_transaction(root, 1); | 1910 | trans = btrfs_start_transaction(root, 1); |
1904 | if (IS_ERR(trans)) { | 1911 | if (IS_ERR(trans)) { |
@@ -2082,7 +2089,7 @@ static long btrfs_ioctl_trans_start(struct file *file) | |||
2082 | 2089 | ||
2083 | ret = -ENOMEM; | 2090 | ret = -ENOMEM; |
2084 | trans = btrfs_start_ioctl_transaction(root, 0); | 2091 | trans = btrfs_start_ioctl_transaction(root, 0); |
2085 | if (!trans) | 2092 | if (IS_ERR(trans)) |
2086 | goto out_drop; | 2093 | goto out_drop; |
2087 | 2094 | ||
2088 | file->private_data = trans; | 2095 | file->private_data = trans; |
@@ -2138,9 +2145,9 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) | |||
2138 | path->leave_spinning = 1; | 2145 | path->leave_spinning = 1; |
2139 | 2146 | ||
2140 | trans = btrfs_start_transaction(root, 1); | 2147 | trans = btrfs_start_transaction(root, 1); |
2141 | if (!trans) { | 2148 | if (IS_ERR(trans)) { |
2142 | btrfs_free_path(path); | 2149 | btrfs_free_path(path); |
2143 | return -ENOMEM; | 2150 | return PTR_ERR(trans); |
2144 | } | 2151 | } |
2145 | 2152 | ||
2146 | dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); | 2153 | dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); |
@@ -2201,7 +2208,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) | |||
2201 | int num_types = 4; | 2208 | int num_types = 4; |
2202 | int alloc_size; | 2209 | int alloc_size; |
2203 | int ret = 0; | 2210 | int ret = 0; |
2204 | int slot_count = 0; | 2211 | u64 slot_count = 0; |
2205 | int i, c; | 2212 | int i, c; |
2206 | 2213 | ||
2207 | if (copy_from_user(&space_args, | 2214 | if (copy_from_user(&space_args, |
@@ -2240,7 +2247,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) | |||
2240 | goto out; | 2247 | goto out; |
2241 | } | 2248 | } |
2242 | 2249 | ||
2243 | slot_count = min_t(int, space_args.space_slots, slot_count); | 2250 | slot_count = min_t(u64, space_args.space_slots, slot_count); |
2244 | 2251 | ||
2245 | alloc_size = sizeof(*dest) * slot_count; | 2252 | alloc_size = sizeof(*dest) * slot_count; |
2246 | 2253 | ||
@@ -2260,6 +2267,9 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) | |||
2260 | for (i = 0; i < num_types; i++) { | 2267 | for (i = 0; i < num_types; i++) { |
2261 | struct btrfs_space_info *tmp; | 2268 | struct btrfs_space_info *tmp; |
2262 | 2269 | ||
2270 | if (!slot_count) | ||
2271 | break; | ||
2272 | |||
2263 | info = NULL; | 2273 | info = NULL; |
2264 | rcu_read_lock(); | 2274 | rcu_read_lock(); |
2265 | list_for_each_entry_rcu(tmp, &root->fs_info->space_info, | 2275 | list_for_each_entry_rcu(tmp, &root->fs_info->space_info, |
@@ -2281,7 +2291,10 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) | |||
2281 | memcpy(dest, &space, sizeof(space)); | 2291 | memcpy(dest, &space, sizeof(space)); |
2282 | dest++; | 2292 | dest++; |
2283 | space_args.total_spaces++; | 2293 | space_args.total_spaces++; |
2294 | slot_count--; | ||
2284 | } | 2295 | } |
2296 | if (!slot_count) | ||
2297 | break; | ||
2285 | } | 2298 | } |
2286 | up_read(&info->groups_sem); | 2299 | up_read(&info->groups_sem); |
2287 | } | 2300 | } |
@@ -2334,6 +2347,8 @@ static noinline long btrfs_ioctl_start_sync(struct file *file, void __user *argp | |||
2334 | u64 transid; | 2347 | u64 transid; |
2335 | 2348 | ||
2336 | trans = btrfs_start_transaction(root, 0); | 2349 | trans = btrfs_start_transaction(root, 0); |
2350 | if (IS_ERR(trans)) | ||
2351 | return PTR_ERR(trans); | ||
2337 | transid = trans->transid; | 2352 | transid = trans->transid; |
2338 | btrfs_commit_transaction_async(trans, root, 0); | 2353 | btrfs_commit_transaction_async(trans, root, 0); |
2339 | 2354 | ||