diff options
-rw-r--r-- | fs/ocfs2/suballoc.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 8a009ee1f7fd..b93d7e72175a 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 | ||
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 | |||
65 | static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); | 76 | static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); |
66 | static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); | 77 | static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); |
67 | static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); | 78 | 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 | 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 | ||
1942 | bail: | 1958 | bail: |