aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/suballoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/suballoc.c')
-rw-r--r--fs/ocfs2/suballoc.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 9c2e669a74fa..7809f41bcbfc 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -54,7 +54,9 @@
54#define OCFS2_MAX_TO_STEAL 1024 54#define OCFS2_MAX_TO_STEAL 1024
55 55
56struct ocfs2_suballoc_result { 56struct ocfs2_suballoc_result {
57 u64 sr_bg_blkno; /* The bg we allocated from */ 57 u64 sr_bg_blkno; /* The bg we allocated from. Set
58 to 0 when a block group is
59 contiguous. */
58 u64 sr_blkno; /* The first allocated block */ 60 u64 sr_blkno; /* The first allocated block */
59 unsigned int sr_bit_offset; /* The bit in the bg */ 61 unsigned int sr_bit_offset; /* The bit in the bg */
60 unsigned int sr_bits; /* How many bits we claimed */ 62 unsigned int sr_bits; /* How many bits we claimed */
@@ -1604,6 +1606,7 @@ static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac,
1604 struct ocfs2_suballoc_result *res) 1606 struct ocfs2_suballoc_result *res)
1605{ 1607{
1606 int i; 1608 int i;
1609 u64 bg_blkno = res->sr_bg_blkno; /* Save off */
1607 struct ocfs2_extent_rec *rec; 1610 struct ocfs2_extent_rec *rec;
1608 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; 1611 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data;
1609 struct ocfs2_chain_list *cl = &di->id2.i_chain; 1612 struct ocfs2_chain_list *cl = &di->id2.i_chain;
@@ -1614,14 +1617,17 @@ static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac,
1614 } 1617 }
1615 1618
1616 res->sr_blkno = res->sr_bg_blkno + res->sr_bit_offset; 1619 res->sr_blkno = res->sr_bg_blkno + res->sr_bit_offset;
1620 res->sr_bg_blkno = 0; /* Clear it for contig block groups */
1617 if (!ocfs2_supports_discontig_bh(OCFS2_SB(ac->ac_inode->i_sb)) || 1621 if (!ocfs2_supports_discontig_bh(OCFS2_SB(ac->ac_inode->i_sb)) ||
1618 !bg->bg_list.l_next_free_rec) 1622 !bg->bg_list.l_next_free_rec)
1619 return; 1623 return;
1620 1624
1621 for (i = 0; i < le16_to_cpu(bg->bg_list.l_next_free_rec); i++) { 1625 for (i = 0; i < le16_to_cpu(bg->bg_list.l_next_free_rec); i++) {
1622 rec = &bg->bg_list.l_recs[i]; 1626 rec = &bg->bg_list.l_recs[i];
1623 if (ocfs2_bg_discontig_fix_by_rec(res, rec, cl)) 1627 if (ocfs2_bg_discontig_fix_by_rec(res, rec, cl)) {
1628 res->sr_bg_blkno = bg_blkno; /* Restore */
1624 break; 1629 break;
1630 }
1625 } 1631 }
1626} 1632}
1627 1633
@@ -1926,6 +1932,7 @@ bail:
1926int ocfs2_claim_metadata(handle_t *handle, 1932int ocfs2_claim_metadata(handle_t *handle,
1927 struct ocfs2_alloc_context *ac, 1933 struct ocfs2_alloc_context *ac,
1928 u32 bits_wanted, 1934 u32 bits_wanted,
1935 u64 *suballoc_loc,
1929 u16 *suballoc_bit_start, 1936 u16 *suballoc_bit_start,
1930 unsigned int *num_bits, 1937 unsigned int *num_bits,
1931 u64 *blkno_start) 1938 u64 *blkno_start)
@@ -1948,6 +1955,7 @@ int ocfs2_claim_metadata(handle_t *handle,
1948 } 1955 }
1949 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); 1956 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
1950 1957
1958 *suballoc_loc = res.sr_bg_blkno;
1951 *suballoc_bit_start = res.sr_bit_offset; 1959 *suballoc_bit_start = res.sr_bit_offset;
1952 *blkno_start = res.sr_blkno; 1960 *blkno_start = res.sr_blkno;
1953 ac->ac_bits_given += res.sr_bits; 1961 ac->ac_bits_given += res.sr_bits;
@@ -1993,11 +2001,12 @@ int ocfs2_claim_new_inode(handle_t *handle,
1993 struct inode *dir, 2001 struct inode *dir,
1994 struct buffer_head *parent_fe_bh, 2002 struct buffer_head *parent_fe_bh,
1995 struct ocfs2_alloc_context *ac, 2003 struct ocfs2_alloc_context *ac,
2004 u64 *suballoc_loc,
1996 u16 *suballoc_bit, 2005 u16 *suballoc_bit,
1997 u64 *fe_blkno) 2006 u64 *fe_blkno)
1998{ 2007{
1999 int status; 2008 int status;
2000 struct ocfs2_suballoc_result res = { .sr_blkno = 0, }; 2009 struct ocfs2_suballoc_result res;
2001 2010
2002 mlog_entry_void(); 2011 mlog_entry_void();
2003 2012
@@ -2021,6 +2030,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
2021 2030
2022 BUG_ON(res.sr_bits != 1); 2031 BUG_ON(res.sr_bits != 1);
2023 2032
2033 *suballoc_loc = res.sr_bg_blkno;
2024 *suballoc_bit = res.sr_bit_offset; 2034 *suballoc_bit = res.sr_bit_offset;
2025 *fe_blkno = res.sr_blkno; 2035 *fe_blkno = res.sr_blkno;
2026 ac->ac_bits_given++; 2036 ac->ac_bits_given++;