#866734 btrfs-progs: btrfs replace fails with unknown error

Package:
btrfs-progs
Source:
btrfs-progs
Description:
Checksumming Copy on Write Filesystem utilities
Submitter:
Russell Coker
Date:
2025-12-09 14:41:03 UTC
Severity:
normal
#866734#5
Date:
2017-07-01 10:40:05 UTC
From:
To:
First I don't know if this is a btrfs-progs error or a kernel error.  But when
in doubt it seems most reasonable to file against btrfs-progs to get the
attention of someone who can help work this out.  Even if the kernel is doing
the wrong thing the utility should be able to be more helpful in it's error
messages.

# btrfs replace start -B 3 /dev/sdd2 /
ERROR: ioctl(DEV_REPLACE_START) on '/' returns error: <illegal result value>
# btrfs replace start -B /dev/sdb2 /dev/sdd2 /
ERROR: ioctl(DEV_REPLACE_START) on '/' returns error: <illegal result value>
# btrfs replace start -B /dev/sdc2 /dev/sdd2 /
ERROR: ioctl(DEV_REPLACE_START) on '/' returns error: <illegal result value>
# btrfs replace start -B 1 /dev/sdd2 /
ERROR: ioctl(DEV_REPLACE_START) on '/' returns error: <illegal result value>

The above is the result of some routine device replacement commands.

# btrfs device usage /
/dev/sda2, ID: 2
   Device size:           446.67GiB
   Device slack:              0.00B
   Data,RAID1:            329.40GiB
   Metadata,RAID1:          5.00GiB
   System,RAID1:           32.00MiB
   Unallocated:           112.24GiB

/dev/sdb2, ID: 3
   Device size:           111.32GiB
   Device slack:              0.00B
   Data,RAID1:            111.32GiB
   Unallocated:             1.02MiB

/dev/sdc2, ID: 1
   Device size:           223.10GiB
   Device slack:              0.00B
   Data,RAID1:            218.07GiB
   Metadata,RAID1:          5.00GiB
   System,RAID1:           32.00MiB
   Unallocated:             1.02MiB

From the above you can see that IDs 3 and 1 and devices /dev/sdb2 and /dev/sdc2
are part of the filesystem and suitable for replacement.

https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices#Replacing_failed_devices

btrfs-replace(8) and the above Wiki page both indicate that what I am
attempting is correct.

#866734#10
Date:
2017-12-10 23:06:54 UTC
From:
To:
Hi Russel,

I just observed similar symptoms.

Check if there is a add/delete/balance/replace/resize running on the
file system.

In my case, there was a paused balance that I wasn't aware of (since
weeks? Months? …?).

Cheers,

Lukas

#866734#15
Date:
2018-07-22 23:27:19 UTC
From:
To:
When I first saw this last year Lukas correctly identified the problem, sorry
for not mentioning this.

Now it happened again and it turned out that this bug report was one of only 2
google hits about it.  I had forgotten about having this problem before.

Could you please patch the btrfs utility to give a hint to the user that a
paused balance might be the culprit?