Bug 256746 - fsck_ffs completely broken for background fsck
Summary: fsck_ffs completely broken for background fsck
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-21 12:07 UTC by andrew
Modified: 2021-07-19 18:18 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andrew 2021-06-21 12:07:54 UTC
Commit 5cc52631b3b88 completely breaks background fsck by trying to open the device for writing (which is of course disallowed because it is mounted) too early in the process. This affects 13.0 release, 13-stable and current.

To reproduce: have any filesystem other than / with softupdates enabled but not journalling; force a reboot with for example reboot -qn when the filesystem is mounted and dirty; observe that in /var/log/messages 60 seconds after booting a message like this shows up:

Jun 21 11:40:48 hel fsck[784]: /dev/vtbd1: NO WRITE ACCESS
Jun 21 11:40:48 hel fsck[784]: /dev/vtbd1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
Jun 21 11:40:48 hel fsck[784]: /dev/vtbd1: CANNOT SET FS_NEEDSFSCK FLAG

The code at fsck_ffs/main.c:298 should probably be inside the FS_GJOURNAL condition, or otherwise refactored; it's obviously completely wrong as it stands. (Note that -p sets ckclean, and skipclean is set by default).
Comment 1 Kirk McKusick freebsd_committer 2021-06-21 12:38:09 UTC
Thanks for breaking out this bug separately. I will investigate it and report back.
Comment 3 Robert Wing freebsd_committer 2021-06-23 22:30:58 UTC
proposed fix: https://reviews.freebsd.org/D30880
Comment 4 Kirk McKusick freebsd_committer 2021-06-30 00:31:15 UTC
(In reply to Robert Wing from comment #3)
Your proposed fix in https://reviews.freebsd.org/D30880 looks good.
Comment 5 commit-hook freebsd_committer 2021-07-11 20:59:16 UTC
A commit in branch main references this bug:

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

commit 0c5a59252c8e7b80b98521ebc23a415a05ff9594
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2021-07-11 20:47:27 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2021-07-11 20:47:27 +0000

    fsck_ffs: fix background fsck in preen mode

    Background checks are only allowed for mounted filesystems - don't try
    to open the device for writing when performing a background check.

    While here, remove a debugging printf that's commented out.

    PR:             256746
    Fixes:          5cc52631b3b88dfc36d8049dc8bece8573c5f9af
    Reviewed by:    mckusick
    MFC After:      1 week
    Differential Revision:  https://reviews.freebsd.org/D30880

 sbin/fsck_ffs/main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
Comment 6 commit-hook freebsd_committer 2021-07-19 18:18:02 UTC
A commit in branch stable/13 references this bug:

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

commit fb2feceac34cc9c3fb47ba4a7b0ca31637f8fdf0
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2021-07-11 20:47:27 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2021-07-19 18:06:53 +0000

    fsck_ffs: fix background fsck in preen mode

    Background checks are only allowed for mounted filesystems - don't try
    to open the device for writing when performing a background check.

    While here, remove a debugging printf that's commented out.

    PR:             256746
    Fixes:          5cc52631b3b88dfc36d8049dc8bece8573c5f9af
    Reviewed by:    mckusick
    Differential Revision:  https://reviews.freebsd.org/D30880

    (cherry picked from commit 0c5a59252c8e7b80b98521ebc23a415a05ff9594)

 sbin/fsck_ffs/main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)