From owner-freebsd-hackers Wed Jan 24 12:43:46 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id MAA18141 for hackers-outgoing; Wed, 24 Jan 1996 12:43:46 -0800 (PST) Received: from who.cdrom.com (who.cdrom.com [192.216.222.3]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id MAA18131 Wed, 24 Jan 1996 12:43:33 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by who.cdrom.com (8.6.12/8.6.11) with ESMTP id MAA29303 ; Wed, 24 Jan 1996 12:43:19 -0800 Received: (from root@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id NAA19809; Wed, 24 Jan 1996 13:33:29 -0700 From: Terry Lambert Message-Id: <199601242033.NAA19809@phaeton.artisoft.com> Subject: Fix for annoying fsck bug To: hackers@freebsd.org Date: Wed, 24 Jan 1996 13:33:29 -0700 (MST) Cc: current@freebsd.org X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org Precedence: bulk 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"); } ============================================================================