Re: [PATCH 01/25] libxfs: open-code "exit on buffer read failure" in upper level callers

Darrick J. Wong
2020-02-25T19:19:14Z

On Tue, Feb 25, 2020 at 10:42:40AM -0800, Christoph Hellwig wrote:
> On Tue, Feb 25, 2020 at 10:40:23AM -0800, Darrick J. Wong wrote:
> > Prior to this patch, the "!(flags & DEBUGGER)" expressions in the call
> > sites evaluate to 0 or 1, and this effectively results in libxfs_mount
> > passing EXIT_ON_FAILURE to the buffer read functions as the flag value.
> > The flag value is passed all the way down to __read_buf, and when it
> > sees an IO failure, it exits.
> >
> > After this patch, libxfs_mount passes flags==0, which means that we get
> > a buffer back, possibly with b_error set. If b_error is set, we log a
> > warning about the screwed up filesystem and return a null mount if the
> > libxfs_mount caller didn't indicate that it is a debugger. Presumably
> > the libxfs_mount caller will exit with error if we return a null mount.
> >
> > IOWs, I'm doing exactly what the commit message says, but in a rather
> > subtle way. I'll clarify that, if you'd like.
>
> Ok, with a proper commit message this looks good to me:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

The new commit message reads as follows:

"libxfs: open-code "exit on buffer read failure" in upper level callers

"Make all functions that use LIBXFS_EXIT_ON_FAILURE to abort on buffer
read errors implement that logic themselves. This also removes places
where libxfs can abort the program with no warning.

"Note that in libxfs_mount, the "!(flags & DEBUGGER)" code would
indirectly select LIBXFS_EXIT_ON_FAILURE, so we're replacing the hidden
library exit(1) with a null xfs_mount return, which should cause the
utilities to exit with an error."

--D