xfs_healer: fail earlier on non-xfs filesystems
PATCH 1/1 xfs_healer: fail earlier on non-xfs filesystems
From: Darrick J. Wong <[email protected]>
A Debian user reported that the root filesystem service fails with:
systemd[1]: Starting [email protected] - Self Healing of XFS Metadata for /... xfs_healer@-[976]: /: Inappropriate ioctl for device
systemd[1]: [email protected]: Condition check process exited, code=exited, status=255/EXCEPTION systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start [email protected] - Self Healing of XFS Metadata for /.
when the root filesystem is not XFS. It's most likely ext4 given Debian's defaults. However, the actual service failure here is a result of the ExecCondition program exiting with 255 instead of EXIT_FAILURE. EXIT_FAILURE is what we're supposed to return to mean "do not run service".
Note that xfs_healer@- is always started by systemd (and not xfs_healer_start) because the root filesystem is usually mounted before systemd starts.
stracing this program a litle further reveals this:
# strace -e ioctl /usr/libexec/xfsprogs/xfs_healer --supported / ioctl(3, _IOC(_IOC_READ, 0x58, 0x7e, 0x100), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x7c, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x64, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) /: Inappropriate ioctl for device
All three ioctls are XFS_IOC_FSGEOMETRY calls, and they all fail with ENOTTY because this is an ext4 filesystem. The fsgeometry call occurs under xfd_open(), so fix this error by special-casing the error return handling.
--- healer/xfs_healer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
healer/xfs_healer.c +10 -0
@@ -317,6 +317,16 @@ setup_monitor( ret =xfd_open (&ctx->mnt, ctx->mntpoint,O_RDONLY );if (ret) { +if (ret == -ENOTTY ) { +/* +* If this isn't even an XFS filesystem, the fsgeometry +* call will return ENOTTY. +*/ +fprintf (stderr,"%s: %s\n" , ctx->mntpoint, +_ ("XFS health monitoring not supported." )); +return MON_UNSUPPORTED ; + } +perror (ctx->mntpoint);return outcome; }
Re: Bug#1149571: [PATCH] xfs_healer: fail earlier on non-xfs filesystems
Quoted 48 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
A Debian user reported that the root filesystem service fails with:
systemd[1]: Starting [email protected] - Self Healing of XFS Metadata for /... xfs_healer@-[976]: /: Inappropriate ioctl for device
systemd[1]: [email protected]: Condition check process exited, code=exited, status=255/EXCEPTION systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start [email protected] - Self Healing of XFS Metadata for /.when the root filesystem is not XFS. It's most likely ext4 given Debian's defaults. However, the actual service failure here is a result of the ExecCondition program exiting with 255 instead of
EXIT_FAILURE.EXIT_FAILUREis what we're supposed to return to mean "do not run service".Note that xfs_healer@- is always started by systemd (and not
xfs_healer_start) because the root filesystem is usually mounted before systemd starts.stracing this program a litle further reveals this:
# strace -e ioctl /usr/libexec/xfsprogs/xfs_healer --supported / ioctl(3, _IOC(_IOC_READ, 0x58, 0x7e, 0x100), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x7c, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x64, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) /: Inappropriate ioctl for deviceAll three ioctls are
XFS_IOC_FSGEOMETRYcalls, and they all fail with ENOTTY because this is an ext4 filesystem. The fsgeometry call occurs underxfd_open(), so fix this error by special-casing the error return handling.Reported-by Michael Biebl <[email protected]>Cc <[email protected]> # v7.0.0Fixes ea178059ff72c3 ("xfs_healer: don't start service if kernel support unavailable")Signed-off-by "Darrick J. Wong" <[email protected]>--- healer/xfs_healer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)healer/xfs_healer.c +0
-0
healer/xfs_healer.c setup_monitor( · line 318
Quoted 2 lines
healer/xfs_healer.c +0
-0@@ -317,6 +317,16 @@ setup_monitor( ret =xfd_open (&ctx->mnt, ctx->mntpoint,O_RDONLY );
This probably should be ret = -xfd_open(...)? (not sure why xfd_open converts errno to negative but all other users convert it back)
healer/xfs_healer.c setup_monitor( · line 320
Quoted 2 lines
healer/xfs_healer.c +1
-0if (ret) { +if (ret == -ENOTTY ) {
Then, ret == ENOTTY
Signature · 1 line
- Andrey
Re: Bug#1149571: [PATCH] xfs_healer: fail earlier on non-xfs filesystems
Quoted 50 lines · Andrey Albershteyn
Quoted 49 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
A Debian user reported that the root filesystem service fails with:
systemd[1]: Starting [email protected] - Self Healing of XFS Metadata for /... xfs_healer@-[976]: /: Inappropriate ioctl for device
systemd[1]: [email protected]: Condition check process exited, code=exited, status=255/EXCEPTION systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start [email protected] - Self Healing of XFS Metadata for /.when the root filesystem is not XFS. It's most likely ext4 given Debian's defaults. However, the actual service failure here is a result of the ExecCondition program exiting with 255 instead of
EXIT_FAILURE.EXIT_FAILUREis what we're supposed to return to mean "do not run service".Note that xfs_healer@- is always started by systemd (and not
xfs_healer_start) because the root filesystem is usually mounted before systemd starts.stracing this program a litle further reveals this:
# strace -e ioctl /usr/libexec/xfsprogs/xfs_healer --supported / ioctl(3, _IOC(_IOC_READ, 0x58, 0x7e, 0x100), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x7c, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x64, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) /: Inappropriate ioctl for deviceAll three ioctls are
XFS_IOC_FSGEOMETRYcalls, and they all fail with ENOTTY because this is an ext4 filesystem. The fsgeometry call occurs underxfd_open(), so fix this error by special-casing the error return handling.Reported-by Michael Biebl <[email protected]>Cc <[email protected]> # v7.0.0Fixes ea178059ff72c3 ("xfs_healer: don't start service if kernel support unavailable")Signed-off-by "Darrick J. Wong" <[email protected]>--- healer/xfs_healer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)healer/xfs_healer.c +0
-0@@ -317,6 +317,16 @@ setup_monitor(
Quoted 4 lines
healer/xfs_healer.c setup_monitor( · line 318
Quoted 1 line
healer/xfs_healer.c +0
-0ret =xfd_open (&ctx->mnt, ctx->mntpoint,O_RDONLY );This probably should be ret = -xfd_open(...)? (not sure why
xfd_openconverts errno to negative but all other users convert it back)
Yeah, and the perror() call is incorrect too. I'll post a second patch to convert the callsite.
--D
Quoted 8 lines
healer/xfs_healer.c setup_monitor( · line 320
Quoted 2 lines
healer/xfs_healer.c +1
-0if (ret) { +if (ret == -ENOTTY ) {Then, ret == ENOTTY
Signature · 1 line
- Andrey
Am 01.10.26 um 08:23 schrieb Darrick J. Wong:
Quoted 4 lines
From: Darrick J. Wong <[email protected]>
A Debian user reported that the root filesystem service fails with:
Quoted 8 lines
systemd[1]: Starting [email protected] - Self Healing of XFS Metadata for /... xfs_healer@-[976]: /: Inappropriate ioctl for device
systemd[1]: [email protected]: Condition check process exited, code=exited, status=255/EXCEPTION systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start [email protected] - Self Healing of XFS Metadata for /.when the root filesystem is not XFS. It's most likely ext4 given Debian's defaults.
Fwiw, this assumption is correct. My / is using ext4.
Regards,
Michael
PATCH v2 1/1 xfs_healer: fix a user-reported bug
Hi all,
This bugfix series corrects a couple of problems in xfs_healer that were found by a Debian user.
v2: fix xfd_open callsite's use of error return values in addition to
fixing the reported problem, per maintainer
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
With a bit of luck, this should all go splendidly. Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=healer-fixes
---
Commits in this patchset:
* xfs_healer: correct xfd_ API usage
* xfs_healer: fail earlier on non-xfs filesystems
--- healer/xfs_healer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
PATCH 1/2 xfs_healer: correct xfd_ API usage
From: Darrick J. Wong <[email protected]>
This callsite is wrong -- the xfd_* functions return 0 on success or negative errno on failure, so we should be using strerror on the value provided, and not perror, which uses errno. Fix this to be consistent with the other xfsprogs utilities.
--- healer/xfs_healer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
healer/xfs_healer.c +2 -2
@@ -315,9 +315,9 @@ setup_monitor(int mon_fd;int ret; - ret =xfd_open (&ctx->mnt, ctx->mntpoint,O_RDONLY ); + ret = -xfd_open (&ctx->mnt, ctx->mntpoint,O_RDONLY );if (ret) { -perror (ctx->mntpoint); +fprintf (stderr,"%s: %s\n" , ctx->mntpoint,strerror (ret));return outcome; }
Re: [PATCH 1/2] xfs_healer: correct xfd_ API usage
Quoted 10 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
This callsite is wrong -- the xfd_* functions return 0 on success or negative errno on failure, so we should be using strerror on the value provided, and not perror, which uses errno. Fix this to be consistent with the other xfsprogs utilities.
Cc <[email protected]> # v7.0.0Fixes b9b03770197d19 ("xfs_healer: create daemon to listen for health events")Signed-off-by "Darrick J. Wong" <[email protected]>
Looks good to me
Signature · 1 line
- Andrey
PATCH 2/2 xfs_healer: fail earlier on non-xfs filesystems
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
A Debian user reported that the root filesystem service fails with:
systemd[1]: Starting [email protected] - Self Healing of XFS Metadata for /... xfs_healer@-[976]: /: Inappropriate ioctl for device
systemd[1]: [email protected]: Condition check process exited, code=exited, status=255/EXCEPTION systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start [email protected] - Self Healing of XFS Metadata for /.
when the root filesystem is not XFS. It's most likely ext4 given Debian's defaults. However, the actual service failure here is a result of the ExecCondition program exiting with 255 instead of EXIT_FAILURE. EXIT_FAILURE is what we're supposed to return to mean "do not run service".
Note that xfs_healer@- is always started by systemd (and not xfs_healer_start) because the root filesystem is usually mounted before systemd starts.
stracing this program a litle further reveals this:
# strace -e ioctl /usr/libexec/xfsprogs/xfs_healer --supported / ioctl(3, _IOC(_IOC_READ, 0x58, 0x7e, 0x100), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x7c, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x64, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) /: Inappropriate ioctl for device
All three ioctls are XFS_IOC_FSGEOMETRY calls, and they all fail with ENOTTY because this is an ext4 filesystem. The fsgeometry call occurs under xfd_open(), so fix this error by special-casing the error return handling.
--- healer/xfs_healer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
healer/xfs_healer.c +10 -0
@@ -317,6 +317,16 @@ setup_monitor( ret = -xfd_open (&ctx->mnt, ctx->mntpoint,O_RDONLY );if (ret) { +if (ret ==ENOTTY ) { +/* +* If the fsgeometry call returns ENOTTY, this isn't +* even an XFS filesystem. +*/ +fprintf (stderr,"%s: %s\n" , ctx->mntpoint, +_ ("XFS health monitoring not supported." )); +return MON_UNSUPPORTED ; + } +fprintf (stderr,"%s: %s\n" , ctx->mntpoint,strerror (ret));return outcome; }
Re: Bug#1149571: [PATCH 2/2] xfs_healer: fail earlier on non-xfs filesystems
Quoted 33 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
A Debian user reported that the root filesystem service fails with:
systemd[1]: Starting [email protected] - Self Healing of XFS Metadata for /... xfs_healer@-[976]: /: Inappropriate ioctl for device
systemd[1]: [email protected]: Condition check process exited, code=exited, status=255/EXCEPTION systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start [email protected] - Self Healing of XFS Metadata for /.when the root filesystem is not XFS. It's most likely ext4 given Debian's defaults. However, the actual service failure here is a result of the ExecCondition program exiting with 255 instead of
EXIT_FAILURE.EXIT_FAILUREis what we're supposed to return to mean "do not run service".Note that xfs_healer@- is always started by systemd (and not
xfs_healer_start) because the root filesystem is usually mounted before systemd starts.stracing this program a litle further reveals this:
# strace -e ioctl /usr/libexec/xfsprogs/xfs_healer --supported / ioctl(3, _IOC(_IOC_READ, 0x58, 0x7e, 0x100), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x7c, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, _IOC(_IOC_READ, 0x58, 0x64, 0x70), 0x7fffb2c5e6a8) = -1 ENOTTY (Inappropriate ioctl for device) /: Inappropriate ioctl for deviceAll three ioctls are
XFS_IOC_FSGEOMETRYcalls, and they all fail with ENOTTY because this is an ext4 filesystem. The fsgeometry call occurs underxfd_open(), so fix this error by special-casing the error return handling.
Quoted 6 lines
Reported-by Michael Biebl <[email protected]>Cc <[email protected]> # v7.0.0Fixes bf8b99270c6be1 ("xfs_healer: use the autofsck fsproperty to select mode")Signed-off-by "Darrick J. Wong" <[email protected]>
Looks good to me
Signature · 1 line
- Andrey