aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2010-08-26 16:06:50 -0400
committerTao Ma <tao.ma@oracle.com>2010-09-08 02:25:56 -0400
commitb2b6ebf5f740e015b2155343958f067e594323ea (patch)
treec235f91c504cb95ce0b7b4a5c3cfed1df185eb88 /fs
parent889f004a8c83d515f275078687f859bc0d5ede9d (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/suballoc.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 8a009ee1f7f..b93d7e72175 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -62,6 +62,17 @@ struct ocfs2_suballoc_result {
62 unsigned int sr_bits; /* How many bits we claimed */ 62 unsigned int sr_bits; /* How many bits we claimed */
63}; 63};
64 64
65static 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
65static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); 76static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
66static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); 77static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
67static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); 78static 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 int status; 1856 int status;
1846 u16 victim, i; 1857 u16 victim, i;
1847 u16 bits_left = 0; 1858 u16 bits_left = 0;
1859 u64 hint = ac->ac_last_group;
1848 struct ocfs2_chain_list *cl; 1860 struct ocfs2_chain_list *cl;
1849 struct ocfs2_dinode *fe; 1861 struct ocfs2_dinode *fe;
1850 1862
@@ -1872,7 +1884,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
1872 goto bail; 1884 goto bail;
1873 } 1885 }
1874 1886
1875 res->sr_bg_blkno = ac->ac_last_group; 1887 res->sr_bg_blkno = hint;
1876 if (res->sr_bg_blkno) { 1888 if (res->sr_bg_blkno) {
1877 /* Attempt to short-circuit the usual search mechanism 1889 /* Attempt to short-circuit the usual search mechanism
1878 * by jumping straight to the most recently used 1890 * by jumping straight to the most recently used
@@ -1896,8 +1908,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
1896 1908
1897 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, 1909 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
1898 res, &bits_left); 1910 res, &bits_left);
1899 if (!status) 1911 if (!status) {
1912 hint = ocfs2_group_from_res(res);
1900 goto set_hint; 1913 goto set_hint;
1914 }
1901 if (status < 0 && status != -ENOSPC) { 1915 if (status < 0 && status != -ENOSPC) {
1902 mlog_errno(status); 1916 mlog_errno(status);
1903 goto bail; 1917 goto bail;
@@ -1920,8 +1934,10 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
1920 ac->ac_chain = i; 1934 ac->ac_chain = i;
1921 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, 1935 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
1922 res, &bits_left); 1936 res, &bits_left);
1923 if (!status) 1937 if (!status) {
1938 hint = ocfs2_group_from_res(res);
1924 break; 1939 break;
1940 }
1925 if (status < 0 && status != -ENOSPC) { 1941 if (status < 0 && status != -ENOSPC) {
1926 mlog_errno(status); 1942 mlog_errno(status);
1927 goto bail; 1943 goto bail;
@@ -1936,7 +1952,7 @@ set_hint:
1936 if (bits_left < min_bits) 1952 if (bits_left < min_bits)
1937 ac->ac_last_group = 0; 1953 ac->ac_last_group = 0;
1938 else 1954 else
1939 ac->ac_last_group = res->sr_bg_blkno; 1955 ac->ac_last_group = hint;
1940 } 1956 }
1941 1957
1942bail: 1958bail: