diff options
author | Jeff Mahoney <jeffm@suse.com> | 2007-10-19 02:39:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:35 -0400 |
commit | 4d20851d3757ba5bece263a4c8c5a2bd4983cb5d (patch) | |
tree | ac89f9cf860801675e587c38c39fd9e6bd2204da /fs/reiserfs | |
parent | 3ee1667042c350003b9d3f35e5666cc8c43ce8aa (diff) |
reiserfs: remove first_zero_hint
The first_zero_hint metadata caching was never actually used, and it's of
dubious optimization quality. This patch removes it.
It doesn't actually shrink the size of the reiserfs_bitmap_info struct, since
that doesn't work with block sizes larger than 8K. There was a big fixme in
there, and with all the work lately in allowing block size > page size, I
might as well kill the fixme as well.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs')
-rw-r--r-- | fs/reiserfs/bitmap.c | 29 | ||||
-rw-r--r-- | fs/reiserfs/resize.c | 6 |
2 files changed, 12 insertions, 23 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index f7275176305e..f09a6f6d3ac0 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
@@ -273,7 +273,7 @@ static inline int block_group_used(struct super_block *s, u32 id) | |||
273 | * to make a better decision. This favors long-term performace gain | 273 | * to make a better decision. This favors long-term performace gain |
274 | * with a better on-disk layout vs. a short term gain of skipping the | 274 | * with a better on-disk layout vs. a short term gain of skipping the |
275 | * read and potentially having a bad placement. */ | 275 | * read and potentially having a bad placement. */ |
276 | if (info->first_zero_hint == 0) { | 276 | if (info->free_count == UINT_MAX) { |
277 | struct buffer_head *bh = reiserfs_read_bitmap_block(s, bm); | 277 | struct buffer_head *bh = reiserfs_read_bitmap_block(s, bm); |
278 | brelse(bh); | 278 | brelse(bh); |
279 | } | 279 | } |
@@ -1214,27 +1214,22 @@ void reiserfs_cache_bitmap_metadata(struct super_block *sb, | |||
1214 | { | 1214 | { |
1215 | unsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size); | 1215 | unsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size); |
1216 | 1216 | ||
1217 | info->first_zero_hint = 1 << (sb->s_blocksize_bits + 3); | 1217 | /* The first bit must ALWAYS be 1 */ |
1218 | BUG_ON(!reiserfs_test_le_bit(0, (unsigned long *)bh->b_data)); | ||
1219 | |||
1220 | info->free_count = 0; | ||
1218 | 1221 | ||
1219 | while (--cur >= (unsigned long *)bh->b_data) { | 1222 | while (--cur >= (unsigned long *)bh->b_data) { |
1220 | int base = ((char *)cur - bh->b_data) << 3; | 1223 | int i; |
1221 | 1224 | ||
1222 | /* 0 and ~0 are special, we can optimize for them */ | 1225 | /* 0 and ~0 are special, we can optimize for them */ |
1223 | if (*cur == 0) { | 1226 | if (*cur == 0) |
1224 | info->first_zero_hint = base; | ||
1225 | info->free_count += BITS_PER_LONG; | 1227 | info->free_count += BITS_PER_LONG; |
1226 | } else if (*cur != ~0L) { /* A mix, investigate */ | 1228 | else if (*cur != ~0L) /* A mix, investigate */ |
1227 | int b; | 1229 | for (i = BITS_PER_LONG - 1; i >= 0; i--) |
1228 | for (b = BITS_PER_LONG - 1; b >= 0; b--) { | 1230 | if (!reiserfs_test_le_bit(i, cur)) |
1229 | if (!reiserfs_test_le_bit(b, cur)) { | ||
1230 | info->first_zero_hint = base + b; | ||
1231 | info->free_count++; | 1231 | info->free_count++; |
1232 | } | ||
1233 | } | ||
1234 | } | ||
1235 | } | 1232 | } |
1236 | /* The first bit must ALWAYS be 1 */ | ||
1237 | BUG_ON(info->first_zero_hint == 0); | ||
1238 | } | 1233 | } |
1239 | 1234 | ||
1240 | struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb, | 1235 | struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb, |
@@ -1264,7 +1259,7 @@ struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb, | |||
1264 | BUG_ON(!buffer_uptodate(bh)); | 1259 | BUG_ON(!buffer_uptodate(bh)); |
1265 | BUG_ON(atomic_read(&bh->b_count) == 0); | 1260 | BUG_ON(atomic_read(&bh->b_count) == 0); |
1266 | 1261 | ||
1267 | if (info->first_zero_hint == 0) | 1262 | if (info->free_count == UINT_MAX) |
1268 | reiserfs_cache_bitmap_metadata(sb, bh, info); | 1263 | reiserfs_cache_bitmap_metadata(sb, bh, info); |
1269 | } | 1264 | } |
1270 | 1265 | ||
@@ -1279,7 +1274,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb) | |||
1279 | if (bitmap == NULL) | 1274 | if (bitmap == NULL) |
1280 | return -ENOMEM; | 1275 | return -ENOMEM; |
1281 | 1276 | ||
1282 | memset(bitmap, 0, sizeof (*bitmap) * SB_BMAP_NR(sb)); | 1277 | memset(bitmap, 0xff, sizeof(*bitmap) * SB_BMAP_NR(sb)); |
1283 | 1278 | ||
1284 | SB_AP_BITMAP(sb) = bitmap; | 1279 | SB_AP_BITMAP(sb) = bitmap; |
1285 | 1280 | ||
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c index 3bec2f96242a..66f1cda83a81 100644 --- a/fs/reiserfs/resize.c +++ b/fs/reiserfs/resize.c | |||
@@ -143,7 +143,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
143 | mark_buffer_dirty(bh); | 143 | mark_buffer_dirty(bh); |
144 | sync_dirty_buffer(bh); | 144 | sync_dirty_buffer(bh); |
145 | // update bitmap_info stuff | 145 | // update bitmap_info stuff |
146 | bitmap[i].first_zero_hint = 1; | ||
147 | bitmap[i].free_count = sb_blocksize(sb) * 8 - 1; | 146 | bitmap[i].free_count = sb_blocksize(sb) * 8 - 1; |
148 | brelse(bh); | 147 | brelse(bh); |
149 | } | 148 | } |
@@ -173,8 +172,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
173 | for (i = block_r; i < s->s_blocksize * 8; i++) | 172 | for (i = block_r; i < s->s_blocksize * 8; i++) |
174 | reiserfs_test_and_clear_le_bit(i, bh->b_data); | 173 | reiserfs_test_and_clear_le_bit(i, bh->b_data); |
175 | info->free_count += s->s_blocksize * 8 - block_r; | 174 | info->free_count += s->s_blocksize * 8 - block_r; |
176 | if (!info->first_zero_hint) | ||
177 | info->first_zero_hint = block_r; | ||
178 | 175 | ||
179 | journal_mark_dirty(&th, s, bh); | 176 | journal_mark_dirty(&th, s, bh); |
180 | brelse(bh); | 177 | brelse(bh); |
@@ -196,9 +193,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
196 | brelse(bh); | 193 | brelse(bh); |
197 | 194 | ||
198 | info->free_count -= s->s_blocksize * 8 - block_r_new; | 195 | 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 */ | 196 | /* update super */ |
203 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); | 197 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
204 | free_blocks = SB_FREE_BLOCKS(s); | 198 | free_blocks = SB_FREE_BLOCKS(s); |