Re: [PATCH 16/21] xfs: improve detection of lost xfile contents

Matthew Wilcox
2024-01-28T20:33:31Z

On Sun, Jan 28, 2024 at 05:55:49PM +0100, Christoph Hellwig wrote:
> On Fri, Jan 26, 2024 at 04:33:40PM +0000, Matthew Wilcox wrote:
> > > +static inline bool
> > > +xfile_has_lost_data(
> > > + struct inode *inode,
> > > + struct folio *folio)
> > > +{
> > > + struct address_space *mapping = inode->i_mapping;
> > > +
> > > + /* This folio itself has been poisoned. */
> > > + if (folio_test_hwpoison(folio))
> > > + return true;
> > > +
> > > + /* A base page under this large folio has been poisoned. */
> > > + if (folio_test_large(folio) && folio_test_has_hwpoisoned(folio))
> > > + return true;
> > > +
> > > + /* Data loss has occurred anywhere in this shmem file. */
> > > + if (test_bit(AS_EIO, &mapping->flags))
> > > + return true;
> > > + if (filemap_check_wb_err(mapping, 0))
> > > + return true;
> > > +
> > > + return false;
> > > +}
> >
> > This is too much. filemap_check_wb_err() will do just fine for your
> > needs unless you really want to get fine-grained and perhaps try to
> > reconstruct the contents of the file.
>
> As in only call filemap_check_wb_err and do away with all the
> hwpoisoned checks and the extra AS_EIO check?

Yes, that's what i meant.