Re: [RFC][PATCH 00/25] Network fs helper library & fscache kiocb API

J. Bruce Fields
2021-01-21T17:45:10Z

On Thu, Jan 21, 2021 at 05:02:57PM +0000, David Howells wrote:
> J. Bruce Fields <bfields@fieldses.org> wrote:
>
> > On Wed, Jan 20, 2021 at 10:21:24PM +0000, David Howells wrote:
> > > Note that this uses SEEK_HOLE/SEEK_DATA to locate the data available
> > > to be read from the cache. Whilst this is an improvement from the
> > > bmap interface, it still has a problem with regard to a modern
> > > extent-based filesystem inserting or removing bridging blocks of
> > > zeros.
> >
> > What are the consequences from the point of view of a user?
>
> The cache can get both false positive and false negative results on checks for
> the presence of data because an extent-based filesystem can, at will, insert
> or remove blocks of contiguous zeros to make the extents easier to encode
> (ie. bridge them or split them).
>
> A false-positive means that you get a block of zeros in the middle of your
> file that very probably shouldn't be there (ie. file corruption); a
> false-negative means that we go and reload the missing chunk from the server.
>
> The problem exists in cachefiles whether we use bmap or we use
> SEEK_HOLE/SEEK_DATA. The only way round it is to keep track of what data is
> present independently of backing filesystem's metadata.
>
> To this end, it shouldn't (mis)behave differently than the code already there
> - except that it handles better the case in which the backing filesystem
> blocksize != PAGE_SIZE (which may not be relevant on an extent-based
> filesystem anyway if it packs parts of different files together in a single
> block) because the current implementation only bmaps the first block in a page
> and doesn't probe for the rest.
>
> Fixing this requires a much bigger overhaul of cachefiles than this patchset
> performs.

That sounds like "sometimes you may get file corruption and there's
nothing you can do about it". But I know people actually use fscache,
so it must be reliable at least for some use cases.

Is it that those "bridging" blocks only show up in certain corner cases
that users can arrange to avoid? Or that it's OK as long as you use
certain specific file systems whose behavior goes beyond what's
technically required by the bamp or seek interfaces?

--b.

>
> Also, it works towards getting rid of this use of bmap, but that's not user
> visible.
>
> David