aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ialloc.c
diff options
context:
space:
mode:
authorAvantika Mathur <mathur@us.ibm.com>2008-01-28 23:58:27 -0500
committerTheodore Ts'o <tytso@mit.edu>2008-01-28 23:58:27 -0500
commitfd2d42912f9f09e5250cb3b024ee0625704e9cb7 (patch)
tree23e85123e8cc06d518fd7cff665f93429e19e4e2 /fs/ext4/ialloc.c
parentbba907433b85ba2adae1bb3b6fd29b4e5f35c468 (diff)
ext4: add ext4_group_t, and change all group variables to this type.
In many places variables for block group are of type int, which limits the maximum number of block groups to 2^31. Each block group can have up to 2^15 blocks, with a 4K block size, and the max filesystem size is limited to 2^31 * (2^15 * 2^12) = 2^58 -- or 256 PB This patch introduces a new type ext4_group_t, of type unsigned long, to represent block group numbers in ext4. All occurrences of block group variables are converted to type ext4_group_t. Signed-off-by: Avantika Mathur <mathur@us.ibm.com>
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r--fs/ext4/ialloc.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index c61f37fd3f05..64dea8689e1f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -64,8 +64,8 @@ void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
64} 64}
65 65
66/* Initializes an uninitialized inode bitmap */ 66/* Initializes an uninitialized inode bitmap */
67unsigned ext4_init_inode_bitmap(struct super_block *sb, 67unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
68 struct buffer_head *bh, int block_group, 68 ext4_group_t block_group,
69 struct ext4_group_desc *gdp) 69 struct ext4_group_desc *gdp)
70{ 70{
71 struct ext4_sb_info *sbi = EXT4_SB(sb); 71 struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -75,7 +75,7 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb,
75 /* If checksum is bad mark all blocks and inodes use to prevent 75 /* If checksum is bad mark all blocks and inodes use to prevent
76 * allocation, essentially implementing a per-group read-only flag. */ 76 * allocation, essentially implementing a per-group read-only flag. */
77 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { 77 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
78 ext4_error(sb, __FUNCTION__, "Checksum bad for group %u\n", 78 ext4_error(sb, __FUNCTION__, "Checksum bad for group %lu\n",
79 block_group); 79 block_group);
80 gdp->bg_free_blocks_count = 0; 80 gdp->bg_free_blocks_count = 0;
81 gdp->bg_free_inodes_count = 0; 81 gdp->bg_free_inodes_count = 0;
@@ -98,7 +98,7 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb,
98 * Return buffer_head of bitmap on success or NULL. 98 * Return buffer_head of bitmap on success or NULL.
99 */ 99 */
100static struct buffer_head * 100static struct buffer_head *
101read_inode_bitmap(struct super_block * sb, unsigned long block_group) 101read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
102{ 102{
103 struct ext4_group_desc *desc; 103 struct ext4_group_desc *desc;
104 struct buffer_head *bh = NULL; 104 struct buffer_head *bh = NULL;
@@ -152,7 +152,7 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
152 unsigned long ino; 152 unsigned long ino;
153 struct buffer_head *bitmap_bh = NULL; 153 struct buffer_head *bitmap_bh = NULL;
154 struct buffer_head *bh2; 154 struct buffer_head *bh2;
155 unsigned long block_group; 155 ext4_group_t block_group;
156 unsigned long bit; 156 unsigned long bit;
157 struct ext4_group_desc * gdp; 157 struct ext4_group_desc * gdp;
158 struct ext4_super_block * es; 158 struct ext4_super_block * es;
@@ -260,12 +260,12 @@ error_return:
260 * For other inodes, search forward from the parent directory\'s block 260 * For other inodes, search forward from the parent directory\'s block
261 * group to find a free inode. 261 * group to find a free inode.
262 */ 262 */
263static int find_group_dir(struct super_block *sb, struct inode *parent) 263static ext4_group_t find_group_dir(struct super_block *sb, struct inode *parent)
264{ 264{
265 int ngroups = EXT4_SB(sb)->s_groups_count; 265 ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
266 unsigned int freei, avefreei; 266 unsigned int freei, avefreei;
267 struct ext4_group_desc *desc, *best_desc = NULL; 267 struct ext4_group_desc *desc, *best_desc = NULL;
268 int group, best_group = -1; 268 ext4_group_t group, best_group = -1;
269 269
270 freei = percpu_counter_read_positive(&EXT4_SB(sb)->s_freeinodes_counter); 270 freei = percpu_counter_read_positive(&EXT4_SB(sb)->s_freeinodes_counter);
271 avefreei = freei / ngroups; 271 avefreei = freei / ngroups;
@@ -314,12 +314,13 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
314#define INODE_COST 64 314#define INODE_COST 64
315#define BLOCK_COST 256 315#define BLOCK_COST 256
316 316
317static int find_group_orlov(struct super_block *sb, struct inode *parent) 317static ext4_group_t find_group_orlov(struct super_block *sb,
318 struct inode *parent)
318{ 319{
319 int parent_group = EXT4_I(parent)->i_block_group; 320 ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
320 struct ext4_sb_info *sbi = EXT4_SB(sb); 321 struct ext4_sb_info *sbi = EXT4_SB(sb);
321 struct ext4_super_block *es = sbi->s_es; 322 struct ext4_super_block *es = sbi->s_es;
322 int ngroups = sbi->s_groups_count; 323 ext4_group_t ngroups = sbi->s_groups_count;
323 int inodes_per_group = EXT4_INODES_PER_GROUP(sb); 324 int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
324 unsigned int freei, avefreei; 325 unsigned int freei, avefreei;
325 ext4_fsblk_t freeb, avefreeb; 326 ext4_fsblk_t freeb, avefreeb;
@@ -327,7 +328,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
327 unsigned int ndirs; 328 unsigned int ndirs;
328 int max_debt, max_dirs, min_inodes; 329 int max_debt, max_dirs, min_inodes;
329 ext4_grpblk_t min_blocks; 330 ext4_grpblk_t min_blocks;
330 int group = -1, i; 331 ext4_group_t group = -1, i;
331 struct ext4_group_desc *desc; 332 struct ext4_group_desc *desc;
332 333
333 freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter); 334 freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
@@ -340,7 +341,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
340 if ((parent == sb->s_root->d_inode) || 341 if ((parent == sb->s_root->d_inode) ||
341 (EXT4_I(parent)->i_flags & EXT4_TOPDIR_FL)) { 342 (EXT4_I(parent)->i_flags & EXT4_TOPDIR_FL)) {
342 int best_ndir = inodes_per_group; 343 int best_ndir = inodes_per_group;
343 int best_group = -1; 344 ext4_group_t best_group = -1;
344 345
345 get_random_bytes(&group, sizeof(group)); 346 get_random_bytes(&group, sizeof(group));
346 parent_group = (unsigned)group % ngroups; 347 parent_group = (unsigned)group % ngroups;
@@ -415,12 +416,13 @@ fallback:
415 return -1; 416 return -1;
416} 417}
417 418
418static int find_group_other(struct super_block *sb, struct inode *parent) 419static ext4_group_t find_group_other(struct super_block *sb,
420 struct inode *parent)
419{ 421{
420 int parent_group = EXT4_I(parent)->i_block_group; 422 ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
421 int ngroups = EXT4_SB(sb)->s_groups_count; 423 ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
422 struct ext4_group_desc *desc; 424 struct ext4_group_desc *desc;
423 int group, i; 425 ext4_group_t group, i;
424 426
425 /* 427 /*
426 * Try to place the inode in its parent directory 428 * Try to place the inode in its parent directory
@@ -487,7 +489,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
487 struct super_block *sb; 489 struct super_block *sb;
488 struct buffer_head *bitmap_bh = NULL; 490 struct buffer_head *bitmap_bh = NULL;
489 struct buffer_head *bh2; 491 struct buffer_head *bh2;
490 int group; 492 ext4_group_t group;
491 unsigned long ino = 0; 493 unsigned long ino = 0;
492 struct inode * inode; 494 struct inode * inode;
493 struct ext4_group_desc * gdp = NULL; 495 struct ext4_group_desc * gdp = NULL;
@@ -583,7 +585,7 @@ got:
583 ino > EXT4_INODES_PER_GROUP(sb)) { 585 ino > EXT4_INODES_PER_GROUP(sb)) {
584 ext4_error(sb, __FUNCTION__, 586 ext4_error(sb, __FUNCTION__,
585 "reserved inode or inode > inodes count - " 587 "reserved inode or inode > inodes count - "
586 "block_group = %d, inode=%lu", group, 588 "block_group = %lu, inode=%lu", group,
587 ino + group * EXT4_INODES_PER_GROUP(sb)); 589 ino + group * EXT4_INODES_PER_GROUP(sb));
588 err = -EIO; 590 err = -EIO;
589 goto fail; 591 goto fail;
@@ -777,7 +779,7 @@ fail_drop:
777struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) 779struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
778{ 780{
779 unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count); 781 unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
780 unsigned long block_group; 782 ext4_group_t block_group;
781 int bit; 783 int bit;
782 struct buffer_head *bitmap_bh = NULL; 784 struct buffer_head *bitmap_bh = NULL;
783 struct inode *inode = NULL; 785 struct inode *inode = NULL;
@@ -833,7 +835,7 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
833{ 835{
834 unsigned long desc_count; 836 unsigned long desc_count;
835 struct ext4_group_desc *gdp; 837 struct ext4_group_desc *gdp;
836 int i; 838 ext4_group_t i;
837#ifdef EXT4FS_DEBUG 839#ifdef EXT4FS_DEBUG
838 struct ext4_super_block *es; 840 struct ext4_super_block *es;
839 unsigned long bitmap_count, x; 841 unsigned long bitmap_count, x;
@@ -879,7 +881,7 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
879unsigned long ext4_count_dirs (struct super_block * sb) 881unsigned long ext4_count_dirs (struct super_block * sb)
880{ 882{
881 unsigned long count = 0; 883 unsigned long count = 0;
882 int i; 884 ext4_group_t i;
883 885
884 for (i = 0; i < EXT4_SB(sb)->s_groups_count; i++) { 886 for (i = 0; i < EXT4_SB(sb)->s_groups_count; i++) {
885 struct ext4_group_desc *gdp = ext4_get_group_desc (sb, i, NULL); 887 struct ext4_group_desc *gdp = ext4_get_group_desc (sb, i, NULL);