aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2007-10-19 02:39:25 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:35 -0400
commit3ee1667042c350003b9d3f35e5666cc8c43ce8aa (patch)
tree331217461b684c298397d7347431c500c5969148 /fs/reiserfs
parent6c57c2c8d3862c8d5b908669654f6565da74ec19 (diff)
reiserfs: fix usage of signed ints for block numbers
Do a quick signedness check for block numbers. There are a number of places where signed integers are used for block numbers, which limits the usable file system size to 8 TiB. The disk format, excepting a problem which will be fixed in the following patch, supports file systems up to 16 TiB in size. This patch cleans up those sites so that we can enable the full usable size. 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.c24
-rw-r--r--fs/reiserfs/inode.c8
-rw-r--r--fs/reiserfs/journal.c18
-rw-r--r--fs/reiserfs/stree.c6
4 files changed, 30 insertions, 26 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index 28a1b06081fc..f7275176305e 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -47,7 +47,9 @@
47 test_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s)) 47 test_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s))
48 48
49static inline void get_bit_address(struct super_block *s, 49static inline void get_bit_address(struct super_block *s,
50 b_blocknr_t block, int *bmap_nr, int *offset) 50 b_blocknr_t block,
51 unsigned int *bmap_nr,
52 unsigned int *offset)
51{ 53{
52 /* It is in the bitmap block number equal to the block 54 /* It is in the bitmap block number equal to the block
53 * number divided by the number of bits in a block. */ 55 * number divided by the number of bits in a block. */
@@ -58,7 +60,7 @@ static inline void get_bit_address(struct super_block *s,
58 60
59int 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)
60{ 62{
61 int bmap, offset; 63 unsigned int bmap, offset;
62 64
63 if (block == 0 || block >= SB_BLOCK_COUNT(s)) { 65 if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
64 reiserfs_warning(s, 66 reiserfs_warning(s,
@@ -108,8 +110,8 @@ int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
108 110
109/* searches in journal structures for a given block number (bmap, off). If block 111/* searches in journal structures for a given block number (bmap, off). If block
110 is found in reiserfs journal it suggests next free block candidate to test. */ 112 is found in reiserfs journal it suggests next free block candidate to test. */
111static inline int is_block_in_journal(struct super_block *s, int bmap, int 113static inline int is_block_in_journal(struct super_block *s, unsigned int bmap,
112 off, int *next) 114 int off, int *next)
113{ 115{
114 b_blocknr_t tmp; 116 b_blocknr_t tmp;
115 117
@@ -130,8 +132,8 @@ static inline int is_block_in_journal(struct super_block *s, int bmap, int
130/* it searches for a window of zero bits with given minimum and maximum lengths in one bitmap 132/* it searches for a window of zero bits with given minimum and maximum lengths in one bitmap
131 * block; */ 133 * block; */
132static int scan_bitmap_block(struct reiserfs_transaction_handle *th, 134static int scan_bitmap_block(struct reiserfs_transaction_handle *th,
133 int bmap_n, int *beg, int boundary, int min, 135 unsigned int bmap_n, int *beg, int boundary,
134 int max, int unfm) 136 int min, int max, int unfm)
135{ 137{
136 struct super_block *s = th->t_super; 138 struct super_block *s = th->t_super;
137 struct reiserfs_bitmap_info *bi = &SB_AP_BITMAP(s)[bmap_n]; 139 struct reiserfs_bitmap_info *bi = &SB_AP_BITMAP(s)[bmap_n];
@@ -307,16 +309,16 @@ __le32 reiserfs_choose_packing(struct inode * dir)
307 * bitmap and place new blocks there. Returns number of allocated blocks. */ 309 * bitmap and place new blocks there. Returns number of allocated blocks. */
308static int scan_bitmap(struct reiserfs_transaction_handle *th, 310static int scan_bitmap(struct reiserfs_transaction_handle *th,
309 b_blocknr_t * start, b_blocknr_t finish, 311 b_blocknr_t * start, b_blocknr_t finish,
310 int min, int max, int unfm, unsigned long file_block) 312 int min, int max, int unfm, sector_t file_block)
311{ 313{
312 int nr_allocated = 0; 314 int nr_allocated = 0;
313 struct super_block *s = th->t_super; 315 struct super_block *s = th->t_super;
314 /* find every bm and bmap and bmap_nr in this file, and change them all to bitmap_blocknr 316 /* find every bm and bmap and bmap_nr in this file, and change them all to bitmap_blocknr
315 * - Hans, it is not a block number - Zam. */ 317 * - Hans, it is not a block number - Zam. */
316 318
317 int bm, off; 319 unsigned int bm, off;
318 int end_bm, end_off; 320 unsigned int end_bm, end_off;
319 int off_max = s->s_blocksize << 3; 321 unsigned int off_max = s->s_blocksize << 3;
320 322
321 BUG_ON(!th->t_trans_id); 323 BUG_ON(!th->t_trans_id);
322 324
@@ -383,7 +385,7 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,
383 struct reiserfs_super_block *rs; 385 struct reiserfs_super_block *rs;
384 struct buffer_head *sbh, *bmbh; 386 struct buffer_head *sbh, *bmbh;
385 struct reiserfs_bitmap_info *apbi; 387 struct reiserfs_bitmap_info *apbi;
386 int nr, offset; 388 unsigned int nr, offset;
387 389
388 BUG_ON(!th->t_trans_id); 390 BUG_ON(!th->t_trans_id);
389 391
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 0804289d355d..a991af96f3f0 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -199,7 +199,7 @@ static inline void set_block_dev_mapped(struct buffer_head *bh,
199// files which were created in the earlier version can not be longer, 199// files which were created in the earlier version can not be longer,
200// than 2 gb 200// than 2 gb
201// 201//
202static int file_capable(struct inode *inode, long block) 202static int file_capable(struct inode *inode, sector_t block)
203{ 203{
204 if (get_inode_item_key_version(inode) != KEY_FORMAT_3_5 || // it is new file. 204 if (get_inode_item_key_version(inode) != KEY_FORMAT_3_5 || // it is new file.
205 block < (1 << (31 - inode->i_sb->s_blocksize_bits))) // old file, but 'block' is inside of 2gb 205 block < (1 << (31 - inode->i_sb->s_blocksize_bits))) // old file, but 'block' is inside of 2gb
@@ -242,7 +242,7 @@ static int restart_transaction(struct reiserfs_transaction_handle *th,
242// Please improve the english/clarity in the comment above, as it is 242// Please improve the english/clarity in the comment above, as it is
243// hard to understand. 243// hard to understand.
244 244
245static int _get_block_create_0(struct inode *inode, long block, 245static int _get_block_create_0(struct inode *inode, sector_t block,
246 struct buffer_head *bh_result, int args) 246 struct buffer_head *bh_result, int args)
247{ 247{
248 INITIALIZE_PATH(path); 248 INITIALIZE_PATH(path);
@@ -250,7 +250,7 @@ static int _get_block_create_0(struct inode *inode, long block,
250 struct buffer_head *bh; 250 struct buffer_head *bh;
251 struct item_head *ih, tmp_ih; 251 struct item_head *ih, tmp_ih;
252 int fs_gen; 252 int fs_gen;
253 int blocknr; 253 b_blocknr_t blocknr;
254 char *p = NULL; 254 char *p = NULL;
255 int chars; 255 int chars;
256 int ret; 256 int ret;
@@ -569,7 +569,7 @@ static int convert_tail_for_hole(struct inode *inode,
569} 569}
570 570
571static inline int _allocate_block(struct reiserfs_transaction_handle *th, 571static inline int _allocate_block(struct reiserfs_transaction_handle *th,
572 long block, 572 sector_t block,
573 struct inode *inode, 573 struct inode *inode,
574 b_blocknr_t * allocated_block_nr, 574 b_blocknr_t * allocated_block_nr,
575 struct treepath *path, int flags) 575 struct treepath *path, int flags)
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 4cad9e75ef56..0e30ba0ac489 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -219,11 +219,12 @@ static void allocate_bitmap_nodes(struct super_block *p_s_sb)
219 } 219 }
220} 220}
221 221
222static int set_bit_in_list_bitmap(struct super_block *p_s_sb, int block, 222static int set_bit_in_list_bitmap(struct super_block *p_s_sb,
223 b_blocknr_t block,
223 struct reiserfs_list_bitmap *jb) 224 struct reiserfs_list_bitmap *jb)
224{ 225{
225 int bmap_nr = block / (p_s_sb->s_blocksize << 3); 226 unsigned int bmap_nr = block / (p_s_sb->s_blocksize << 3);
226 int bit_nr = block % (p_s_sb->s_blocksize << 3); 227 unsigned int bit_nr = block % (p_s_sb->s_blocksize << 3);
227 228
228 if (!jb->bitmaps[bmap_nr]) { 229 if (!jb->bitmaps[bmap_nr]) {
229 jb->bitmaps[bmap_nr] = get_bitmap_node(p_s_sb); 230 jb->bitmaps[bmap_nr] = get_bitmap_node(p_s_sb);
@@ -289,7 +290,7 @@ static int free_bitmap_nodes(struct super_block *p_s_sb)
289*/ 290*/
290int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb, 291int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb,
291 struct reiserfs_list_bitmap *jb_array, 292 struct reiserfs_list_bitmap *jb_array,
292 int bmap_nr) 293 unsigned int bmap_nr)
293{ 294{
294 int i; 295 int i;
295 int failed = 0; 296 int failed = 0;
@@ -483,7 +484,7 @@ static inline struct reiserfs_journal_cnode *get_journal_hash_dev(struct
483** 484**
484*/ 485*/
485int reiserfs_in_journal(struct super_block *p_s_sb, 486int reiserfs_in_journal(struct super_block *p_s_sb,
486 int bmap_nr, int bit_nr, int search_all, 487 unsigned int bmap_nr, int bit_nr, int search_all,
487 b_blocknr_t * next_zero_bit) 488 b_blocknr_t * next_zero_bit)
488{ 489{
489 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 490 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
@@ -1013,7 +1014,7 @@ static int flush_commit_list(struct super_block *s,
1013 struct reiserfs_journal_list *jl, int flushall) 1014 struct reiserfs_journal_list *jl, int flushall)
1014{ 1015{
1015 int i; 1016 int i;
1016 int bn; 1017 b_blocknr_t bn;
1017 struct buffer_head *tbh = NULL; 1018 struct buffer_head *tbh = NULL;
1018 unsigned long trans_id = jl->j_trans_id; 1019 unsigned long trans_id = jl->j_trans_id;
1019 struct reiserfs_journal *journal = SB_JOURNAL(s); 1020 struct reiserfs_journal *journal = SB_JOURNAL(s);
@@ -2307,8 +2308,9 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2307 Right now it is only used from journal code. But later we might use it 2308 Right now it is only used from journal code. But later we might use it
2308 from other places. 2309 from other places.
2309 Note: Do not use journal_getblk/sb_getblk functions here! */ 2310 Note: Do not use journal_getblk/sb_getblk functions here! */
2310static struct buffer_head *reiserfs_breada(struct block_device *dev, int block, 2311static struct buffer_head *reiserfs_breada(struct block_device *dev,
2311 int bufsize, unsigned int max_block) 2312 b_blocknr_t block, int bufsize,
2313 b_blocknr_t max_block)
2312{ 2314{
2313 struct buffer_head *bhlist[BUFNR]; 2315 struct buffer_head *bhlist[BUFNR];
2314 unsigned int blocks = BUFNR; 2316 unsigned int blocks = BUFNR;
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 981027d1187b..ca41567d7890 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -559,7 +559,7 @@ static int is_tree_node(struct buffer_head *bh, int level)
559/* The function is NOT SCHEDULE-SAFE! */ 559/* The function is NOT SCHEDULE-SAFE! */
560static void search_by_key_reada(struct super_block *s, 560static void search_by_key_reada(struct super_block *s,
561 struct buffer_head **bh, 561 struct buffer_head **bh,
562 unsigned long *b, int num) 562 b_blocknr_t *b, int num)
563{ 563{
564 int i, j; 564 int i, j;
565 565
@@ -611,7 +611,7 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /*
611 DISK_LEAF_NODE_LEVEL */ 611 DISK_LEAF_NODE_LEVEL */
612 ) 612 )
613{ 613{
614 int n_block_number; 614 b_blocknr_t n_block_number;
615 int expected_level; 615 int expected_level;
616 struct buffer_head *p_s_bh; 616 struct buffer_head *p_s_bh;
617 struct path_element *p_s_last_element; 617 struct path_element *p_s_last_element;
@@ -619,7 +619,7 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /*
619 int right_neighbor_of_leaf_node; 619 int right_neighbor_of_leaf_node;
620 int fs_gen; 620 int fs_gen;
621 struct buffer_head *reada_bh[SEARCH_BY_KEY_READA]; 621 struct buffer_head *reada_bh[SEARCH_BY_KEY_READA];
622 unsigned long reada_blocks[SEARCH_BY_KEY_READA]; 622 b_blocknr_t reada_blocks[SEARCH_BY_KEY_READA];
623 int reada_count = 0; 623 int reada_count = 0;
624 624
625#ifdef CONFIG_REISERFS_CHECK 625#ifdef CONFIG_REISERFS_CHECK