diff options
author | Tao Ma <tao.ma@oracle.com> | 2010-04-26 20:30:36 -0400 |
---|---|---|
committer | Tao Ma <tao.ma@oracle.com> | 2010-04-26 20:30:36 -0400 |
commit | abf1b3cb5b20fbad27ca9c7497235eeb4dd3f4fd (patch) | |
tree | cd3abb6c107dfdc09c1d8014832ee27803e9e8f6 /fs/ocfs2 | |
parent | 74380c479ad83addeff8a172ab95f59557b5b0c3 (diff) |
ocfs2: Set ac_last_group properly with discontig group.
ac_last_group is used to record the last block group we
used during allocation. But the initialization process
only calls ocfs2_which_suballoc_group and fails to
use suballoc_loc properly. So let us do it.
Another function ocfs2_test_suballoc_bit also needs fix.
I have searched all the callers of ocfs2_which_suballoc_group,
and all the callers notices suballoc_loc now.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/suballoc.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 0c08353fddac..a327c80721ee 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -1982,10 +1982,10 @@ bail: | |||
1982 | } | 1982 | } |
1983 | 1983 | ||
1984 | static void ocfs2_init_inode_ac_group(struct inode *dir, | 1984 | static void ocfs2_init_inode_ac_group(struct inode *dir, |
1985 | struct buffer_head *parent_fe_bh, | 1985 | struct buffer_head *parent_di_bh, |
1986 | struct ocfs2_alloc_context *ac) | 1986 | struct ocfs2_alloc_context *ac) |
1987 | { | 1987 | { |
1988 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *)parent_fe_bh->b_data; | 1988 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_di_bh->b_data; |
1989 | /* | 1989 | /* |
1990 | * Try to allocate inodes from some specific group. | 1990 | * Try to allocate inodes from some specific group. |
1991 | * | 1991 | * |
@@ -1999,10 +1999,14 @@ static void ocfs2_init_inode_ac_group(struct inode *dir, | |||
1999 | if (OCFS2_I(dir)->ip_last_used_group && | 1999 | if (OCFS2_I(dir)->ip_last_used_group && |
2000 | OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) | 2000 | OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) |
2001 | ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; | 2001 | ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; |
2002 | else if (le16_to_cpu(fe->i_suballoc_slot) == ac->ac_alloc_slot) | 2002 | else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { |
2003 | ac->ac_last_group = ocfs2_which_suballoc_group( | 2003 | if (di->i_suballoc_loc) |
2004 | le64_to_cpu(fe->i_blkno), | 2004 | ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); |
2005 | le16_to_cpu(fe->i_suballoc_bit)); | 2005 | else |
2006 | ac->ac_last_group = ocfs2_which_suballoc_group( | ||
2007 | le64_to_cpu(di->i_blkno), | ||
2008 | le16_to_cpu(di->i_suballoc_bit)); | ||
2009 | } | ||
2006 | } | 2010 | } |
2007 | 2011 | ||
2008 | static inline void ocfs2_save_inode_ac_group(struct inode *dir, | 2012 | static inline void ocfs2_save_inode_ac_group(struct inode *dir, |
@@ -2620,7 +2624,7 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
2620 | struct buffer_head *alloc_bh, u64 blkno, | 2624 | struct buffer_head *alloc_bh, u64 blkno, |
2621 | u16 bit, int *res) | 2625 | u16 bit, int *res) |
2622 | { | 2626 | { |
2623 | struct ocfs2_dinode *alloc_fe; | 2627 | struct ocfs2_dinode *alloc_di; |
2624 | struct ocfs2_group_desc *group; | 2628 | struct ocfs2_group_desc *group; |
2625 | struct buffer_head *group_bh = NULL; | 2629 | struct buffer_head *group_bh = NULL; |
2626 | u64 bg_blkno; | 2630 | u64 bg_blkno; |
@@ -2629,17 +2633,20 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
2629 | mlog_entry("blkno: %llu bit: %u\n", (unsigned long long)blkno, | 2633 | mlog_entry("blkno: %llu bit: %u\n", (unsigned long long)blkno, |
2630 | (unsigned int)bit); | 2634 | (unsigned int)bit); |
2631 | 2635 | ||
2632 | alloc_fe = (struct ocfs2_dinode *)alloc_bh->b_data; | 2636 | alloc_di = (struct ocfs2_dinode *)alloc_bh->b_data; |
2633 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_fe->id2.i_chain)) { | 2637 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) { |
2634 | mlog(ML_ERROR, "suballoc bit %u out of range of %u\n", | 2638 | mlog(ML_ERROR, "suballoc bit %u out of range of %u\n", |
2635 | (unsigned int)bit, | 2639 | (unsigned int)bit, |
2636 | ocfs2_bits_per_group(&alloc_fe->id2.i_chain)); | 2640 | ocfs2_bits_per_group(&alloc_di->id2.i_chain)); |
2637 | status = -EINVAL; | 2641 | status = -EINVAL; |
2638 | goto bail; | 2642 | goto bail; |
2639 | } | 2643 | } |
2640 | 2644 | ||
2641 | bg_blkno = ocfs2_which_suballoc_group(blkno, bit); | 2645 | if (alloc_di->i_suballoc_loc) |
2642 | status = ocfs2_read_group_descriptor(suballoc, alloc_fe, bg_blkno, | 2646 | bg_blkno = le64_to_cpu(alloc_di->i_suballoc_loc); |
2647 | else | ||
2648 | bg_blkno = ocfs2_which_suballoc_group(blkno, bit); | ||
2649 | status = ocfs2_read_group_descriptor(suballoc, alloc_di, bg_blkno, | ||
2643 | &group_bh); | 2650 | &group_bh); |
2644 | if (status < 0) { | 2651 | if (status < 0) { |
2645 | mlog(ML_ERROR, "read group %llu failed %d\n", | 2652 | mlog(ML_ERROR, "read group %llu failed %d\n", |