aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/resize.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/resize.c')
-rw-r--r--fs/reiserfs/resize.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c
index 976cc7887a0d..f71c3948edef 100644
--- a/fs/reiserfs/resize.c
+++ b/fs/reiserfs/resize.c
@@ -61,7 +61,8 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
61 } 61 }
62 62
63 /* count used bits in last bitmap block */ 63 /* count used bits in last bitmap block */
64 block_r = SB_BLOCK_COUNT(s) - (SB_BMAP_NR(s) - 1) * s->s_blocksize * 8; 64 block_r = SB_BLOCK_COUNT(s) -
65 (reiserfs_bmap_count(s) - 1) * s->s_blocksize * 8;
65 66
66 /* count bitmap blocks in new fs */ 67 /* count bitmap blocks in new fs */
67 bmap_nr_new = block_count_new / (s->s_blocksize * 8); 68 bmap_nr_new = block_count_new / (s->s_blocksize * 8);
@@ -73,7 +74,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
73 74
74 /* save old values */ 75 /* save old values */
75 block_count = SB_BLOCK_COUNT(s); 76 block_count = SB_BLOCK_COUNT(s);
76 bmap_nr = SB_BMAP_NR(s); 77 bmap_nr = reiserfs_bmap_count(s);
77 78
78 /* resizing of reiserfs bitmaps (journal and real), if needed */ 79 /* resizing of reiserfs bitmaps (journal and real), if needed */
79 if (bmap_nr_new > bmap_nr) { 80 if (bmap_nr_new > bmap_nr) {
@@ -119,7 +120,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
119 return -ENOMEM; 120 return -ENOMEM;
120 } 121 }
121 memset(bitmap, 0, 122 memset(bitmap, 0,
122 sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s)); 123 sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
123 for (i = 0; i < bmap_nr; i++) 124 for (i = 0; i < bmap_nr; i++)
124 bitmap[i] = old_bitmap[i]; 125 bitmap[i] = old_bitmap[i];
125 126
@@ -143,7 +144,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
143 mark_buffer_dirty(bh); 144 mark_buffer_dirty(bh);
144 sync_dirty_buffer(bh); 145 sync_dirty_buffer(bh);
145 // update bitmap_info stuff 146 // update bitmap_info stuff
146 bitmap[i].first_zero_hint = 1;
147 bitmap[i].free_count = sb_blocksize(sb) * 8 - 1; 147 bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
148 brelse(bh); 148 brelse(bh);
149 } 149 }
@@ -173,8 +173,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
173 for (i = block_r; i < s->s_blocksize * 8; i++) 173 for (i = block_r; i < s->s_blocksize * 8; i++)
174 reiserfs_test_and_clear_le_bit(i, bh->b_data); 174 reiserfs_test_and_clear_le_bit(i, bh->b_data);
175 info->free_count += s->s_blocksize * 8 - block_r; 175 info->free_count += s->s_blocksize * 8 - block_r;
176 if (!info->first_zero_hint)
177 info->first_zero_hint = block_r;
178 176
179 journal_mark_dirty(&th, s, bh); 177 journal_mark_dirty(&th, s, bh);
180 brelse(bh); 178 brelse(bh);
@@ -196,9 +194,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
196 brelse(bh); 194 brelse(bh);
197 195
198 info->free_count -= s->s_blocksize * 8 - block_r_new; 196 info->free_count -= s->s_blocksize * 8 - block_r_new;
199 /* Extreme case where last bitmap is the only valid block in itself. */
200 if (!info->free_count)
201 info->first_zero_hint = 0;
202 /* update super */ 197 /* update super */
203 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); 198 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
204 free_blocks = SB_FREE_BLOCKS(s); 199 free_blocks = SB_FREE_BLOCKS(s);
@@ -206,7 +201,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
206 free_blocks + (block_count_new - block_count - 201 free_blocks + (block_count_new - block_count -
207 (bmap_nr_new - bmap_nr))); 202 (bmap_nr_new - bmap_nr)));
208 PUT_SB_BLOCK_COUNT(s, block_count_new); 203 PUT_SB_BLOCK_COUNT(s, block_count_new);
209 PUT_SB_BMAP_NR(s, bmap_nr_new); 204 PUT_SB_BMAP_NR(s, bmap_would_wrap(bmap_nr_new) ? : bmap_nr_new);
210 s->s_dirt = 1; 205 s->s_dirt = 1;
211 206
212 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); 207 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));