svn commit: r218438 - head/sys/fs/ext2fs
John Baldwin
jhb at FreeBSD.org
Tue Feb 8 13:02:26 UTC 2011
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;
More information about the svn-src-head
mailing list