xfs: clean up scrub context if scrub setup returns -EDEADLOCK
authorDarrick J. Wong <djwong@kernel.org>
Wed, 12 Apr 2023 01:59:59 +0000 (18:59 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 12 Apr 2023 01:59:59 +0000 (18:59 -0700)
commit3f64c718d06eae168208faaadb522007e0048e7b
treed23904ad419b27aa436e51e6772408b6f35cfb2a
parentd5c88131dbf01a30a222ad82d58e0c21a15f0d8e
xfs: clean up scrub context if scrub setup returns -EDEADLOCK

It has been a longstanding convention that online scrub and repair
functions can return -EDEADLOCK to signal that they weren't able to
obtain some necessary resource.  When this happens, the scrub framework
is supposed to release all resources attached to the scrub context, set
the TRY_HARDER flag in the scrub context flags, and try again.  In this
context, individual scrub functions are supposed to take all the
resources they (incorrectly) speculated were not necessary.

We're about to make it so that the functions that lock and wait for a
filesystem AG can also return EDEADLOCK to signal that we need to try
again with the drain waiters enabled.  Therefore, refactor
xfs_scrub_metadata to support this behavior for ->setup() functions.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/scrub/scrub.c