btrfs-progs: fix to use half the available space for DUP profile

In the DUP profile, we can use only half of the space available in a
device extent. Fix the calculation of calc_size for it.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Naohiro Aota 2021-04-06 17:05:50 +09:00 committed by David Sterba
parent 13a6cff8b6
commit 907c5fd7a4

View File

@ -1323,7 +1323,10 @@ again:
}
if (!looped && max_avail > 0) {
looped = 1;
ctl.calc_size = max_avail;
if (ctl.type & BTRFS_BLOCK_GROUP_DUP)
ctl.calc_size = max_avail / 2;
else
ctl.calc_size = max_avail;
goto again;
}
return -ENOSPC;