aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/suballoc.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-08-20 22:36:33 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 19:57:05 -0400
commitf99b9b7ccf6a691f653cec45f36bfdd1e94769c7 (patch)
tree1c6ff6ea1fa1bb86b70f1fd78dd725b559c729e4 /fs/ocfs2/suballoc.c
parent1e61ee79e2a96f62c007486677319814ce621c3c (diff)
ocfs2: Make ocfs2_extent_tree the first-class representation of a tree.
We now have three different kinds of extent trees in ocfs2: inode data (dinode), extended attributes (xattr_tree), and extended attribute values (xattr_value). There is a nice abstraction for them, ocfs2_extent_tree, but it is hidden in alloc.c. All the calling functions have to pick amongst a varied API and pass in type bits and often extraneous pointers. A better way is to make ocfs2_extent_tree a first-class object. Everyone converts their object to an ocfs2_extent_tree() via the ocfs2_get_*_extent_tree() calls, then uses the ocfs2_extent_tree for all tree calls to alloc.c. This simplifies a lot of callers, making for readability. It also provides an easy way to add additional extent tree types, as they only need to be defined in alloc.c with a ocfs2_get_<new>_extent_tree() function. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/suballoc.c')
-rw-r--r--fs/ocfs2/suballoc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index f1871ca83815..8d3947e94a2e 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -1914,12 +1914,11 @@ static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe)
1914 * File systems which don't support holes call this from 1914 * File systems which don't support holes call this from
1915 * ocfs2_extend_allocation(). 1915 * ocfs2_extend_allocation().
1916 */ 1916 */
1917int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *root_bh, 1917int ocfs2_lock_allocators(struct inode *inode,
1918 struct ocfs2_extent_list *root_el, 1918 struct ocfs2_extent_tree *et,
1919 u32 clusters_to_add, u32 extents_to_split, 1919 u32 clusters_to_add, u32 extents_to_split,
1920 struct ocfs2_alloc_context **data_ac, 1920 struct ocfs2_alloc_context **data_ac,
1921 struct ocfs2_alloc_context **meta_ac, 1921 struct ocfs2_alloc_context **meta_ac)
1922 enum ocfs2_extent_tree_type type, void *private)
1923{ 1922{
1924 int ret = 0, num_free_extents; 1923 int ret = 0, num_free_extents;
1925 unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split; 1924 unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split;
@@ -1931,8 +1930,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *root_bh,
1931 1930
1932 BUG_ON(clusters_to_add != 0 && data_ac == NULL); 1931 BUG_ON(clusters_to_add != 0 && data_ac == NULL);
1933 1932
1934 num_free_extents = ocfs2_num_free_extents(osb, inode, root_bh, 1933 num_free_extents = ocfs2_num_free_extents(osb, inode, et);
1935 type, private);
1936 if (num_free_extents < 0) { 1934 if (num_free_extents < 0) {
1937 ret = num_free_extents; 1935 ret = num_free_extents;
1938 mlog_errno(ret); 1936 mlog_errno(ret);
@@ -1954,7 +1952,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *root_bh,
1954 */ 1952 */
1955 if (!num_free_extents || 1953 if (!num_free_extents ||
1956 (ocfs2_sparse_alloc(osb) && num_free_extents < max_recs_needed)) { 1954 (ocfs2_sparse_alloc(osb) && num_free_extents < max_recs_needed)) {
1957 ret = ocfs2_reserve_new_metadata(osb, root_el, meta_ac); 1955 ret = ocfs2_reserve_new_metadata(osb, et->et_root_el, meta_ac);
1958 if (ret < 0) { 1956 if (ret < 0) {
1959 if (ret != -ENOSPC) 1957 if (ret != -ENOSPC)
1960 mlog_errno(ret); 1958 mlog_errno(ret);