diff options
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 6a706e69137..a0686658a3f 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1341,8 +1341,10 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) | |||
1341 | ret = -EPERM; | 1341 | ret = -EPERM; |
1342 | goto out; | 1342 | goto out; |
1343 | } | 1343 | } |
1344 | btrfs_defrag_root(root, 0); | 1344 | ret = btrfs_defrag_root(root, 0); |
1345 | btrfs_defrag_root(root->fs_info->extent_root, 0); | 1345 | if (ret) |
1346 | goto out; | ||
1347 | ret = btrfs_defrag_root(root->fs_info->extent_root, 0); | ||
1346 | break; | 1348 | break; |
1347 | case S_IFREG: | 1349 | case S_IFREG: |
1348 | if (!(file->f_mode & FMODE_WRITE)) { | 1350 | if (!(file->f_mode & FMODE_WRITE)) { |
@@ -1372,9 +1374,11 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) | |||
1372 | /* the rest are all set to zero by kzalloc */ | 1374 | /* the rest are all set to zero by kzalloc */ |
1373 | range->len = (u64)-1; | 1375 | range->len = (u64)-1; |
1374 | } | 1376 | } |
1375 | btrfs_defrag_file(file, range); | 1377 | ret = btrfs_defrag_file(file, range); |
1376 | kfree(range); | 1378 | kfree(range); |
1377 | break; | 1379 | break; |
1380 | default: | ||
1381 | ret = -EINVAL; | ||
1378 | } | 1382 | } |
1379 | out: | 1383 | out: |
1380 | mnt_drop_write(file->f_path.mnt); | 1384 | mnt_drop_write(file->f_path.mnt); |