Commit b2b6ebf5 authored by Mark Fasheh's avatar Mark Fasheh Committed by Tao Ma

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: default avatarTao Ma <tao.ma@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
Tested-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.de>
Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
parent 889f004a
...@@ -62,6 +62,17 @@ struct ocfs2_suballoc_result { ...@@ -62,6 +62,17 @@ struct ocfs2_suballoc_result {
unsigned int sr_bits; /* How many bits we claimed */ unsigned int sr_bits; /* How many bits we claimed */
}; };
static u64 ocfs2_group_from_res(struct ocfs2_suballoc_result *res)
{
if (res->sr_blkno == 0)
return 0;
if (res->sr_bg_blkno)
return res->sr_bg_blkno;
return ocfs2_which_suballoc_group(res->sr_blkno, res->sr_bit_offset);
}
static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); 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, ...@@ -1845,6 +1856,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
int status; int status;
u16 victim, i; u16 victim, i;
u16 bits_left = 0; u16 bits_left = 0;
u64 hint = ac->ac_last_group;
struct ocfs2_chain_list *cl; struct ocfs2_chain_list *cl;
struct ocfs2_dinode *fe; struct ocfs2_dinode *fe;
...@@ -1872,7 +1884,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, ...@@ -1872,7 +1884,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
goto bail; goto bail;
} }
res->sr_bg_blkno = ac->ac_last_group; res->sr_bg_blkno = hint;
if (res->sr_bg_blkno) { if (res->sr_bg_blkno) {
/* Attempt to short-circuit the usual search mechanism /* Attempt to short-circuit the usual search mechanism
* by jumping straight to the most recently used * by jumping straight to the most recently used
...@@ -1896,8 +1908,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, ...@@ -1896,8 +1908,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
res, &bits_left); res, &bits_left);
if (!status) if (!status) {
hint = ocfs2_group_from_res(res);
goto set_hint; goto set_hint;
}
if (status < 0 && status != -ENOSPC) { if (status < 0 && status != -ENOSPC) {
mlog_errno(status); mlog_errno(status);
goto bail; goto bail;
...@@ -1920,8 +1934,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, ...@@ -1920,8 +1934,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
ac->ac_chain = i; ac->ac_chain = i;
status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
res, &bits_left); res, &bits_left);
if (!status) if (!status) {
hint = ocfs2_group_from_res(res);
break; break;
}
if (status < 0 && status != -ENOSPC) { if (status < 0 && status != -ENOSPC) {
mlog_errno(status); mlog_errno(status);
goto bail; goto bail;
...@@ -1936,7 +1952,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, ...@@ -1936,7 +1952,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
if (bits_left < min_bits) if (bits_left < min_bits)
ac->ac_last_group = 0; ac->ac_last_group = 0;
else else
ac->ac_last_group = res->sr_bg_blkno; ac->ac_last_group = hint;
} }
bail: bail:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment