On 4.01.19 г. 12:26 ч., David Disseldorp wrote: > On Fri, 4 Jan 2019 09:05:00 +0200, Nikolay Borisov wrote: > >> btrfs inspect-internal dump-super already supports showing seeding, why >> do we need btrfstune support for that as well? > > Ah, I wasn't aware of that. IMO the logical place to look is next to > where the user enables seeding (btrfstune -S1). > >> Also the way you've >> phrased is a bit misleading, since checking the superflag doesn't mean >> seeding for a particular _device_ is enabled but that the filesystem >> itself is set as seeding. > > Not quite sure I follow. For a multi-dev FS (one seeding), I see: the seeding flag is a feature of the filesystem not any particular device in it. It's set per-superblock, the superblock on every device is (or should be) identical to the superblock on any other device. > > rapido1:/# btrfstune -s /dev/zram0 > Seeding flag is currently unset > rapido1:/# btrfstune -S 1 /dev/zram0 > rapido1:/# btrfstune -s /dev/zram0 > Seeding flag is currently set > rapido1:/# mount /dev/zram0 /mnt/test/ > mount: /dev/zram0 is write-protected, mounting read-only > ... > rapido1:/# btrfs device add -f /dev/zram1 /mnt/test/ > [ 77.805374] BTRFS info (device zram0): disk added /dev/zram1 > rapido1:/# umount /mnt/test/ > rapido1:/# btrfstune -s /dev/zram1 > Seeding flag is currently unset > rapido1:/# btrfstune -s /dev/zram0 > Seeding flag is currently set Right, i think this is a side effect rather than a deliberate behavior. What I mean by this is if you have a raid0 filesystem and you set it to seed then the flag will be reflected on both devices, but not because the code said "mark device 1 and device 2 as seed devices" but because the logic goes "mark this superblock as being a seed and write it to all devices". So when you actually add the new device to an existing filesystem which is seed what btrfs does is initialize a new filesystem on the newly added device. For reference you can check the code around btrfs_init_new_device and btrfs_prepare_sprout. IMO seed has really been hacked on "just because" and is lacking coherent design, I'd prefer it didn't proliferate and rely on what we have currently. > > Cheers, David >
