Bug 246962 - fsck_ffs frequently requires multiple runs
Summary: fsck_ffs frequently requires multiple runs
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-03 16:54 UTC by Mark Johnston
Modified: 2021-10-01 01:03 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston freebsd_committer 2020-06-03 16:54:39 UTC
I use a FreeBSD HEAD VM for development, with SU (no journaling) on the root FS.  It panics frequently, and often drops me off in single user mode after fsck_ffs returns a non-zero exit status:

--
Starting file system checks:
/dev/gpt/rootfs: INCORRECT BLOCK COUNT I=330657 (8 should be 0) (CORRECTED)            
/dev/gpt/rootfs: INCORRECT BLOCK COUNT I=330658 (8 should be 0) (CORRECTED)            
/dev/gpt/rootfs: INCORRECT BLOCK COUNT I=330660 (8 should be 0) (CORRECTED)            
/dev/gpt/rootfs: INCORRECT BLOCK COUNT I=330661 (8 should be 0) (CORRECTED)
/dev/gpt/rootfs: INCORRECT BLOCK COUNT I=330665 (8 should be 0) (CORRECTED)                                                                                                   
/dev/gpt/rootfs: INCORRECT BLOCK COUNT I=330666 (16 should be 0) (CORRECTED)
...
/dev/gpt/rootfs: ZERO LENGTH DIR I=727410  OWNER=root MODE=41777                       
/dev/gpt/rootfs: SIZE=0 MTIME=Jun  3 11:00 2020                                        
 (CLEARED)                                                                                                                                                                    
/dev/gpt/rootfs: FREE BLK COUNT(S) WRONG IN SUPERBLK (SALVAGED)                                                                                                               
/dev/gpt/rootfs: SUMMARY INFORMATION BAD (SALVAGED)                                    
/dev/gpt/rootfs: BLK(S) MISSING IN BIT MAPS (SALVAGED)                                 
/dev/gpt/rootfs: 51340 files, 1475643 used, 3343995 free (5475 frags, 417315 blocks, 0.1% fragmentation)
                                                                                       
***** PLEASE RERUN FSCK *****                                                          
WARNING: /: reload pending error: blocks 184 files 8                                   
Automatic file system check failed; help!                                              
ERROR: ABORTING BOOT (sending SIGTERM to parent)!                                      
2020-06-03T08:15:42.153887-04:00  init 1 - - /bin/sh on /etc/rc terminated abnormally, going to single user mode
--

Then, running fsck_ffs again returns with no errors:

--
root@:/ # fsck_ffs -y /                                                                                                                                                       
** /dev/gpt/rootfs                                                                     
** Last Mounted on /                                                                   
** Root file system                                                                    
** Phase 1 - Check Blocks and Sizes                                                    
** Phase 2 - Check Pathnames                                                           
** Phase 3 - Check Connectivity                                                        
** Phase 4 - Check Reference Counts                                                    
** Phase 5 - Check Cyl groups                                                          
51340 files, 1475643 used, 3343995 free (5475 frags, 417315 blocks, 0.1% fragmentation)
                                                                                       
***** FILE SYSTEM MARKED CLEAN *****                                           
<boot continues>
--

Why does fsck_ffs require a restart here?  I know that there is some rc.conf variable I can set to work around this, but it looks like it shouldn't be necessary to begin with.
Comment 1 commit-hook freebsd_committer 2021-09-22 23:21:31 UTC
A commit in branch main references this bug:

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

commit b31c5a25321363ab95c1642dffc6e92319dc42ce
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2021-09-22 23:16:39 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2021-09-22 23:20:19 +0000

    Eliminate an unnecessary rerun request in fsck_ffs.

    When fsck_ffs is running in preen mode and finds a zero-length directory,
    it deletes that directory. In doing this operation, it unnecessary set
    its internal flag saying that fsck_ffs needed to be rerun. This patch
    deletes the rerun request for this case.

    Reported by:  Mark Johnson
    PR:           246962
    MFC after:    1 week
    Sponsored by: Netflix

 sbin/fsck_ffs/dir.c | 1 -
 1 file changed, 1 deletion(-)
Comment 2 Kirk McKusick freebsd_committer 2021-09-22 23:26:46 UTC
I encountered this problem recently and discovered that fsck is unnecessarily setting the `needs rerun' flag when clearing zero-length directories. I have removed the unnecessary rerun request. If you see any recurrence of this problem, let me know.
Comment 3 Kirk McKusick freebsd_committer 2021-10-01 01:03:45 UTC
This fix has been MFC'ed to 13.