On 3/26/20 9:30 AM, Marc MERLIN wrote:
On Thu, Mar 26, 2020 at 07:56:10AM +0800, Anand Jain wrote:
Are users really supposed to know this?
Why does btrfs device scan not invalidate the cache of devices and keep
remembering a device that's gone (not visible in new scan)?
btrfs device scan --forget is only useful to cleanup the unmounted
devices, per the logs below the device was mounted when it disappeared.
More below.
I'm confused: why is --forget even needed? Why would it remember devices
that were unmounted and not part of a new scan?
And yes, the device was not unmounted. The sata layer failed, device
disappeared while mounted and then re-appeared
I was able to force umount the mountpoints, so maybe --forget would have
helped, but I'm confused as to why it even exists.
We would log the below only if the old device sde is still in mounted
state. Unfortunately we don't have the unmount event log yet (patches
are in the ML) so we don't know if unmount was successful.
[2560416.434529] BTRFS warning (device sde1): duplicate device
fsid:devid for 727c7ba3-f6f9-462a-8472-453dd7d46d8a:1 old:/dev/sde1
new:/dev/sdq1
If the device is unmounted, the scan would have replaced the sde
to sdi, unless the sde (stale) generation is > generation in sdi
(lost commit). In which case the --forget is useful to remove the
state device entry (provided device is unmounted).
This indicates the device was mounted when it disappeared. So it
re-appears with the new path, but as its fsid+uuid+devid matches
with the old still mounted device we rightly consider it as an
alien device and fail the mount.
It was unmounted after disappearing, see the 'grep sde /proc/mounts'
showing that it wasn't mounted anymore, so it seems that even that part
didn't work as intended?
Its strange /proc/mounts doesn't list sde. Could you please send me
complete kernel logs. Lets try if there is any clue.
I tried to reproduce.. but in my case the unmount was successful.
$ mkfs.btrfs -fq /dev/sdc && mount /dev/sdc /btrfs
$ devmgt show | grep sdc
host2 sdc
$ devmgt detach /dev/sdc
::
detach /dev/sdc successful
$ devmgt attach host2
::
sd 2:0:0:0: [sdb] Attached SCSI disk
::
BTRFS warning (device sdc): duplicate device fsid:devid for
dcbc5603-e1cf-4d8d-9ec2-832bc3ac4e36:1 old:/dev/sdc new:/dev/sdb
------------------
attach host2 successful
mounts shows sdc is in ro.
$ cat /proc/mounts | grep sdc
/dev/sdc /btrfs btrfs ro,relatime,noacl,space_cache,subvolid=5,subvol=/ 0 0
$ dmesg -k | tail
[ 1427.268767] BTRFS warning (device sdc): duplicate device fsid:devid
for dcbc5603-e1cf-4d8d-9ec2-832bc3ac4e36:1 old:/dev/sdc new:/dev/sdb
$ umount /dev/sdc
Unfortunately there is no log about the unmount :-(.
And the following device scan replaces the sdc with sdb.
$ btrfs dev scan
Scanning for Btrfs filesystems
$ cat /proc/fs/btrfs/devlist | grep sdc
$ cat /proc/fs/btrfs/devlist | grep sdb
device: /dev/sdb
$
And mount is successful.
$ mount /dev/sdb /btrfs
Thanks, Anand
Marc