Bug 246201

Summary: fsck: Does not honour /etc/fstab "failok" option (mount does)
Product: Base System Reporter: Scott Aitken <freebsd-bugzilla>
Component: binAssignee: freebsd-fs (Nobody) <fs>
Status: Closed FIXED    
Severity: Affects Some People CC: fuz, grahamperrin, mckusick, rew
Priority: --- Keywords: easy, needs-patch
Version: 12.1-RELEASEFlags: koobs: maintainer-feedback? (mckusick)
koobs: maintainer-feedback? (rew)
koobs: mfc-stable13?
koobs: mfc-stable12?
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=163668

Description Scott Aitken 2020-05-04 23:59:08 UTC
When the /etc/fstab option "failok" is configured for a UFS device which may, at times, be missing, boot still fails (drops into single-user mode).

This is because fsck also runs against /etc/fstab, and considers the missing device to be a failure condition.

fsck should be patched to also continue, possibly returning a different return code.

Bug 163668 fixed the missing device issue in mount, but fsck was never taken into account (that I can see).
Comment 1 Kirk McKusick freebsd_committer freebsd_triage 2021-11-30 14:15:19 UTC
I concur that fsck_ffs should honor the /etc/fstab option "failok".
It should exit(0) when a device open fails for a "failok" entry.
I will look at getting that added.
Comment 2 Robert Clausecker freebsd_committer freebsd_triage 2021-11-30 14:22:08 UTC
(In reply to Kirk McKusick from comment #1)

Hi Kirk,

Isn't this better solved in fsck(8)?  If you address this in fsck_ffs(8), the problem will still exist for other file systems.

Also, suppose the device open succeeds but the fsck fails (e.g. because the device is flaky), this would still send the system back to single user mode.  I expect "failok" to mean "do not interrupt boot if there is a problem with this fstab entry under any circumstances."
Comment 3 Kirk McKusick freebsd_committer freebsd_triage 2021-12-04 06:26:38 UTC
(In reply to Robert Clausecker from comment #2)
You are right, I do have an fsck_ffs-centric view of fsck :-)
It should be handled in fsck.
Comment 4 Kirk McKusick freebsd_committer freebsd_triage 2021-12-14 00:35:05 UTC
Proposed fix is in https://reviews.freebsd.org/D33424
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-12-16 00:54:21 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c72372c693b36058b58a525981e833515ce8e441

commit c72372c693b36058b58a525981e833515ce8e441
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2021-12-16 00:51:55 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2021-12-16 00:53:46 +0000

    Update fsck(8) to ignore failures from a check program for a filesystem
    when the fstab(5) entry for the filesystem has the "failok" attribute.

    Reviewed by:  kib
    PR:           246201
    MFC after:    2 weeks
    Sponsored by: Netflix
    Differential Revision: https://reviews.freebsd.org/D33424

 sbin/fsck/fsck.c   |  3 +++
 sbin/fsck/fsutil.c | 39 +++++++++++++++++++++++++++++++++++++++
 sbin/fsck/fsutil.h |  7 +++----
 sbin/fsck/preen.c  | 24 +++++++++++++++---------
 4 files changed, 60 insertions(+), 13 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2022-01-02 22:20:28 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fe7121ec5b8b1c98c2933902be7aef1850030154

commit fe7121ec5b8b1c98c2933902be7aef1850030154
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2021-12-16 00:51:55 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-01-02 22:12:14 +0000

    Update fsck(8) to ignore failures from a check program for a filesystem
    when the fstab(5) entry for the filesystem has the "failok" attribute.

    PR:           246201
    Sponsored by: Netflix
    Differential Revision: https://reviews.freebsd.org/D33424

    (cherry picked from commit c72372c693b36058b58a525981e833515ce8e441)

 sbin/fsck/fsck.c   |  3 +++
 sbin/fsck/fsutil.c | 39 +++++++++++++++++++++++++++++++++++++++
 sbin/fsck/fsutil.h |  7 +++----
 sbin/fsck/preen.c  | 24 +++++++++++++++---------
 4 files changed, 60 insertions(+), 13 deletions(-)
Comment 7 Kirk McKusick freebsd_committer freebsd_triage 2022-01-08 22:06:54 UTC
The fix has been MFC'ed to 13-STABLE.