From owner-freebsd-fs@FreeBSD.ORG Wed Feb 2 22:04:07 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD4E810656A8; Wed, 2 Feb 2011 22:04:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8B3108FC1A; Wed, 2 Feb 2011 22:04:07 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 2C69546B0C; Wed, 2 Feb 2011 17:04:07 -0500 (EST) Received: from kavik.baldwin.cx (c-68-36-150-83.hsd1.nj.comcast.net [68.36.150.83]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id EAFE68A009; Wed, 2 Feb 2011 17:04:05 -0500 (EST) From: John Baldwin To: Doug Barton Date: Wed, 2 Feb 2011 17:04:03 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-RC1; KDE/4.5.5; i386; ; ) References: <4D47B954.3010600@FreeBSD.org> <20110202014252.GA1574@earth> <4D49C90C.2090003@FreeBSD.org> In-Reply-To: <4D49C90C.2090003@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201102021704.04274.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 02 Feb 2011 17:04:06 -0500 (EST) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-0.9 required=4.2 tests=BAYES_00,RDNS_DYNAMIC autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: freebsd-fs@freebsd.org Subject: Re: ext2fs crash in -current (r218056) 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: Wed, 02 Feb 2011 22:04:08 -0000 On Wednesday, February 02, 2011 04:13:48 pm Doug Barton wrote: > I haven't had a chance to test this patch yet, but John's did not work > (sorry): > > http://dougbarton.us/ext2fs-crash-dump-2.jpg > > No actual dump this time either. > > I'm happy to test the patch below on Thursday if there is consensus that > it will work. Err, this is a different panic than what you reported earlier. Your disk died and spewed a bunch of EIO errors. I can look at the locking assertion failure tomorrow, but this is a differnt issue. Even UFS needed a good bit of work to handle disks dying gracefully. > Doug > > On 02/01/2011 17:42, Aditya Sarawgi wrote: > > Hi John, > > > > I can see what you are saying. Can't we check > > the number of free blocks in the given cg without > > locking the fs. > > This way > > > > EXT2_LOCK(ump); > > return (0); > > > > } > > > > + if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0) { > > + /* > > + * Another thread allocated the last block in this > > + * group while we were waiting for the buffer. > > + */ > > + brelse(bp); > > + EXT2_LOCK(ump); > > + return (0); > > + } > > > > bbp = (char *)bp->b_data; > > > > if (dtog(fs, bpref) != cg) > > > > UFS is doing something similar > > > > static ufs2_daddr_t > > ffs_alloccg(ip, cg, bpref, size, rsize) > > > > struct inode *ip; > > u_int cg; > > ufs2_daddr_t bpref; > > int size; > > int rsize; > > > > { > > > > struct fs *fs; > > struct cg *cgp; > > struct buf *bp; > > struct ufsmount *ump; > > ufs1_daddr_t bno; > > ufs2_daddr_t blkno; > > int i, allocsiz, error, frags; > > u_int8_t *blksfree; > > > > ump = ip->i_ump; > > fs = ip->i_fs; > > if (fs->fs_cs(fs, cg).cs_nbfree == 0&& size == fs->fs_bsize) > > > > return (0); > > > > UFS_UNLOCK(ump); > > error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), > > > > (int)fs->fs_cgsize, NOCRED,&bp); > > > > if (error) > > > > goto fail; > > > > cgp = (struct cg *)bp->b_data; > > if (!cg_chkmagic(cgp) || > > > > (cgp->cg_cs.cs_nbfree == 0&& size == fs->fs_bsize)) > > > > goto fail; > >> > >> Please try this: > >> > >> Index: ext2_alloc.c > >> =================================================================== > >> --- ext2_alloc.c (revision 218175) > >> +++ ext2_alloc.c (working copy) > >> @@ -650,6 +650,18 @@ > >> > >> EXT2_LOCK(ump); > >> return (0); > >> > >> } > >> > >> + EXT2_LOCK(ump); > >> + if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0) { > >> + /* > >> + * Another thread allocated the last block in this > >> + * group while we were waiting for the buffer. > >> + */ > >> + EXT2_UNLOCK(ump); > >> + brelse(bp); > >> + EXT2_LOCK(ump); > >> + return (0); > >> + } > >> + EXT2_UNLOCK(ump); > >> > >> bbp = (char *)bp->b_data; > >> > >> if (dtog(fs, bpref) != cg) > >> > >> @@ -776,6 +788,18 @@ > >> > >> EXT2_LOCK(ump); > >> return (0); > >> > >> } > >> > >> + EXT2_LOCK(ump); > >> + if (fs->e2fs_gd[cg].ext2bgd_nifree == 0) { > >> + /* > >> + * Another thread allocated the last i-node in this > >> + * group while we were waiting for the buffer. > >> + */ > >> + EXT2_UNLOCK(ump); > >> + brelse(bp); > >> + EXT2_LOCK(ump); > >> + return (0); > >> + } > >> + EXT2_UNLOCK(ump); > >> > >> ibp = (char *)bp->b_data; > >> if (ipref) { > >> > >> ipref %= fs->e2fs->e2fs_ipg; > > > > -- > > Aditya Sarawgi > > _______________________________________________ > > freebsd-fs@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org" -- John Baldwin