Date: Thu, 24 Feb 2011 12:16:46 +0800 From: gnehzuil <gnehzuil@gmail.com> To: John Baldwin <jhb@freebsd.org> Cc: "Pedro F. Giffuni" <giffunip@yahoo.com>, fs@freebsd.org Subject: Re: Simple ext2fs allocation routine cleanups Message-ID: <4D65DBAE.7010505@gmail.com> In-Reply-To: <201102231432.38902.jhb@freebsd.org> References: <201102230811.32864.jhb@freebsd.org> <AANLkTinrMSSCrwuAtzrgNOjpV=5OpH68zOY2Lkingc7R@mail.gmail.com> <201102231432.38902.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi John, I have tried your changes again. It's ok. The error doesn't occurred. I think the problem is off-by-one bug. Best regards, lz On 02/24/2011 03:32 AM, John Baldwin wrote: > On Wednesday, February 23, 2011 11:35:33 am gnehzuil gnehzuil wrote: >> Hi John, >> >> I use dbench program to do some tests for your changes. However, it causes >> kernel crash. The error is as follows: >> >> panic: __lockmgr_args: recursing on non recursive lockmgr ext2fs @ >> /usr/src/sys/kern/vfs_subr.c:2124 > I wasn't able to reproduce that, but I did have silly off-by-one bugs in the > use of ffs() that should be fixed now: > > Index: ext2_alloc.c > =================================================================== > --- ext2_alloc.c (revision 218975) > +++ ext2_alloc.c (working copy) > @@ -815,16 +815,12 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t > } > } > i = start + len - loc; > - map = ibp[i]; > - ipref = i * NBBY; > - for (i = 1; i< (1<< NBBY); i<<= 1, ipref++) { > - if ((map& i) == 0) { > - goto gotit; > - } > + map = ibp[i] ^ 0xff; > + if (map == 0) { > + printf("fs = %s\n", fs->e2fs_fsmnt); > + panic("ext2fs_nodealloccg: block not in map"); > } > - printf("fs = %s\n", fs->e2fs_fsmnt); > - panic("ext2fs_nodealloccg: block not in map"); > - /* NOTREACHED */ > + ipref = i * NBBY + ffs(map) - 1; > gotit: > setbit(ibp, ipref); > EXT2_LOCK(ump); > @@ -952,7 +948,6 @@ ext2_vfree(pvp, ino, mode) > static daddr_t > ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t bpref) > { > - daddr_t bno; > int start, len, loc, i, map; > > /* > @@ -977,15 +972,12 @@ ext2_mapsearch(struct m_ext2fs *fs, char *bbp, dad > } > } > i = start + len - loc; > - map = bbp[i]; > - bno = i * NBBY; > - for (i = 1; i< (1<< NBBY); i<<= 1, bno++) { > - if ((map& i) == 0) > - return (bno); > + map = bbp[i] ^ 0xff; > + if (map == 0) { > + printf("fs = %s\n", fs->e2fs_fsmnt); > + panic("ext2fs_mapsearch: block not in map"); > } > - printf("fs = %s\n", fs->e2fs_fsmnt); > - panic("ext2fs_mapsearch: block not in map"); > - /* NOTREACHED */ > + return (i * NBBY + ffs(map) - 1); > } > > /* >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D65DBAE.7010505>