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

Darrick J. Wong
2020-02-21T16:15:39Z

On Fri, Feb 21, 2020 at 07:03:39AM -0800, Christoph Hellwig wrote:
> On Wed, Feb 19, 2020 at 05:45:01PM -0800, Darrick J. Wong wrote:
> > @@ -1050,15 +1083,26 @@ libxfs_buf_read_map(struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
> > flags);
> > else
> > error = libxfs_readbufr_map(btp, bp, flags);
> > + if (error == -EIO && salvage)
> > + goto ok;
>
> 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.

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.

--D