From owner-freebsd-fs@FreeBSD.ORG Tue Jan 10 22:21:14 2012 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 399491065673 for ; Tue, 10 Jan 2012 22:21:14 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (unknown [IPv6:2001:5a8:4:7e72:4a5b:39ff:fe12:452]) by mx1.freebsd.org (Postfix) with ESMTP id 0F2A18FC08 for ; Tue, 10 Jan 2012 22:21:14 +0000 (UTC) Received: from chez.mckusick.com (localhost [127.0.0.1]) by chez.mckusick.com (8.14.3/8.14.3) with ESMTP id q0AML8MX012837; Tue, 10 Jan 2012 14:21:08 -0800 (PST) (envelope-from mckusick@chez.mckusick.com) Message-Id: <201201102221.q0AML8MX012837@chez.mckusick.com> To: "Julian H. Stacey" In-reply-to: <201201102147.q0ALkvhW033512@fire.js.berklix.net> Date: Tue, 10 Jan 2012 14:21:08 -0800 From: Kirk McKusick X-Spam-Status: No, score=0.0 required=5.0 tests=MISSING_MID, UNPARSEABLE_RELAY autolearn=failed version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on chez.mckusick.com Cc: fs@freebsd.org Subject: Re: unexpected soft update inconsistency - cannot fix X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 22:21:14 -0000 > To: Kirk McKusick > cc: fs@freebsd.org > Subject: Re: unexpected soft update inconsistency - cannot fix > From: "Julian H. Stacey" > Date: Tue, 10 Jan 2012 22:46:57 +0100 > > Hi Kirk > cc fs@ > > Thanks ! Meantime I'd been looking & made notes below. > I don't understand how the above "mv Makefile,v Makefile,v.sav" > would create a new slot ? wouldnt' it just call rename(2) ? > So there'd still be no slot to re-label as ".." to point at parent inode ? The rename will have to create a new slot for "Makefile,v.sav" which will be at the end of the directory (as that is the only place where there is enough space for it). That will leave slot 0 with a reclen of 40. With a reclen of 40, there will be enough space following the "." entry (which is using the first 12) that fsck will be able to fit the ".." entry into the unused space immediately following the "." entry where it belongs. > Wouldn't it be better to call fsdb + "ln 79302719 .." as below ? If you do that the ".." entry will be placed at the end of the directory where it does not belong. Fsck will still bitch and will still be unable to fix it. > Also as notes below show inode of parent can be deduced, > wouldn't it be good if such functionality were built into fsck or fsdb code > (or pro tem added as an example to man fsdb ?) The path is calculated by getting the inode associated with ".." in the current inode. You then read the ".." inode and find the name associated with the current inode in it. You repeat this process level by level until you reach the root of the filesystem (inode 2) at which point you have the full path. If the only information you have is the contents of an inode that is missing its ".." entry you cannot figure out its parent or its path. At the point in fsck where this error occurs you do not know what the namespace looks like, you have only a subset of the inodes. So there is no way to figure out the path. --------- fsdb -r /dev/ad4s4g ** /dev/ad4s4g (NO WRITE) Examining file system `/dev/ad4s4g' Last Mounted on current inode: directory I=2 MODE=40755 SIZE=512 OWNER=root GRP=wheel LINKCNT=9 FLAGS=0 BLKCNT=4 GEN=359f3dd1 fsdb (inum: 2)> inode 825575 current inode: directory I=825575 MODE=40755 SIZE=512 OWNER=mailnull GRP=mailnull LINKCNT=2 FLAGS=0 BLKCNT=4 GEN=29c28025 fsdb (inum: 825575)> ls slot 0 ino 825575 reclen 20: directory, `.' slot 1 ino 825580 reclen 20: regular, `Makefile,v' slot 2 ino 825581 reclen 20: regular, `distinfo,v' slot 3 ino 825582 reclen 20: regular, `pkg-descr,v' slot 4 ino 825583 reclen 432: regular, `pkg-plist,v' fsdb (inum: 825575)> print current inode: directory I=825575 MODE=40755 SIZE=512 OWNER=mailnull GRP=mailnull LINKCNT=2 FLAGS=0 BLKCNT=4 GEN=29c28025 # LINKCNT=2 seems wrong, comparing with a goo directory, # I think should be 4 without the ".." & 5 with "..". The ./ftp/.backup/pri/FreeBSD/development/FreeBSD-CVS/ports/net/ \ keepalived/Attic directory contains no directories, so with a ".." entry it should have a link count of 2. fsdb (inum: 825575)> uplink fsdb: `uplink' requires write access fsdb: rval was 1 fsdb (inum: 825575)> To Do Later With Fsdb ( without -r ) uplink uplink ln 79302719 .. mount /usr1 ; mount | grep /usr1 /dev/ad4s4g on /usr1 (ufs, local, read-only) cd /usr1 ; find -x . -inum 825575 ./ftp/.backup/pri/FreeBSD/development/FreeBSD-CVS/\ ports/net/keepalived/Attic cd ftp/.backup/pri/FreeBSD/development/FreeBSD-CVS/ports/net/keepalived ls -lai total 50 79302719 drwxr-xr-x 3 mailnull mailnull 512 Dec 29 20:09 ./ 73700289 drwxr-xr-x 2109 mailnull mailnull 43520 Dec 29 20:08 ../ 825575 drwxr-xr-x 2 mailnull mailnull 512 Dec 29 22:12 Attic/ 79302722 drwxr-xr-x 3 mailnull mailnull 512 Dec 29 22:12 files/ fsdb (inum: 825575)> inode 79302719 current inode: directory I=79302719 MODE=40755 SIZE=512 OWNER=mailnull GRP=mailnull LINKCNT=3 FLAGS=0 BLKCNT=4 GEN=293a450d fsdb (inum: 79302719)> ls slot 0 ino 79302719 reclen 12: directory, `.' slot 1 ino 73700289 reclen 12: directory, `..' slot 2 ino 79302722 reclen 16: directory, `files' slot 3 ino 825575 reclen 472: directory, `Attic' --------- Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com Reply below not above, cumulative like a play script, & indent with "> ". Format: Plain text. Not HTML, multipart/alternative, base64, quoted-printable. So, to refine my earlier suggestion: cd /usr1/./ftp/.backup/pri/FreeBSD/development/FreeBSD-CVS/ports/net/\ keepalived/Attic ls -fa mv Makefile,v Makefile,v.sav ls -fa cd / umount /dev/ad4s4g fsck /dev/ad4s4g mount /usr1 cd /usr1/./ftp/.backup/pri/FreeBSD/development/FreeBSD-CVS/ports/net/\ keepalived/Attic ls -fa mv Makefile,v.sav Makefile,v ls -fa You can use `ls -fa' to see the order of everything in the directory. Kirk McKusick