This patch will make ext2:
o robust against possible sleeps of mark_buffer_dirty()
o will avoid silenty ignoring the allocation of the last block
under us when BUG() will be #undef. If I understood well
the reason nobody can race with the allocation of the real data
block is that we are serialized by the per-page-lock (the buffer
is always <= PAGE_SIZE).
o will avoid ignoring somebody racing with us in the block_getblk
path.
--- 2.3.13-pre8-tmp/fs/ext2/inode.c.~1~ Tue Jul 13 02:02:09 1999
+++ 2.3.13-pre8-tmp/fs/ext2/inode.c Mon Aug 9 01:52:28 1999
@@ -259,20 +259,22 @@
}
if (metadata) {
result = getblk (inode->i_dev, tmp, blocksize);
+ memset(result->b_data, 0, blocksize);
+ mark_buffer_uptodate(result, 1);
+ mark_buffer_dirty(result, 1);
if (*p) {
ext2_free_blocks (inode, tmp, 1);
- brelse (result);
+ bforget (result);
goto repeat;
}
- memset(result->b_data, 0, blocksize);
- mark_buffer_uptodate(result, 1);
- mark_buffer_dirty(result, 1);
} else {
if (*p) {
/*
* Nobody is allowed to change block allocation
* state from under us:
*/
+ ext2_error (inode->i_sb, "block_getblk",
+ "data block filled under us");
BUG();
ext2_free_blocks (inode, tmp, 1);
goto repeat;
@@ -366,22 +368,28 @@
goto out;
if (metadata) {
result = getblk (bh->b_dev, tmp, blocksize);
+ memset(result->b_data, 0, inode->i_sb->s_blocksize);
+ mark_buffer_uptodate(result, 1);
+ mark_buffer_dirty(result, 1);
if (*p) {
ext2_free_blocks (inode, tmp, 1);
- brelse (result);
+ bforget (result);
goto repeat;
}
- memset(result->b_data, 0, inode->i_sb->s_blocksize);
- mark_buffer_uptodate(result, 1);
- mark_buffer_dirty(result, 1);
} else {
+ if (*p) {
+ /*
+ * Nobody is allowed to change block allocation
+ * state from under us:
+ */
+ ext2_error (inode->i_sb, "block_getblk",
+ "data block filled under us");
+ BUG();
+ ext2_free_blocks (inode, tmp, 1);
+ goto repeat;
+ }
*phys = tmp;
*new = 1;
- }
- if (*p) {
- ext2_free_blocks (inode, tmp, 1);
- brelse (result);
- goto repeat;
}
*p = le32_to_cpu(tmp);
mark_buffer_dirty(bh, 1);
Andrea
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/