On 05/04/2016 01:31 AM, David Sterba wrote: > On Thu, Apr 14, 2016 at 06:24:10PM +0800, Anand Jain wrote: >> Yauhen reported in the ML that s_bdev is null at mount, and >> s_bdev gets updated to some device when missing device is >> replaced, as because bdev is null for missing device, things >> gets matched up. Fix this by checking if s_bdev is set. I >> didn't want to completely remove updating s_bdev because >> the future multi device support at vfs layer may need it. >> >> Signed-off-by: Anand Jain >> Reported-by: Yauhen Kharuzhy > > Do you have a testcase for that? For this particular bug/fix no. As I went through the vfs layer to understand the s_bdev usage. It appears that s_bdev is used for fsync. But btrfs kept s_bdev NULL, which will make vfs layer to fail safe in that context. We need to continue to keep s_bdev null, even after the replace missing. The bug is that it didn't. As shown below. mkfs.btrfs -f -draid1 -mraid1 /dev/sdc /dev/sdd /dev/sde modprobe -r btrfs && modprobe btrfs mount -o degraded,device=/dev/sdc /dev/sde /btrfs ----- cat /proc/fs/btrfs/fsinfo [1] [fsid: 60ca666b-83e8-4a28-a0cb-9b7ddb0451e2] sb->s_bdev: null latest_bdev: sde ----- btrfs repl start 2 /dev/sdf /btrfs -f ----- cat /proc/fs/btrfs/fsinfo [fsid: 60ca666b-83e8-4a28-a0cb-9b7ddb0451e2] sb->s_bdev: sdf latest_bdev: sde ----- > As there are more patches touching the > device pointers I'd rather see some test coverage. Thanks. Hm, yes the btrfs-vm test coverage needs a review at xfstests. Let me try. For my quick verifications, I have been using.. https://github.com/asj/exercise-btrfs-volume-mgt.git has around quick 30+ btrfs-vm related tests. But very raw. Omar added test case 027 to test replace missing. The for-next plus 3 patches[2] passes 027 as well. Do you have any particular test coverage idea in mind ? Thanks, Anand [1] For /proc/fs/btrfs/fsinfo see attached which should be applied on top of the patch. [PATCH] btrfs: procfs: devlist: introduce /proc/fs/btrfs/devlist [2] 86eb5d598d58 btrfs: cleanup assigning next active device with a check 7b09eb01d80c btrfs: s_bdev is not null after missing replace 6237a895bc31 btrfs: fix lock dep warning move scratch super outside of chunk_mutex