On Sat, Jul 22, 2017 at 06:15:58PM +0000, Hugo Mills wrote: > On Sat, Jul 22, 2017 at 12:06:17PM -0600, Chris Murphy wrote: > > I just did an additional test that's pretty icky behavior. > > > > 2x HDD device Btrfs volume. Add both devices and `btrfs devices ready` > > exits with 0 as expected. Physically remove both USB devices. > > Reconnect one device. `btrfs device ready` still exits 0. That's > > definitely not good. (If I leave that one device connected and reboot, > > `btrfs device ready` exits 1). > > In a slightly less-specific way, this has been a problem pretty > much since the inception of the FS. It's not possible to do the > reverse of the "scan" operation on a device -- that is, invalidate/ > remove the device's record in the kernel. So, as you've discovered > here, if you have a device which is removed (overwritten, unplugged), > the kernel still thinks it's a part of the FS.
Alas, this needs to be fixed. The reproducers I posted last week give data corruption in case a device that was once a part of the FS is reconnected. It doesn't matter what it contains now -- be it another part of the FS or something totally unrelated, as far as the device node (/dev/loop0, /dev/sda1, etc) is reused, degraded mounts get confused. It wasn't urgent before as degraded mounts were broken before Qu's chunk check patch (that's not even merged yet) -- but once running degraded is not an emergency, there'll be folks doing so for an extended time. > It's something I recall being talked about a bit, some years ago. I > don't recall now why it was going to be useful, though. I think you > have a good use-case for such a new ioctl (or extension to the > SCAN_DEV ioctl) now, though. Such an ioctl would be inherently racey. Even current udev code is -- mounting right after losetup often fails, sometimes you even need to sleep longer than 1 second. With the above in mind, I see no way other than invalidating and re-checking all known devices at mount time. Meow! -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢠⠒⠀⣿⡁ A dumb species has no way to open a tuna can. ⢿⡄⠘⠷⠚⠋⠀ A smart species invents a can opener. ⠈⠳⣄⠀⠀⠀⠀ A master species delegates. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html