Skip to content

Commit 4d20851

Browse files
jeffmahoneyLinus Torvalds
authored andcommitted
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>
1 parent 3ee1667 commit 4d20851

3 files changed

Lines changed: 13 additions & 26 deletions

File tree

‎fs/reiserfs/bitmap.c‎

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static inline int block_group_used(struct super_block *s, u32 id)
273273
* to make a better decision. This favors long-term performace gain
274274
* with a better on-disk layout vs. a short term gain of skipping the
275275
* read and potentially having a bad placement. */
276-
if (info->first_zero_hint == 0) {
276+
if (info->free_count == UINT_MAX) {
277277
struct buffer_head *bh = reiserfs_read_bitmap_block(s, bm);
278278
brelse(bh);
279279
}
@@ -1214,27 +1214,22 @@ void reiserfs_cache_bitmap_metadata(struct super_block *sb,
12141214
{
12151215
unsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size);
12161216

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;
12181221

12191222
while (--cur >= (unsigned long *)bh->b_data) {
1220-
int base = ((char *)cur - bh->b_data) << 3;
1223+
int i;
12211224

12221225
/* 0 and ~0 are special, we can optimize for them */
1223-
if (*cur == 0) {
1224-
info->first_zero_hint = base;
1226+
if (*cur == 0)
12251227
info->free_count += BITS_PER_LONG;
1226-
} else if (*cur != ~0L) { /* A mix, investigate */
1227-
int b;
1228-
for (b = BITS_PER_LONG - 1; b >= 0; b--) {
1229-
if (!reiserfs_test_le_bit(b, cur)) {
1230-
info->first_zero_hint = base + b;
1228+
else if (*cur != ~0L) /* A mix, investigate */
1229+
for (i = BITS_PER_LONG - 1; i >= 0; i--)
1230+
if (!reiserfs_test_le_bit(i, cur))
12311231
info->free_count++;
1232-
}
1233-
}
1234-
}
12351232
}
1236-
/* The first bit must ALWAYS be 1 */
1237-
BUG_ON(info->first_zero_hint == 0);
12381233
}
12391234

12401235
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,
12641259
BUG_ON(!buffer_uptodate(bh));
12651260
BUG_ON(atomic_read(&bh->b_count) == 0);
12661261

1267-
if (info->first_zero_hint == 0)
1262+
if (info->free_count == UINT_MAX)
12681263
reiserfs_cache_bitmap_metadata(sb, bh, info);
12691264
}
12701265

@@ -1279,7 +1274,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb)
12791274
if (bitmap == NULL)
12801275
return -ENOMEM;
12811276

1282-
memset(bitmap, 0, sizeof (*bitmap) * SB_BMAP_NR(sb));
1277+
memset(bitmap, 0xff, sizeof(*bitmap) * SB_BMAP_NR(sb));
12831278

12841279
SB_AP_BITMAP(sb) = bitmap;
12851280

‎fs/reiserfs/resize.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
143143
mark_buffer_dirty(bh);
144144
sync_dirty_buffer(bh);
145145
// update bitmap_info stuff
146-
bitmap[i].first_zero_hint = 1;
147146
bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
148147
brelse(bh);
149148
}
@@ -173,8 +172,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
173172
for (i = block_r; i < s->s_blocksize * 8; i++)
174173
reiserfs_test_and_clear_le_bit(i, bh->b_data);
175174
info->free_count += s->s_blocksize * 8 - block_r;
176-
if (!info->first_zero_hint)
177-
info->first_zero_hint = block_r;
178175

179176
journal_mark_dirty(&th, s, bh);
180177
brelse(bh);
@@ -196,9 +193,6 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
196193
brelse(bh);
197194

198195
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;
202196
/* update super */
203197
reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
204198
free_blocks = SB_FREE_BLOCKS(s);

‎include/linux/reiserfs_fs_sb.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ enum journal_state_bits {
265265
typedef __u32(*hashf_t) (const signed char *, int);
266266

267267
struct reiserfs_bitmap_info {
268-
// FIXME: Won't work with block sizes > 8K
269-
__u16 first_zero_hint;
270-
__u16 free_count;
268+
__u32 free_count;
271269
};
272270

273271
struct proc_dir_entry;

0 commit comments

Comments
 (0)