Re: [PATCH 05/14] libxfs: make libxfs_buf_read_map return an error code

Christoph Hellwig
2020-02-21T16:28:40Z

On Fri, Feb 21, 2020 at 08:15:30AM -0800, Darrick J. Wong wrote:
> > I understand the part about skipping the verifiers. But how does ignoring
> > EIO in this case fir the scheme?
>
> "Salvage" mode means that the caller wants an xfs_buf even if the
> contents are invalid or missing due to EIO. This is useful for db and
> repair because we can fill the buffer with fixed or new metadata and
> write it back to disk.

I thought the aim was to look at the buffer for the content even if
said content fails the verifiers, for which it makes sense to me.

> On a practical level this means I don't have to amend all callsites:
>
> err = libxfs_buf_read(...LIBXFS_READBUF_SALVAGE..., &bp);
> if (err == -EIO)
> err = libxfs_buf_get(..., &bp);
> if (err)
> goto barf;
>
> ...since EIO doesn't seem that much more special than EFSCORRUPTED.

I actually prefer that, as it really documents what is going on. That
being said if reading the block fails with EIO chances are writing will
fail as well..