Skip to content

Commit b2b6ebf

Browse files
Mark FashehTao Ma
authored andcommitted
ocfs2: properly set and use inode group alloc hint
We were setting ac->ac_last_group in ocfs2_claim_suballoc_bits from res->sr_bg_blkno. Unfortunately, res->sr_bg_blkno is going to be zero under normal (non-fragmented) circumstances. The discontig block group patches effectively turned off that feature. Fix this by correctly calculating what the next group hint should be. Acked-by: Tao Ma <tao.ma@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com> Tested-by: Goldwyn Rodrigues <rgoldwyn@suse.de> Signed-off-by: Tao Ma <tao.ma@oracle.com>
1 parent 889f004 commit b2b6ebf

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

‎fs/ocfs2/suballoc.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ struct ocfs2_suballoc_result {
6262
unsigned int sr_bits; /* How many bits we claimed */
6363
};
6464

65+
static u64 ocfs2_group_from_res(struct ocfs2_suballoc_result *res)
66+
{
67+
if (res->sr_blkno == 0)
68+
return 0;
69+
70+
if (res->sr_bg_blkno)
71+
return res->sr_bg_blkno;
72+
73+
return ocfs2_which_suballoc_group(res->sr_blkno, res->sr_bit_offset);
74+
}
75+
6576
static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
6677
static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
6778
static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl);
@@ -1845,6 +1856,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
18451856
int status;
18461857
u16 victim, i;
18471858
u16 bits_left = 0;
1859+
u64 hint = ac->ac_last_group;
18481860
struct ocfs2_chain_list *cl;
18491861
struct ocfs2_dinode *fe;
18501862

@@ -1872,7 +1884,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
18721884
goto bail;
18731885
}
18741886

1875-
res->sr_bg_blkno = ac->ac_last_group;
1887+
res->sr_bg_blkno = hint;
18761888
if (res->sr_bg_blkno) {
18771889
/* Attempt to short-circuit the usual search mechanism
18781890
* by jumping straight to the most recently used
@@ -1896,8 +1908,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
18961908

18971909
status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
18981910
res, &bits_left);
1899-
if (!status)
1911+
if (!status) {
1912+
hint = ocfs2_group_from_res(res);
19001913
goto set_hint;
1914+
}
19011915
if (status < 0 && status != -ENOSPC) {
19021916
mlog_errno(status);
19031917
goto bail;
@@ -1920,8 +1934,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
19201934
ac->ac_chain = i;
19211935
status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
19221936
res, &bits_left);
1923-
if (!status)
1937+
if (!status) {
1938+
hint = ocfs2_group_from_res(res);
19241939
break;
1940+
}
19251941
if (status < 0 && status != -ENOSPC) {
19261942
mlog_errno(status);
19271943
goto bail;
@@ -1936,7 +1952,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
19361952
if (bits_left < min_bits)
19371953
ac->ac_last_group = 0;
19381954
else
1939-
ac->ac_last_group = res->sr_bg_blkno;
1955+
ac->ac_last_group = hint;
19401956
}
19411957

19421958
bail:

0 commit comments

Comments
 (0)