xfs: clarify documentation for the function to reverify buffers

Improve the documentation around xfs_buf_ensure_ops, which is the
function that is responsible for cleaning up the b_ops state of buffers
that go through xrep_findroot_block but don't match anything.  Rename
the function to xfs_buf_reverify.

[darrick: this started off as bfoster mods of a previous patch of mine,
but the renaming part is now this separate patch.]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
Brian Foster 2019-02-06 09:25:29 -08:00 committed by Darrick J. Wong
parent 9b24717979
commit 75d0230314
3 changed files with 17 additions and 22 deletions

View File

@ -776,29 +776,24 @@ _xfs_buf_read(
} }
/* /*
* Set buffer ops on an unchecked buffer and validate it, if possible. * Reverify a buffer found in cache without an attached ->b_ops.
* *
* If the caller passed in an ops structure and the buffer doesn't have ops * If the caller passed an ops structure and the buffer doesn't have ops
* assigned, set the ops and use them to verify the contents. If the contents * assigned, set the ops and use it to verify the contents. If verification
* cannot be verified, we'll clear XBF_DONE. We assume the buffer has no * fails, clear XBF_DONE. We assume the buffer has no recorded errors and is
* recorded errors and is already in XBF_DONE state. * already in XBF_DONE state on entry.
* *
* Under normal operations, every in-core buffer must have buffer ops assigned * Under normal operations, every in-core buffer is verified on read I/O
* to them when the buffer is read in from disk so that we can validate the * completion. There are two scenarios that can lead to in-core buffers without
* metadata. * an assigned ->b_ops. The first is during log recovery of buffers on a V4
* * filesystem, though these buffers are purged at the end of recovery. The
* However, there are two scenarios where one can encounter in-core buffers * other is online repair, which intentionally reads with a NULL buffer ops to
* that don't have buffer ops. The first is during log recovery of buffers on * run several verifiers across an in-core buffer in order to establish buffer
* a V4 filesystem, though these buffers are purged at the end of recovery. * type. If repair can't establish that, the buffer will be left in memory
* * with NULL buffer ops.
* The other is online repair, which tries to match arbitrary metadata blocks
* with btree types in order to find the root. If online repair doesn't match
* the buffer with /any/ btree type, the buffer remains in memory in DONE state
* with no ops, and a subsequent read_buf call from elsewhere will not set the
* ops. This function helps us fix this situation.
*/ */
int int
xfs_buf_ensure_ops( xfs_buf_reverify(
struct xfs_buf *bp, struct xfs_buf *bp,
const struct xfs_buf_ops *ops) const struct xfs_buf_ops *ops)
{ {
@ -840,7 +835,7 @@ xfs_buf_read_map(
return bp; return bp;
} }
xfs_buf_ensure_ops(bp, ops); xfs_buf_reverify(bp, ops);
if (flags & XBF_ASYNC) { if (flags & XBF_ASYNC) {
/* /*

View File

@ -385,6 +385,6 @@ extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int);
#define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev) #define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev)
#define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev) #define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev)
int xfs_buf_ensure_ops(struct xfs_buf *bp, const struct xfs_buf_ops *ops); int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops);
#endif /* __XFS_BUF_H__ */ #endif /* __XFS_BUF_H__ */

View File

@ -277,7 +277,7 @@ xfs_trans_read_buf_map(
* release this buffer when it kills the tranaction. * release this buffer when it kills the tranaction.
*/ */
ASSERT(bp->b_ops != NULL); ASSERT(bp->b_ops != NULL);
error = xfs_buf_ensure_ops(bp, ops); error = xfs_buf_reverify(bp, ops);
if (error) { if (error) {
xfs_buf_ioerror_alert(bp, __func__); xfs_buf_ioerror_alert(bp, __func__);