diff options
author | Filipe David Borba Manana <fdmanana@gmail.com> | 2013-08-16 10:23:33 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-09-01 08:16:00 -0400 |
commit | 633085c79c84c391732caa40f5b3a3d2b299f7be (patch) | |
tree | 93e64ecb2d2bbc58da63c859bd736ccc83fdbbd3 /fs/btrfs/ioctl.c | |
parent | f420ee1e923b931eeef5e2928791e84b1197cab3 (diff) |
Btrfs: reset force_compress on btrfs_file_defrag failure
After we set force_compress with a new value (which was not being done
while holding the inode mutex), if an error happens and we jump to
the label out_ra, the force_compress property of the inode is not set
to BTRFS_COMPRESS_NONE (unlike in the case where no errors happen).
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 8e75249282c2..076cc7fff813 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1285,9 +1285,6 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1285 | cluster = max_cluster; | 1285 | cluster = max_cluster; |
1286 | } | 1286 | } |
1287 | 1287 | ||
1288 | if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) | ||
1289 | BTRFS_I(inode)->force_compress = compress_type; | ||
1290 | |||
1291 | if (i + cluster > ra_index) { | 1288 | if (i + cluster > ra_index) { |
1292 | ra_index = max(i, ra_index); | 1289 | ra_index = max(i, ra_index); |
1293 | btrfs_force_ra(inode->i_mapping, ra, file, ra_index, | 1290 | btrfs_force_ra(inode->i_mapping, ra, file, ra_index, |
@@ -1296,6 +1293,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1296 | } | 1293 | } |
1297 | 1294 | ||
1298 | mutex_lock(&inode->i_mutex); | 1295 | mutex_lock(&inode->i_mutex); |
1296 | if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) | ||
1297 | BTRFS_I(inode)->force_compress = compress_type; | ||
1299 | ret = cluster_pages_for_defrag(inode, pages, i, cluster); | 1298 | ret = cluster_pages_for_defrag(inode, pages, i, cluster); |
1300 | if (ret < 0) { | 1299 | if (ret < 0) { |
1301 | mutex_unlock(&inode->i_mutex); | 1300 | mutex_unlock(&inode->i_mutex); |
@@ -1352,10 +1351,6 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1352 | atomic_read(&root->fs_info->async_delalloc_pages) == 0)); | 1351 | atomic_read(&root->fs_info->async_delalloc_pages) == 0)); |
1353 | } | 1352 | } |
1354 | atomic_dec(&root->fs_info->async_submit_draining); | 1353 | atomic_dec(&root->fs_info->async_submit_draining); |
1355 | |||
1356 | mutex_lock(&inode->i_mutex); | ||
1357 | BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_NONE; | ||
1358 | mutex_unlock(&inode->i_mutex); | ||
1359 | } | 1354 | } |
1360 | 1355 | ||
1361 | if (range->compress_type == BTRFS_COMPRESS_LZO) { | 1356 | if (range->compress_type == BTRFS_COMPRESS_LZO) { |
@@ -1365,6 +1360,11 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1365 | ret = defrag_count; | 1360 | ret = defrag_count; |
1366 | 1361 | ||
1367 | out_ra: | 1362 | out_ra: |
1363 | if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) { | ||
1364 | mutex_lock(&inode->i_mutex); | ||
1365 | BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_NONE; | ||
1366 | mutex_unlock(&inode->i_mutex); | ||
1367 | } | ||
1368 | if (!file) | 1368 | if (!file) |
1369 | kfree(ra); | 1369 | kfree(ra); |
1370 | kfree(pages); | 1370 | kfree(pages); |