4 fs/ext3/balloc.c | 53 +++++++++++++++++++++++++++++++----------------------
5 1 files changed, 31 insertions(+), 22 deletions(-)
7 --- linux-2.4.20/fs/ext3/balloc.c~ext3-2.4.20-fixes 2003-04-08 23:35:17.000000000 -0600
8 +++ linux-2.4.20-braam/fs/ext3/balloc.c 2003-04-08 23:35:17.000000000 -0600
9 @@ -276,7 +276,8 @@ void ext3_free_blocks (handle_t *handle,
12 es = sb->u.ext3_sb.s_es;
13 - if (block < le32_to_cpu(es->s_first_data_block) ||
14 + if (block < le32_to_cpu(es->s_first_data_block) ||
15 + block + count < block ||
16 (block + count) > le32_to_cpu(es->s_blocks_count)) {
17 ext3_error (sb, "ext3_free_blocks",
18 "Freeing blocks not in datazone - "
19 @@ -309,17 +310,6 @@ do_more:
23 - if (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) ||
24 - in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) ||
25 - in_range (block, le32_to_cpu(gdp->bg_inode_table),
26 - sb->u.ext3_sb.s_itb_per_group) ||
27 - in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table),
28 - sb->u.ext3_sb.s_itb_per_group))
29 - ext3_error (sb, "ext3_free_blocks",
30 - "Freeing blocks in system zones - "
31 - "Block = %lu, count = %lu",
35 * We are about to start releasing blocks in the bitmap,
36 * so we need undo access.
37 @@ -345,14 +335,24 @@ do_more:
41 - for (i = 0; i < count; i++) {
42 + for (i = 0; i < count; i++, block++) {
43 + if (block == le32_to_cpu(gdp->bg_block_bitmap) ||
44 + block == le32_to_cpu(gdp->bg_inode_bitmap) ||
45 + in_range(block, le32_to_cpu(gdp->bg_inode_table),
46 + EXT3_SB(sb)->s_itb_per_group)) {
47 + ext3_error(sb, __FUNCTION__,
48 + "Freeing block in system zone - block = %lu",
54 * An HJ special. This is expensive...
56 #ifdef CONFIG_JBD_DEBUG
58 struct buffer_head *debug_bh;
59 - debug_bh = sb_get_hash_table(sb, block + i);
60 + debug_bh = sb_get_hash_table(sb, block);
62 BUFFER_TRACE(debug_bh, "Deleted!");
63 if (!bh2jh(bitmap_bh)->b_committed_data)
64 @@ -365,9 +365,8 @@ do_more:
66 BUFFER_TRACE(bitmap_bh, "clear bit");
67 if (!ext3_clear_bit (bit + i, bitmap_bh->b_data)) {
68 - ext3_error (sb, __FUNCTION__,
69 - "bit already cleared for block %lu",
71 + ext3_error(sb, __FUNCTION__,
72 + "bit already cleared for block %lu", block);
73 BUFFER_TRACE(bitmap_bh, "bit already cleared");
76 @@ -415,7 +414,6 @@ do_more:
79 if (overflow && !err) {
84 @@ -576,6 +574,7 @@ int ext3_new_block (handle_t *handle, st
86 ext3_debug ("goal=%lu.\n", goal);
90 * First, test whether the goal block is free.
92 @@ -684,10 +683,20 @@ got_block:
93 if (tmp == le32_to_cpu(gdp->bg_block_bitmap) ||
94 tmp == le32_to_cpu(gdp->bg_inode_bitmap) ||
95 in_range (tmp, le32_to_cpu(gdp->bg_inode_table),
96 - sb->u.ext3_sb.s_itb_per_group))
97 - ext3_error (sb, "ext3_new_block",
98 - "Allocating block in system zone - "
100 + EXT3_SB(sb)->s_itb_per_group)) {
101 + ext3_error(sb, __FUNCTION__,
102 + "Allocating block in system zone - block = %u", tmp);
104 + /* Note: This will potentially use up one of the handle's
105 + * buffer credits. Normally we have way too many credits,
106 + * so that is OK. In _very_ rare cases it might not be OK.
107 + * We will trigger an assertion if we run out of credits,
108 + * and we will have to do a full fsck of the filesystem -
109 + * better than randomly corrupting filesystem metadata.
111 + ext3_set_bit(j, bh->b_data);
115 /* The superblock lock should guard against anybody else beating
116 * us to this point! */