Whamcloud - gitweb
b=4336
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-2.4.20-fixes.patch
1
2
3
4  fs/ext3/balloc.c |   53 +++++++++++++++++++++++++++++++----------------------
5  1 files changed, 31 insertions(+), 22 deletions(-)
6
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,
10         }
11         lock_super (sb);
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:
20         if (!gdp)
21                 goto error_return;
22  
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",
32 -                           block, count);
33 -
34         /*
35          * We are about to start releasing blocks in the bitmap,
36          * so we need undo access.
37 @@ -345,14 +335,24 @@ do_more:
38         if (err)
39                 goto error_return;
40  
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",
49 +                                  block);
50 +                       continue;
51 +               }
52 +
53                 /*
54                  * An HJ special.  This is expensive...
55                  */
56  #ifdef CONFIG_JBD_DEBUG
57                 {
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);
61                         if (debug_bh) {
62                                 BUFFER_TRACE(debug_bh, "Deleted!");
63                                 if (!bh2jh(bitmap_bh)->b_committed_data)
64 @@ -365,9 +365,8 @@ do_more:
65  #endif
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", 
70 -                                     block + i);
71 +                       ext3_error(sb, __FUNCTION__,
72 +                                  "bit already cleared for block %lu", block);
73                         BUFFER_TRACE(bitmap_bh, "bit already cleared");
74                 } else {
75                         dquot_freed_blocks++;
76 @@ -415,7 +414,6 @@ do_more:
77         if (!err) err = ret;
78  
79         if (overflow && !err) {
80 -               block += count;
81                 count = overflow;
82                 goto do_more;
83         }
84 @@ -576,6 +574,7 @@ int ext3_new_block (handle_t *handle, st
85  
86         ext3_debug ("goal=%lu.\n", goal);
87  
88 +repeat:
89         /*
90          * First, test whether the goal block is free.
91          */
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 - "
99 -                           "block = %u", tmp);
100 +                     EXT3_SB(sb)->s_itb_per_group)) {
101 +               ext3_error(sb, __FUNCTION__,
102 +                          "Allocating block in system zone - block = %u", tmp);
103 +
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.
110 +                */
111 +               ext3_set_bit(j, bh->b_data);
112 +               goto repeat;
113 +       }
114  
115         /* The superblock lock should guard against anybody else beating
116          * us to this point! */
117
118 _