aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/bitmap.c')
-rw-r--r--fs/reiserfs/bitmap.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index f09a6f6d3ac0..16b331dd9913 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -61,6 +61,7 @@ static inline void get_bit_address(struct super_block *s,
61int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value) 61int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
62{ 62{
63 unsigned int bmap, offset; 63 unsigned int bmap, offset;
64 unsigned int bmap_count = reiserfs_bmap_count(s);
64 65
65 if (block == 0 || block >= SB_BLOCK_COUNT(s)) { 66 if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
66 reiserfs_warning(s, 67 reiserfs_warning(s,
@@ -76,25 +77,26 @@ int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
76 if (unlikely(test_bit(REISERFS_OLD_FORMAT, 77 if (unlikely(test_bit(REISERFS_OLD_FORMAT,
77 &(REISERFS_SB(s)->s_properties)))) { 78 &(REISERFS_SB(s)->s_properties)))) {
78 b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1; 79 b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1;
79 if (block >= bmap1 && block <= bmap1 + SB_BMAP_NR(s)) { 80 if (block >= bmap1 &&
81 block <= bmap1 + bmap_count) {
80 reiserfs_warning(s, "vs: 4019: is_reusable: " 82 reiserfs_warning(s, "vs: 4019: is_reusable: "
81 "bitmap block %lu(%u) can't be freed or reused", 83 "bitmap block %lu(%u) can't be freed or reused",
82 block, SB_BMAP_NR(s)); 84 block, bmap_count);
83 return 0; 85 return 0;
84 } 86 }
85 } else { 87 } else {
86 if (offset == 0) { 88 if (offset == 0) {
87 reiserfs_warning(s, "vs: 4020: is_reusable: " 89 reiserfs_warning(s, "vs: 4020: is_reusable: "
88 "bitmap block %lu(%u) can't be freed or reused", 90 "bitmap block %lu(%u) can't be freed or reused",
89 block, SB_BMAP_NR(s)); 91 block, bmap_count);
90 return 0; 92 return 0;
91 } 93 }
92 } 94 }
93 95
94 if (bmap >= SB_BMAP_NR(s)) { 96 if (bmap >= bmap_count) {
95 reiserfs_warning(s, 97 reiserfs_warning(s,
96 "vs-4030: is_reusable: there is no so many bitmap blocks: " 98 "vs-4030: is_reusable: there is no so many bitmap blocks: "
97 "block=%lu, bitmap_nr=%d", block, bmap); 99 "block=%lu, bitmap_nr=%u", block, bmap);
98 return 0; 100 return 0;
99 } 101 }
100 102
@@ -143,8 +145,8 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th,
143 145
144 BUG_ON(!th->t_trans_id); 146 BUG_ON(!th->t_trans_id);
145 147
146 RFALSE(bmap_n >= SB_BMAP_NR(s), "Bitmap %d is out of range (0..%d)", 148 RFALSE(bmap_n >= reiserfs_bmap_count(s), "Bitmap %u is out of "
147 bmap_n, SB_BMAP_NR(s) - 1); 149 "range (0..%u)", bmap_n, reiserfs_bmap_count(s) - 1);
148 PROC_INFO_INC(s, scan_bitmap.bmap); 150 PROC_INFO_INC(s, scan_bitmap.bmap);
149/* this is unclear and lacks comments, explain how journal bitmaps 151/* this is unclear and lacks comments, explain how journal bitmaps
150 work here for the reader. Convey a sense of the design here. What 152 work here for the reader. Convey a sense of the design here. What
@@ -249,12 +251,12 @@ static int bmap_hash_id(struct super_block *s, u32 id)
249 } else { 251 } else {
250 hash_in = (char *)(&id); 252 hash_in = (char *)(&id);
251 hash = keyed_hash(hash_in, 4); 253 hash = keyed_hash(hash_in, 4);
252 bm = hash % SB_BMAP_NR(s); 254 bm = hash % reiserfs_bmap_count(s);
253 if (!bm) 255 if (!bm)
254 bm = 1; 256 bm = 1;
255 } 257 }
256 /* this can only be true when SB_BMAP_NR = 1 */ 258 /* this can only be true when SB_BMAP_NR = 1 */
257 if (bm >= SB_BMAP_NR(s)) 259 if (bm >= reiserfs_bmap_count(s))
258 bm = 0; 260 bm = 0;
259 return bm; 261 return bm;
260} 262}
@@ -328,10 +330,10 @@ static int scan_bitmap(struct reiserfs_transaction_handle *th,
328 330
329 get_bit_address(s, *start, &bm, &off); 331 get_bit_address(s, *start, &bm, &off);
330 get_bit_address(s, finish, &end_bm, &end_off); 332 get_bit_address(s, finish, &end_bm, &end_off);
331 if (bm > SB_BMAP_NR(s)) 333 if (bm > reiserfs_bmap_count(s))
332 return 0; 334 return 0;
333 if (end_bm > SB_BMAP_NR(s)) 335 if (end_bm > reiserfs_bmap_count(s))
334 end_bm = SB_BMAP_NR(s); 336 end_bm = reiserfs_bmap_count(s);
335 337
336 /* When the bitmap is more than 10% free, anyone can allocate. 338 /* When the bitmap is more than 10% free, anyone can allocate.
337 * When it's less than 10% free, only files that already use the 339 * When it's less than 10% free, only files that already use the
@@ -397,10 +399,12 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,
397 399
398 get_bit_address(s, block, &nr, &offset); 400 get_bit_address(s, block, &nr, &offset);
399 401
400 if (nr >= sb_bmap_nr(rs)) { 402 if (nr >= reiserfs_bmap_count(s)) {
401 reiserfs_warning(s, "vs-4075: reiserfs_free_block: " 403 reiserfs_warning(s, "vs-4075: reiserfs_free_block: "
402 "block %lu is out of range on %s", 404 "block %lu is out of range on %s "
403 block, reiserfs_bdevname(s)); 405 "(nr=%u,max=%u)", block,
406 reiserfs_bdevname(s), nr,
407 reiserfs_bmap_count(s));
404 return; 408 return;
405 } 409 }
406 410
@@ -1269,12 +1273,13 @@ struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb,
1269int reiserfs_init_bitmap_cache(struct super_block *sb) 1273int reiserfs_init_bitmap_cache(struct super_block *sb)
1270{ 1274{
1271 struct reiserfs_bitmap_info *bitmap; 1275 struct reiserfs_bitmap_info *bitmap;
1276 unsigned int bmap_nr = reiserfs_bmap_count(sb);
1272 1277
1273 bitmap = vmalloc(sizeof (*bitmap) * SB_BMAP_NR(sb)); 1278 bitmap = vmalloc(sizeof(*bitmap) * bmap_nr);
1274 if (bitmap == NULL) 1279 if (bitmap == NULL)
1275 return -ENOMEM; 1280 return -ENOMEM;
1276 1281
1277 memset(bitmap, 0xff, sizeof(*bitmap) * SB_BMAP_NR(sb)); 1282 memset(bitmap, 0xff, sizeof(*bitmap) * bmap_nr);
1278 1283
1279 SB_AP_BITMAP(sb) = bitmap; 1284 SB_AP_BITMAP(sb) = bitmap;
1280 1285