Date: Thu, 19 Aug 1999 14:46:01 -0700 (PDT) From: Julian Elischer <julian@whistle.com> To: fs@freebsd.org Subject: BUG in 3.2 fsck! (fwd) Message-ID: <Pine.BSF.3.95.990819144407.13522H-100000@current1.whistle.com>
next in thread | raw e-mail | index | archive | help
FS types.. thoughts? An ex collegue writes to me: ------------------------------------------- I have created and am testing an fsck version which will make lost+found much larger (until it fills the first indirect disk page) and which has the ability to suppress output for errors fixed by preen (which is not exactly what I proposed before but which achieves the same end with less code and less risk). It isn't really time yet to discuss merging these features into freeBSD, but I think that day will come. What this mail is really about is a bug in fsck. I am not currently competent to submit the fix or to even be positive that the bug is current. I think this is a potentially serious bug in the current sources. Are you interested? BUG IN FSCK: When the 3.2 version of fsck has to create the lost+found directory, it may fail to flag the appropriate inode busy! Patch: mkdir lost+found in the root directory of all your file systems. Discussion: fsck allocates only enough space to keep track of the first inodes in each cylinder group. This is clever and good - inode usage tends to occur at the front of the cylinder group and this saves space. Unfortunately, it does not work out well when a directory is created which increases the highest inode number for the cylinder group - the inode usage doesn't get recorded in the right place and the inode will be flagged available during pass 5. Fix: The code change causes fsck to check the cylinder group allocation when adding an inode and expand the inode list for the cylinder group if necessary. In inode.c::allocino (near line 605): for (ino = request; ino < maxino; ino++) if (inoinfo(ino)->ino_state == USTATE) break; if (ino == maxino) return (0); inoallocinfo (ino); **** one new line of code. In fsck.h, add the prototype for the new function inoallocinfo. In utility.c (near line 138), replace the function inoinfo with the following: static struct inostat unallocated = { USTATE, 0, 0 }; /* * Look up state information for an inode. */ struct inostat * inoinfo(inum) ino_t inum; { struct inostatlist *ilp; int iloff; if (inum > maxino) errx(EEXIT, "inoinfo: inumber %d out of range", inum); ilp = &inostathead[inum / sblock.fs_ipg]; iloff = inum % sblock.fs_ipg; if (iloff >= ilp->il_numalloced) return (&unallocated); return (&ilp->il_stat[iloff]); } /* * Make it safe to allocate this inode! */ void inoallocinfo (inum) ino_t inum; { struct inostat *info; struct inostatlist *ilp; unsigned i, iloff; if (inum > maxino) errx(EEXIT, "inoinfo: inumber %d out of range", inum); ilp = &inostathead[inum / sblock.fs_ipg]; iloff = inum % sblock.fs_ipg; if (iloff >= (unsigned)ilp->il_numalloced) { info = calloc (iloff + 1, sizeof *info); if (info == NULL) errx(EEXIT, "cannot alloc %u bytes for inoinfo\n", (unsigned)(sizeof *info * (iloff + 1))); memmove (info, ilp->il_stat, ilp->il_numalloced * sizeof *info); free(ilp->il_stat); ilp->il_stat = info; for (i = ilp->il_numalloced; i <= iloff; ++i) memmove (info + i, &unallocated, sizeof unallocated); ilp->il_numalloced = iloff + 1; } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.990819144407.13522H-100000>