Date: Tue, 8 Feb 2011 13:02:26 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r218438 - head/sys/fs/ext2fs Message-ID: <201102081302.p18D2Qqq046702@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Tue Feb 8 13:02:25 2011 New Revision: 218438 URL: http://svn.freebsd.org/changeset/base/218438 Log: After reading a bitmap block for i-nodes or blocks, recheck the count of free i-nodes or blocks to handle a race where another thread might have allocated the last i-node or block while we were waiting for the buffer. Tested by: dougb Modified: head/sys/fs/ext2fs/ext2_alloc.c Modified: head/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- head/sys/fs/ext2fs/ext2_alloc.c Tue Feb 8 12:51:54 2011 (r218437) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Feb 8 13:02:25 2011 (r218438) @@ -650,6 +650,15 @@ ext2_alloccg(struct inode *ip, int cg, d 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) @@ -776,6 +785,15 @@ ext2_nodealloccg(struct inode *ip, int c EXT2_LOCK(ump); return (0); } + 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. + */ + brelse(bp); + EXT2_LOCK(ump); + return (0); + } ibp = (char *)bp->b_data; if (ipref) { ipref %= fs->e2fs->e2fs_ipg;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102081302.p18D2Qqq046702>