Re: [PATCH RFC 2/2] block: Do not discard buffers under a mounted filesystem

Jan Kara
2020-08-28T08:10:39Z

On Fri 28-08-20 10:07:05, Dave Chinner wrote:
> On Thu, Aug 27, 2020 at 10:39:00PM +0100, Al Viro wrote:
> > On Thu, Aug 27, 2020 at 08:16:03AM +0100, Christoph Hellwig wrote:
> > > On Tue, Aug 25, 2020 at 04:50:56PM +0200, Jan Kara wrote:
> > > > Do you mean that address_space filesystem uses to access its metadata on
> > > > /dev/sda will be different from the address_space you will see when reading
> > > > say /dev/sda? Thus these will be completely separate (and incoherent)
> > > > caches?
> > >
> > > Yes.
> > >
> > > > Although this would be simple it will break userspace I'm afraid.
> > > > There are situations where tools read e.g. superblock of a mounted
> > > > filesystem from the block device and rely on the data to be reasonably
> > > > recent. Even worse e.g. tune2fs or e2fsck can *modify* superblock of a
> > > > mounted filesystem through the block device (e.g. to set 'fsck after X
> > > > mounts' fields and similar).
> > >
> > > We've not had any problems when XFS stopped using the block device
> > > address space 9.5 years ago.
> >
> > How much writes from fsck use does xfs see, again?
>
> All of them, because xfs_repair uses direct IO and caches what it
> needs in userspace.

But that's the difference. e2fsprogs (which means e2fsck, tune2fs, or
generally libext2fs which is linked against quite a few external programs
as well) use buffered IO so they rely on cache coherency between what the
kernel filesystem driver sees and what userspace sees when opening the
block device. That's why I'm concerned that loosing this coherency is going
to break some ext4 user... I'll talk to Ted what he thinks about this but
so far I don't see how to separate kernel's view of the bdev from userspace
view without breakage.

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR