Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 May 1996 14:14:16 -0600
From:      Nate Williams <nate@sri.MT.net>
To:        stable@FreeBSD.org, current@FreeBSD.org
Subject:   Re-submit fsck patch for
Message-ID:  <199605062014.OAA18548@rocky.sri.MT.net>

next in thread | raw e-mail | index | archive | help
After Michael Butler pointed out that Terry already sent a patch for the
'multiple-pass' fsck problem, I dug through my mail archives (the net is
still down) and found the following patch.  I applied it to my system
and tested it out by power-cycling my laptop, thus guaranteeing a
corrupted FS.  (I did this a couple times to make sure, and it worked
every time)..

In the past, I *always* had to run fsck multiple times (at least 3,
sometimes more) where now it requires only one pass.  I also tried out
running the old fsck after running the new fsck and the results where
still valid (in case the new fsck did something funny).  Based on my
somewhat limited testing it appears that the patch does indeed fix a
known problem in the system, and I would like to apply it to both
-stable and -current.

The current situation is bad in that a system will get 'fsck' run on it,
but still have FS corruption exist.  With the clean-bit patches, this
could be some cause of trouble since a FS which is considered 'clean'
really isn't.  With this patch in place, chances are much greater of
having a 'really' clean FS after one run of fsck.

In any case, here is the patch again, which I will apply to -current and
-current and -stable if no one objects.


Nate
----------
From: Terry Lambert <terry@lambert.org>
Subject: Fix for annoying fsck bug
Date: Wed, 24 Jan 1996 13:33:29 -0700 (MST)
Status: OR


The following small diff fixes the annoying fsck bug that causes it to
need to be run twice to end up with correct reference counts for inodes
for directories that had subdirectories relocated into the lost+found
directory.

I found the need to rerun *extremely* annoying.  This fix causes the
count to be correctly adjusted later in pass 4 by correctly stating
the parent reference count.

Note that the parent reference count is incremented when the directory
entry is made (for ".."), but is not really there in the case of a
directory that does not make an entry in its parent dir.


This can be tested by waiting for the inode sync after cd'ing from a
shell into a test fs.  Then you "mkdir xxx yyy zzz", wait a second,
and hit the machine reset button.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
============================================================================
*** /usr/src/sbin/fsck/SAVE/dir.c	Wed Jan 24 13:24:32 1996
--- /usr/src/sbin/fsck/dir.c	Wed Jan 24 13:26:03 1996
***************
*** 472,479 ****
  		inodirty();
  		lncntp[lfdir]++;
  		pwarn("DIR I=%lu CONNECTED. ", orphan);
! 		if (parentdir != (ino_t)-1)
  			printf("PARENT WAS I=%lu\n", parentdir);
  		if (preen == 0)
  			printf("\n");
  	}
--- 472,489 ----
  		inodirty();
  		lncntp[lfdir]++;
  		pwarn("DIR I=%lu CONNECTED. ", orphan);
! 		if (parentdir != (ino_t)-1) {
  			printf("PARENT WAS I=%lu\n", parentdir);
+			/*
+ 			 * The parent directory, because of the ordering
+ 			 * guarantees, has had the link count incremented
+ 			 * for the child, but no entry was made.  This
+ 			 * fixes the parent link count so that fsck does
+ 			 * not need to be rerun.
+ 			 */
+ 			lncntp[parentdir]++;
+ 
+ 		}
  		if (preen == 0)
  			printf("\n");
  	}
============================================================================





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605062014.OAA18548>