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>
This commit is contained in:
parent
df2c95f33e
commit
dcb40c196f
@ -3038,12 +3038,14 @@ int prealloc_file_extent_cluster(struct inode *inode,
|
|||||||
u64 num_bytes;
|
u64 num_bytes;
|
||||||
int nr = 0;
|
int nr = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
u64 prealloc_start = cluster->start - offset;
|
||||||
|
u64 prealloc_end = cluster->end - offset;
|
||||||
|
|
||||||
BUG_ON(cluster->start != cluster->boundary[0]);
|
BUG_ON(cluster->start != cluster->boundary[0]);
|
||||||
inode_lock(inode);
|
inode_lock(inode);
|
||||||
|
|
||||||
ret = btrfs_check_data_free_space(inode, cluster->start,
|
ret = btrfs_check_data_free_space(inode, prealloc_start,
|
||||||
cluster->end + 1 - cluster->start);
|
prealloc_end + 1 - prealloc_start);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -3064,8 +3066,8 @@ int prealloc_file_extent_cluster(struct inode *inode,
|
|||||||
break;
|
break;
|
||||||
nr++;
|
nr++;
|
||||||
}
|
}
|
||||||
btrfs_free_reserved_data_space(inode, cluster->start,
|
btrfs_free_reserved_data_space(inode, prealloc_start,
|
||||||
cluster->end + 1 - cluster->start);
|
prealloc_end + 1 - prealloc_start);
|
||||||
out:
|
out:
|
||||||
inode_unlock(inode);
|
inode_unlock(inode);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user