Re: [PATCH v3 0/5] btrfs: remove buffer heads form superblock handling

Johannes Thumshirn
2020-01-31T13:43:23Z

On 30/01/2020 17:16, David Sterba wrote:
> I'd like to remove the buffer_head interface in two steps. First remove
> the wrappers and open code the calls, so the functionality is unchanged.
> Then have another look if we can optimize that further, eg. removing the
> page cache.
>
> We've had subtle bugs when mount/scanning ioctl/mkfs interacted and did
> not see a consistent state. See 6f60cbd3ae442cb35861bb522f388db123d42ec1
> ("btrfs: access superblock via pagecache in scan_one_device"). It's been
> a few years so I don't recall all details, but it was quite hard to
> catch. Mkfs followed by mount sometimes did not work.
>
> So page cache is the common access point for all the parts and for now
> we rely on that. If removing is possible, I'd like to see a good
> explanation why and not such change lost in a well meant cleanup.
>

I have a local version now, where btrfs_read_dev_one_super() uses
read_cache_page_gfp() and btrfs_scratch_superblocks() uses
write_one_page() offloading all the I/O to the pagecache. So far this
works as expected.

Now when I started converting write_dev_supers() and friends I wasn't
sure if I can/should mix up read_cache_page_gfp() and submit_bio_wait().
I could also convert it to write_one_page() but this way we would loose
integrity checking for the super block.

Any advice?