On Mon, May 08, 2023 at 07:50:55PM +0800, Qu Wenruo wrote: > On 2023/5/8 19:27, Anand Jain wrote: > > On 05/05/2023 21:38, David Sterba wrote: > >> On Fri, May 05, 2023 at 03:21:35PM +0800, Qu Wenruo wrote: > >>> On 2023/5/5 01:07, Guilherme G. Piccoli wrote: > >> This is actually a good point, we can do that already. As a conterpart > >> to 5f58d783fd7823 ("btrfs: free device in btrfs_close_devices for a > >> single device filesystem") that drops single device from the list, > >> single fs devices wouldn't be added to the list but some checks could be > >> still done like superblock validation for eventual error reporting. > > > > Something similar occurred to me earlier. However, even for a single > > device, we need to perform the scan because there may be an unfinished > > replace target from a previous reboot, or a sprout Btrfs filesystem may > > have a single seed device. If we were to make an exception for replace > > targets and seed devices, it would only complicate the scan logic, which > > goes against our attempt to simplify it. > > If we go SINGLE_DEV compat_ro flags, then no such problem at all, we can > easily reject any multi-dev features from such SINGLE_DEV fs. With the scanning complications that Anand mentions the compat_ro flag might make more sense, with all the limitations but allowing a safe use of the duplicated UUIDs. The flag would have to be set at mkfs time or by btrfsune on an unmounted filesystem. Doing that on a mounted filesystem is possible too but brings problems with updating the state of scanned device, potentially ongoing operations like dev-replace and more.