diff options
author | Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com> | 2016-07-25 03:51:38 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-08-25 06:58:24 -0400 |
commit | dcb40c196fc85c6dfb28456480e5a882e26f567d (patch) | |
tree | 7cd6cdb47c6e1c970f20c708fea15c65a67f6dcf | |
parent | df2c95f33e0a28b22509e4ee85365eedf32a1056 (diff) |
btrfs: use correct offset for reloc_inode in prealloc_file_extent_cluster()
In prealloc_file_extent_cluster(), btrfs_check_data_free_space() uses
wrong file offset for reloc_inode, it uses cluster->start and cluster->end,
which indeed are extent's bytenr. The correct value should be
cluster->[start|end] minus block group's start bytenr.
start bytenr cluster->start
| | extent | extent | ...| extent |
|----------------------------------------------------------------|
| block group reloc_inode |
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r-- | fs/btrfs/relocation.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 27480ef9813c..71b4b70f56b9 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -3038,12 +3038,14 @@ int prealloc_file_extent_cluster(struct inode *inode, | |||
3038 | u64 num_bytes; | 3038 | u64 num_bytes; |
3039 | int nr = 0; | 3039 | int nr = 0; |
3040 | int ret = 0; | 3040 | int ret = 0; |
3041 | u64 prealloc_start = cluster->start - offset; | ||
3042 | u64 prealloc_end = cluster->end - offset; | ||
3041 | 3043 | ||
3042 | BUG_ON(cluster->start != cluster->boundary[0]); | 3044 | BUG_ON(cluster->start != cluster->boundary[0]); |
3043 | inode_lock(inode); | 3045 | inode_lock(inode); |
3044 | 3046 | ||
3045 | ret = btrfs_check_data_free_space(inode, cluster->start, | 3047 | ret = btrfs_check_data_free_space(inode, prealloc_start, |
3046 | cluster->end + 1 - cluster->start); | 3048 | prealloc_end + 1 - prealloc_start); |
3047 | if (ret) | 3049 | if (ret) |
3048 | goto out; | 3050 | goto out; |
3049 | 3051 | ||
@@ -3064,8 +3066,8 @@ int prealloc_file_extent_cluster(struct inode *inode, | |||
3064 | break; | 3066 | break; |
3065 | nr++; | 3067 | nr++; |
3066 | } | 3068 | } |
3067 | btrfs_free_reserved_data_space(inode, cluster->start, | 3069 | btrfs_free_reserved_data_space(inode, prealloc_start, |
3068 | cluster->end + 1 - cluster->start); | 3070 | prealloc_end + 1 - prealloc_start); |
3069 | out: | 3071 | out: |
3070 | inode_unlock(inode); | 3072 | inode_unlock(inode); |
3071 | return ret; | 3073 | return ret; |