patch-2.3.15 linux/fs/ext2/inode.c

Next file: linux/fs/fat/inode.c
Previous file: linux/fs/ext2/balloc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.14/linux/fs/ext2/inode.c linux/fs/ext2/inode.c
@@ -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);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)