Bug 1012254

Summary: btrfs replace should print meaningful error message when dealing with RAID5/RAID6
Product: Red Hat Enterprise Linux 7 Reporter: Eryu Guan <eguan>
Component: btrfs-progsAssignee: fs-maint
Status: CLOSED CURRENTRELEASE QA Contact: Filesystem QE <fs-qe>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: esandeen, xuw
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-22 00:13:59 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Eryu Guan 2013-09-26 01:58:22 EDT
Description of problem:
btrfs replace cannot handle RAID5 and RAID6, it only gives out EINVAL, user has to check dmesg for the reason of EINVAL

# btrfs replace start -B /dev/loop2 /dev/loop3 /mnt/btrfs
ERROR: ioctl(DEV_REPLACE_START) failed on "/mnt/btrfs": Invalid argument, no error
# dmesg | tail -1
btrfs: dev_replace cannot yet handle RAID5/RAID6

btrfs should print the meaningful error reason to stderr. Not a big problem but kind of inconvenient.

Version-Release number of selected component (if applicable):
btrfs-progs-0.20.rc1.20130308git704a08c-1.el7

Current upstream btrfs-progs has this issue too, HEAD is
194aa4a btrfs-restore: deal with NULL returns from read_node_slot

How reproducible:
always

Steps to Reproduce:
1. mkfs -t btrfs -m raid5 -d raid5 /dev/loop[0-2]
2. mount /dev/loop0 /mnt/btrfs
3. btrfs replace start -B /dev/loop2 /dev/loop3

Actual results:
# btrfs replace start -B /dev/loop2 /dev/loop3 /mnt/btrfs
ERROR: ioctl(DEV_REPLACE_START) failed on "/mnt/btrfs": Invalid argument, no error
# dmesg | tail -1
btrfs: dev_replace cannot yet handle RAID5/RAID6

Expected results:
btrfs prints error and the reason to stderr

Additional info:
Comment 3 Eric Sandeen 2015-04-17 17:30:15 EDT
btrfs-progs 3.19.1 has been built for RHEL7.2; if possible, please retest this bug against that version to see if your problem has been resolved.

Thanks,
-Eric
Comment 4 XuWang 2015-04-21 23:39:04 EDT
Raid5/6 replaced is introduced since kernel-3.10.0-237, so only to this bug, it can be set to be virified.
And I also test it with the btrfs-progs test case "/btrfs-progs/Regression/bz1012254-support-replace-raid56", works fine. The result is lile below:

:: [ 11:29:55 ] :: [ WARNING ] :: POSIX mode detected and switched off
:: [ 11:29:55 ] :: [ WARNING ] :: Please fix your test to have /bin/bash shebang

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [  BEGIN   ] :: Running 'setup_devs'
:: [   PASS   ] :: Command 'setup_devs' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'mkdir -p /mnt/btrfs'
:: [   PASS   ] :: Command 'mkdir -p /mnt/btrfs' (Expected 0, got 0)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [  BEGIN   ] :: Running 'mkfs -t btrfs -f -m raid5 -d raid5 /dev/loop1 /dev/loop2 /dev/loop3'
btrfs-progs v3.19.1
See http://btrfs.wiki.kernel.org for more information.

Performing full device TRIM (1.00GiB) ...
Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
Turning ON incompat feature 'raid56': raid56 extended format
Turning ON incompat feature 'skinny-metadata': reduced-size metadata extent refs
Performing full device TRIM (1.00GiB) ...
adding device /dev/loop2 id 2
Performing full device TRIM (1.00GiB) ...
adding device /dev/loop3 id 3
fs created label (null) on /dev/loop1
	nodesize 16384 leafsize 16384 sectorsize 4096 size 3.00GiB
:: [   PASS   ] :: Command 'mkfs -t btrfs -f -m raid5 -d raid5 /dev/loop1 /dev/loop2 /dev/loop3' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'mount /dev/loop1 /mnt/btrfs'
:: [   PASS   ] :: Command 'mount /dev/loop1 /mnt/btrfs' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'btrfs replace start -B -f /dev/loop1 /dev/loop0 /mnt/btrfs'
:: [   PASS   ] :: Command 'btrfs replace start -B -f /dev/loop1 /dev/loop0 /mnt/btrfs' (Expected 0, got 0)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Cleanup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [  BEGIN   ] :: Running 'cleanup'
:: [   PASS   ] :: Command 'cleanup' (Expected 0, got 0)
Comment 5 Eryu Guan 2015-04-22 00:13:59 EDT
btrfs supports replace raid5/6 now and no error message is needed from btrfs-progs, I think we can just close this bug now.