xfs: fix incorrect return values in online fsck

Here we fix a couple of problems with the errno values that we return to
 userspace.
 
 v23.2: fix vague wording of comment
 v23.3: fix the commit message to discuss what's really going on in this
 patch
 
 Signed-off-by: Darrick J. Wong <djwong@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEUzaAxoMeQq6m2jMV+H93GTRKtOsFAmN1fwkACgkQ+H93GTRK
 tOtqHxAAiKPUgjMDRHIBmVTYEmHo0QuxnBcPAMUmwlX5sAjtVZFHnIZ1ChfdR/K2
 eDzfFLbNnxyW8HdkI6O7aP7XD/HVFkKRmzWdVkzA463scaFnCVrLl8NDecmZRtVS
 TTHCCnDmzdZYM2uDayPJyZAHKZZejp6j33+N6bFBwtNYij9yBEFkHyIP+xZRmPVr
 RU1rzzmXhrZqB3ci/8bfOQbkaGzotEAu6R+pFddvMQ55hSwtY7OZ1IctlqHkRlks
 H86jGbcd8KNsi0SKo0RN+IuS2LtZNesI0Sm95LUOn1HnlEtmeHrJZYqC5WrKB3cn
 gUKJlzgEaDU7eCjMhd6TolqE6zNi/3xMaqjxS/Utoe3wSwSkQvGFVIuJiew7OXFQ
 BIDXxpOV/4C+vyi83CDcD147iLXJqz3RFECMD1HXDClYDXEEu9Qk3shJaDQQsOS/
 Ddn7UhuF80JcFsf0ZjpwuLwJdsAvDGruD/652V/3D3zkOHiqL9ejMI/InHuU/Fnu
 zGeignES4yVcJZMeOL8+crYM1EHGYjZRwe8qOEv4ufND+LnwAu71vyGmtfVqdki5
 Qo3n0x1K0dk0Um+YPJrZSfeuSNdpGfBexR1rvWOdAuPJfrizaqHmWg/7fs3ZNSqG
 Zfye7jpUcFNt8cxLmwHcNPxI5ll7Kev/4eaWzsz23v4ZTP39m0A=
 =UIK1
 -----END PGP SIGNATURE-----

Merge tag 'scrub-fix-return-value-6.2_2022-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.2-mergeA

xfs: fix incorrect return values in online fsck

Here we fix a couple of problems with the errno values that we return to
userspace.

v23.2: fix vague wording of comment
v23.3: fix the commit message to discuss what's really going on in this
patch

Signed-off-by: Darrick J. Wong <djwong@kernel.org>

* tag 'scrub-fix-return-value-6.2_2022-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: don't return -EFSCORRUPTED from repair when resources cannot be grabbed
  xfs: don't retry repairs harder when EAGAIN is returned
  xfs: fix return code when fatal signal encountered during dquot scrub
  xfs: return EINTR when a fatal signal terminates scrub
This commit is contained in:
Darrick J. Wong 2022-11-16 19:18:54 -08:00
commit 3d8426b13b
3 changed files with 9 additions and 5 deletions

View File

@ -25,7 +25,7 @@ xchk_should_terminate(
if (fatal_signal_pending(current)) {
if (*error == 0)
*error = -EAGAIN;
*error = -EINTR;
return true;
}
return false;

View File

@ -84,7 +84,7 @@ xchk_quota_item(
int error = 0;
if (xchk_should_terminate(sc, &error))
return -ECANCELED;
return error;
/*
* Except for the root dquot, the actual dquot we got must either have

View File

@ -61,7 +61,6 @@ xrep_attempt(
sc->flags |= XREP_ALREADY_FIXED;
return -EAGAIN;
case -EDEADLOCK:
case -EAGAIN:
/* Tell the caller to try again having grabbed all the locks. */
if (!(sc->flags & XCHK_TRY_HARDER)) {
sc->flags |= XCHK_TRY_HARDER;
@ -70,10 +69,15 @@ xrep_attempt(
/*
* We tried harder but still couldn't grab all the resources
* we needed to fix it. The corruption has not been fixed,
* so report back to userspace.
* so exit to userspace with the scan's output flags unchanged.
*/
return -EFSCORRUPTED;
return 0;
default:
/*
* EAGAIN tells the caller to re-scrub, so we cannot return
* that here.
*/
ASSERT(error != -EAGAIN);
return error;
}
}