Skip to content

Commit abf1b3c

Browse files
author
Tao Ma
committed
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>
1 parent 74380c4 commit abf1b3c

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

‎fs/ocfs2/suballoc.c‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,10 +1982,10 @@ int ocfs2_claim_metadata(handle_t *handle,
19821982
}
19831983

19841984
static void ocfs2_init_inode_ac_group(struct inode *dir,
1985-
struct buffer_head *parent_fe_bh,
1985+
struct buffer_head *parent_di_bh,
19861986
struct ocfs2_alloc_context *ac)
19871987
{
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;
19891989
/*
19901990
* Try to allocate inodes from some specific group.
19911991
*
@@ -1999,10 +1999,14 @@ static void ocfs2_init_inode_ac_group(struct inode *dir,
19991999
if (OCFS2_I(dir)->ip_last_used_group &&
20002000
OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot)
20012001
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)
2003-
ac->ac_last_group = ocfs2_which_suballoc_group(
2004-
le64_to_cpu(fe->i_blkno),
2005-
le16_to_cpu(fe->i_suballoc_bit));
2002+
else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) {
2003+
if (di->i_suballoc_loc)
2004+
ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc);
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+
}
20062010
}
20072011

20082012
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,
26202624
struct buffer_head *alloc_bh, u64 blkno,
26212625
u16 bit, int *res)
26222626
{
2623-
struct ocfs2_dinode *alloc_fe;
2627+
struct ocfs2_dinode *alloc_di;
26242628
struct ocfs2_group_desc *group;
26252629
struct buffer_head *group_bh = NULL;
26262630
u64 bg_blkno;
@@ -2629,17 +2633,20 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb,
26292633
mlog_entry("blkno: %llu bit: %u\n", (unsigned long long)blkno,
26302634
(unsigned int)bit);
26312635

2632-
alloc_fe = (struct ocfs2_dinode *)alloc_bh->b_data;
2633-
if ((bit + 1) > ocfs2_bits_per_group(&alloc_fe->id2.i_chain)) {
2636+
alloc_di = (struct ocfs2_dinode *)alloc_bh->b_data;
2637+
if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) {
26342638
mlog(ML_ERROR, "suballoc bit %u out of range of %u\n",
26352639
(unsigned int)bit,
2636-
ocfs2_bits_per_group(&alloc_fe->id2.i_chain));
2640+
ocfs2_bits_per_group(&alloc_di->id2.i_chain));
26372641
status = -EINVAL;
26382642
goto bail;
26392643
}
26402644

2641-
bg_blkno = ocfs2_which_suballoc_group(blkno, bit);
2642-
status = ocfs2_read_group_descriptor(suballoc, alloc_fe, bg_blkno,
2645+
if (alloc_di->i_suballoc_loc)
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,
26432650
&group_bh);
26442651
if (status < 0) {
26452652
mlog(ML_ERROR, "read group %llu failed %d\n",

0 commit comments

Comments
 (0)