From 907c5fd7a4bd7da62d6c7cb418e4df81ec77e2f5 Mon Sep 17 00:00:00 2001 From: Naohiro Aota Date: Tue, 6 Apr 2021 17:05:50 +0900 Subject: [PATCH] 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 Signed-off-by: Naohiro Aota Signed-off-by: David Sterba --- kernel-shared/volumes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index c493479e..264c1daa 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -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;