btrfs-progs: convert: fix buggy logic in create_image_file_range()
When checking if the requested range starts in a valid region but later hits a reserved range, we require the reserved range to end before the requested one does. This is incorrect. Since we're going to truncate the requested range anyway, we want this check to pass even if the requested range ends partway through a reserved range. Fix the issue by checking against the reserved range's start address instead of its end. Luckily, I don't believe this bug makes a difference in the current code path, since the range we pass to this function never ends before the end of the filesystem. Issue: #297 Issue: #349 Author: Thomas Hebb <tommyhebb@gmail.com> Pull-request: #494 Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
407a8721b6
commit
cfae74f6bb
|
@ -256,10 +256,13 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
|
|||
/*
|
||||
* |-- reserved --|
|
||||
* |-- range --|
|
||||
* or
|
||||
* |-- reserved --|
|
||||
* |------- range -------|
|
||||
* Leading part may still create a file extent
|
||||
*/
|
||||
if (bytenr < reserved->start &&
|
||||
bytenr + len >= range_end(reserved)) {
|
||||
bytenr + len > reserved->start) {
|
||||
len = min_t(u64, len, reserved->start - bytenr);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue