diff options
author | Eric Sandeen <sandeen@redhat.com> | 2009-08-25 22:36:45 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-08-25 22:36:45 -0400 |
commit | a36b44988cef1fc007535107013571fa691a2d7f (patch) | |
tree | b9d659b8ac2a1068f6fbc08ac093902333512c70 /fs | |
parent | 1927805e6599d8602d2c0af6a0155c85acc0b214 (diff) |
ext4: use ext4_grpblk_t more extensively
unsigned short is potentially too small to track blocks within
a group; today it is safe due to restrictions in e2fsprogs but
we have _lo / _hi bits for group blocks with the intent to go
up to 32 bits, so clean this up now.
There are many more places where we use unsigned/int/unsigned int
to contain a group block but this should at least fix all the
short types.
I added a few comments to the struct ext4_group_info definition
as well.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ext4.h | 11 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 18 | ||||
-rw-r--r-- | fs/ext4/mballoc.h | 6 |
3 files changed, 19 insertions, 16 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 02b22885eb02..41a76e163b99 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -1577,15 +1577,18 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize) | |||
1577 | struct ext4_group_info { | 1577 | struct ext4_group_info { |
1578 | unsigned long bb_state; | 1578 | unsigned long bb_state; |
1579 | struct rb_root bb_free_root; | 1579 | struct rb_root bb_free_root; |
1580 | unsigned short bb_first_free; | 1580 | ext4_grpblk_t bb_first_free; /* first free block */ |
1581 | unsigned short bb_free; | 1581 | ext4_grpblk_t bb_free; /* total free blocks */ |
1582 | unsigned short bb_fragments; | 1582 | ext4_grpblk_t bb_fragments; /* nr of freespace fragments */ |
1583 | struct list_head bb_prealloc_list; | 1583 | struct list_head bb_prealloc_list; |
1584 | #ifdef DOUBLE_CHECK | 1584 | #ifdef DOUBLE_CHECK |
1585 | void *bb_bitmap; | 1585 | void *bb_bitmap; |
1586 | #endif | 1586 | #endif |
1587 | struct rw_semaphore alloc_sem; | 1587 | struct rw_semaphore alloc_sem; |
1588 | unsigned short bb_counters[]; | 1588 | ext4_grpblk_t bb_counters[]; /* Nr of free power-of-two-block |
1589 | * regions, index is order. | ||
1590 | * bb_counters[3] = 5 means | ||
1591 | * 5 free 8-block regions. */ | ||
1589 | }; | 1592 | }; |
1590 | 1593 | ||
1591 | #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 | 1594 | #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 081eaf7fce89..3086b3c65adc 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -623,13 +623,13 @@ static int __mb_check_buddy(struct ext4_buddy *e4b, char *file, | |||
623 | 623 | ||
624 | /* FIXME!! need more doc */ | 624 | /* FIXME!! need more doc */ |
625 | static void ext4_mb_mark_free_simple(struct super_block *sb, | 625 | static void ext4_mb_mark_free_simple(struct super_block *sb, |
626 | void *buddy, unsigned first, int len, | 626 | void *buddy, ext4_grpblk_t first, ext4_grpblk_t len, |
627 | struct ext4_group_info *grp) | 627 | struct ext4_group_info *grp) |
628 | { | 628 | { |
629 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 629 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
630 | unsigned short min; | 630 | ext4_grpblk_t min; |
631 | unsigned short max; | 631 | ext4_grpblk_t max; |
632 | unsigned short chunk; | 632 | ext4_grpblk_t chunk; |
633 | unsigned short border; | 633 | unsigned short border; |
634 | 634 | ||
635 | BUG_ON(len > EXT4_BLOCKS_PER_GROUP(sb)); | 635 | BUG_ON(len > EXT4_BLOCKS_PER_GROUP(sb)); |
@@ -663,10 +663,10 @@ void ext4_mb_generate_buddy(struct super_block *sb, | |||
663 | void *buddy, void *bitmap, ext4_group_t group) | 663 | void *buddy, void *bitmap, ext4_group_t group) |
664 | { | 664 | { |
665 | struct ext4_group_info *grp = ext4_get_group_info(sb, group); | 665 | struct ext4_group_info *grp = ext4_get_group_info(sb, group); |
666 | unsigned short max = EXT4_BLOCKS_PER_GROUP(sb); | 666 | ext4_grpblk_t max = EXT4_BLOCKS_PER_GROUP(sb); |
667 | unsigned short i = 0; | 667 | ext4_grpblk_t i = 0; |
668 | unsigned short first; | 668 | ext4_grpblk_t first; |
669 | unsigned short len; | 669 | ext4_grpblk_t len; |
670 | unsigned free = 0; | 670 | unsigned free = 0; |
671 | unsigned fragments = 0; | 671 | unsigned fragments = 0; |
672 | unsigned long long period = get_cycles(); | 672 | unsigned long long period = get_cycles(); |
@@ -2325,7 +2325,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2325 | struct ext4_buddy e4b; | 2325 | struct ext4_buddy e4b; |
2326 | struct sg { | 2326 | struct sg { |
2327 | struct ext4_group_info info; | 2327 | struct ext4_group_info info; |
2328 | unsigned short counters[16]; | 2328 | ext4_grpblk_t counters[16]; |
2329 | } sg; | 2329 | } sg; |
2330 | 2330 | ||
2331 | group--; | 2331 | group--; |
diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h index 9db890d4d275..188d3d709b24 100644 --- a/fs/ext4/mballoc.h +++ b/fs/ext4/mballoc.h | |||
@@ -136,8 +136,8 @@ struct ext4_prealloc_space { | |||
136 | unsigned pa_deleted; | 136 | unsigned pa_deleted; |
137 | ext4_fsblk_t pa_pstart; /* phys. block */ | 137 | ext4_fsblk_t pa_pstart; /* phys. block */ |
138 | ext4_lblk_t pa_lstart; /* log. block */ | 138 | ext4_lblk_t pa_lstart; /* log. block */ |
139 | unsigned short pa_len; /* len of preallocated chunk */ | 139 | ext4_grpblk_t pa_len; /* len of preallocated chunk */ |
140 | unsigned short pa_free; /* how many blocks are free */ | 140 | ext4_grpblk_t pa_free; /* how many blocks are free */ |
141 | unsigned short pa_type; /* pa type. inode or group */ | 141 | unsigned short pa_type; /* pa type. inode or group */ |
142 | spinlock_t *pa_obj_lock; | 142 | spinlock_t *pa_obj_lock; |
143 | struct inode *pa_inode; /* hack, for history only */ | 143 | struct inode *pa_inode; /* hack, for history only */ |
@@ -152,7 +152,7 @@ struct ext4_free_extent { | |||
152 | ext4_lblk_t fe_logical; | 152 | ext4_lblk_t fe_logical; |
153 | ext4_grpblk_t fe_start; | 153 | ext4_grpblk_t fe_start; |
154 | ext4_group_t fe_group; | 154 | ext4_group_t fe_group; |
155 | int fe_len; | 155 | ext4_grpblk_t fe_len; |
156 | }; | 156 | }; |
157 | 157 | ||
158 | /* | 158 | /* |