diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-08-20 19:57:27 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-10-13 19:57:04 -0400 |
commit | ea5efa151265a743f48e3d371992a0100d73a0eb (patch) | |
tree | 5e3688b0882271210b524564f5b6b42e2813f32c /fs/ocfs2 | |
parent | dc0ce61af418305afa7e0d05d86ab334e0daabf7 (diff) |
ocfs2: Make 'private' into 'object' on ocfs2_extent_tree.
The 'private' pointer was a way to store off xattr values, which don't
live at a set place in the bh. But the concept of "the object
containing the extent tree" is much more generic. For an inode it's the
struct ocfs2_dinode, for an xattr value its the value. Let's save off
the 'object' at all times. If NULL is passed to
ocfs2_get_extent_tree(), 'object' is set to bh->b_data;
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/alloc.c | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index c200d3321689..4cefcb6a47a5 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -79,15 +79,14 @@ struct ocfs2_extent_tree { | |||
79 | struct ocfs2_extent_tree_operations *et_ops; | 79 | struct ocfs2_extent_tree_operations *et_ops; |
80 | struct buffer_head *et_root_bh; | 80 | struct buffer_head *et_root_bh; |
81 | struct ocfs2_extent_list *et_root_el; | 81 | struct ocfs2_extent_list *et_root_el; |
82 | void *et_private; | 82 | void *et_object; |
83 | unsigned int et_max_leaf_clusters; | 83 | unsigned int et_max_leaf_clusters; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | 86 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, |
87 | u64 blkno) | 87 | u64 blkno) |
88 | { | 88 | { |
89 | struct ocfs2_dinode *di = | 89 | struct ocfs2_dinode *di = et->et_object; |
90 | (struct ocfs2_dinode *)et->et_root_bh->b_data; | ||
91 | 90 | ||
92 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); | 91 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); |
93 | di->i_last_eb_blk = cpu_to_le64(blkno); | 92 | di->i_last_eb_blk = cpu_to_le64(blkno); |
@@ -95,8 +94,7 @@ static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | |||
95 | 94 | ||
96 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et) | 95 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et) |
97 | { | 96 | { |
98 | struct ocfs2_dinode *di = | 97 | struct ocfs2_dinode *di = et->et_object; |
99 | (struct ocfs2_dinode *)et->et_root_bh->b_data; | ||
100 | 98 | ||
101 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); | 99 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); |
102 | return le64_to_cpu(di->i_last_eb_blk); | 100 | return le64_to_cpu(di->i_last_eb_blk); |
@@ -106,8 +104,7 @@ static void ocfs2_dinode_update_clusters(struct inode *inode, | |||
106 | struct ocfs2_extent_tree *et, | 104 | struct ocfs2_extent_tree *et, |
107 | u32 clusters) | 105 | u32 clusters) |
108 | { | 106 | { |
109 | struct ocfs2_dinode *di = | 107 | struct ocfs2_dinode *di = et->et_object; |
110 | (struct ocfs2_dinode *)et->et_root_bh->b_data; | ||
111 | 108 | ||
112 | le32_add_cpu(&di->i_clusters, clusters); | 109 | le32_add_cpu(&di->i_clusters, clusters); |
113 | spin_lock(&OCFS2_I(inode)->ip_lock); | 110 | spin_lock(&OCFS2_I(inode)->ip_lock); |
@@ -123,7 +120,7 @@ static int ocfs2_dinode_sanity_check(struct inode *inode, | |||
123 | 120 | ||
124 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); | 121 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); |
125 | 122 | ||
126 | di = (struct ocfs2_dinode *)et->et_root_bh->b_data; | 123 | di = et->et_object; |
127 | if (!OCFS2_IS_VALID_DINODE(di)) { | 124 | if (!OCFS2_IS_VALID_DINODE(di)) { |
128 | ret = -EIO; | 125 | ret = -EIO; |
129 | ocfs2_error(inode->i_sb, | 126 | ocfs2_error(inode->i_sb, |
@@ -145,7 +142,7 @@ static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | |||
145 | u64 blkno) | 142 | u64 blkno) |
146 | { | 143 | { |
147 | struct ocfs2_xattr_value_root *xv = | 144 | struct ocfs2_xattr_value_root *xv = |
148 | (struct ocfs2_xattr_value_root *)et->et_private; | 145 | (struct ocfs2_xattr_value_root *)et->et_object; |
149 | 146 | ||
150 | xv->xr_last_eb_blk = cpu_to_le64(blkno); | 147 | xv->xr_last_eb_blk = cpu_to_le64(blkno); |
151 | } | 148 | } |
@@ -153,7 +150,7 @@ static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | |||
153 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) | 150 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) |
154 | { | 151 | { |
155 | struct ocfs2_xattr_value_root *xv = | 152 | struct ocfs2_xattr_value_root *xv = |
156 | (struct ocfs2_xattr_value_root *) et->et_private; | 153 | (struct ocfs2_xattr_value_root *) et->et_object; |
157 | 154 | ||
158 | return le64_to_cpu(xv->xr_last_eb_blk); | 155 | return le64_to_cpu(xv->xr_last_eb_blk); |
159 | } | 156 | } |
@@ -163,7 +160,7 @@ static void ocfs2_xattr_value_update_clusters(struct inode *inode, | |||
163 | u32 clusters) | 160 | u32 clusters) |
164 | { | 161 | { |
165 | struct ocfs2_xattr_value_root *xv = | 162 | struct ocfs2_xattr_value_root *xv = |
166 | (struct ocfs2_xattr_value_root *)et->et_private; | 163 | (struct ocfs2_xattr_value_root *)et->et_object; |
167 | 164 | ||
168 | le32_add_cpu(&xv->xr_clusters, clusters); | 165 | le32_add_cpu(&xv->xr_clusters, clusters); |
169 | } | 166 | } |
@@ -184,8 +181,7 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_et_ops = { | |||
184 | static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, | 181 | static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, |
185 | u64 blkno) | 182 | u64 blkno) |
186 | { | 183 | { |
187 | struct ocfs2_xattr_block *xb = | 184 | struct ocfs2_xattr_block *xb = et->et_object; |
188 | (struct ocfs2_xattr_block *) et->et_root_bh->b_data; | ||
189 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; | 185 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; |
190 | 186 | ||
191 | xt->xt_last_eb_blk = cpu_to_le64(blkno); | 187 | xt->xt_last_eb_blk = cpu_to_le64(blkno); |
@@ -193,8 +189,7 @@ static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, | |||
193 | 189 | ||
194 | static u64 ocfs2_xattr_tree_get_last_eb_blk(struct ocfs2_extent_tree *et) | 190 | static u64 ocfs2_xattr_tree_get_last_eb_blk(struct ocfs2_extent_tree *et) |
195 | { | 191 | { |
196 | struct ocfs2_xattr_block *xb = | 192 | struct ocfs2_xattr_block *xb = et->et_object; |
197 | (struct ocfs2_xattr_block *) et->et_root_bh->b_data; | ||
198 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; | 193 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; |
199 | 194 | ||
200 | return le64_to_cpu(xt->xt_last_eb_blk); | 195 | return le64_to_cpu(xt->xt_last_eb_blk); |
@@ -204,8 +199,7 @@ static void ocfs2_xattr_tree_update_clusters(struct inode *inode, | |||
204 | struct ocfs2_extent_tree *et, | 199 | struct ocfs2_extent_tree *et, |
205 | u32 clusters) | 200 | u32 clusters) |
206 | { | 201 | { |
207 | struct ocfs2_xattr_block *xb = | 202 | struct ocfs2_xattr_block *xb = et->et_object; |
208 | (struct ocfs2_xattr_block *)et->et_root_bh->b_data; | ||
209 | 203 | ||
210 | le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, clusters); | 204 | le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, clusters); |
211 | } | 205 | } |
@@ -227,26 +221,28 @@ static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et, | |||
227 | struct inode *inode, | 221 | struct inode *inode, |
228 | struct buffer_head *bh, | 222 | struct buffer_head *bh, |
229 | enum ocfs2_extent_tree_type et_type, | 223 | enum ocfs2_extent_tree_type et_type, |
230 | void *private) | 224 | void *obj) |
231 | { | 225 | { |
232 | et->et_type = et_type; | 226 | et->et_type = et_type; |
233 | get_bh(bh); | 227 | get_bh(bh); |
234 | et->et_root_bh = bh; | 228 | et->et_root_bh = bh; |
235 | et->et_private = private; | ||
236 | et->et_max_leaf_clusters = 0; | 229 | et->et_max_leaf_clusters = 0; |
230 | if (!obj) | ||
231 | obj = (void *)bh->b_data; | ||
232 | et->et_object = obj; | ||
237 | 233 | ||
238 | if (et_type == OCFS2_DINODE_EXTENT) { | 234 | if (et_type == OCFS2_DINODE_EXTENT) { |
239 | et->et_root_el = | 235 | et->et_root_el = |
240 | &((struct ocfs2_dinode *)bh->b_data)->id2.i_list; | 236 | &((struct ocfs2_dinode *)obj)->id2.i_list; |
241 | et->et_ops = &ocfs2_dinode_et_ops; | 237 | et->et_ops = &ocfs2_dinode_et_ops; |
242 | } else if (et_type == OCFS2_XATTR_VALUE_EXTENT) { | 238 | } else if (et_type == OCFS2_XATTR_VALUE_EXTENT) { |
243 | struct ocfs2_xattr_value_root *xv = | 239 | struct ocfs2_xattr_value_root *xv = |
244 | (struct ocfs2_xattr_value_root *) private; | 240 | (struct ocfs2_xattr_value_root *)obj; |
245 | et->et_root_el = &xv->xr_list; | 241 | et->et_root_el = &xv->xr_list; |
246 | et->et_ops = &ocfs2_xattr_et_ops; | 242 | et->et_ops = &ocfs2_xattr_et_ops; |
247 | } else if (et_type == OCFS2_XATTR_TREE_EXTENT) { | 243 | } else if (et_type == OCFS2_XATTR_TREE_EXTENT) { |
248 | struct ocfs2_xattr_block *xb = | 244 | struct ocfs2_xattr_block *xb = |
249 | (struct ocfs2_xattr_block *)bh->b_data; | 245 | (struct ocfs2_xattr_block *)obj; |
250 | et->et_root_el = &xb->xb_attrs.xb_root.xt_list; | 246 | et->et_root_el = &xb->xb_attrs.xb_root.xt_list; |
251 | et->et_ops = &ocfs2_xattr_tree_et_ops; | 247 | et->et_ops = &ocfs2_xattr_tree_et_ops; |
252 | et->et_max_leaf_clusters = ocfs2_clusters_for_bytes(inode->i_sb, | 248 | et->et_max_leaf_clusters = ocfs2_clusters_for_bytes(inode->i_sb, |
@@ -593,7 +589,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |||
593 | struct inode *inode, | 589 | struct inode *inode, |
594 | struct buffer_head *root_bh, | 590 | struct buffer_head *root_bh, |
595 | enum ocfs2_extent_tree_type type, | 591 | enum ocfs2_extent_tree_type type, |
596 | void *private) | 592 | void *obj) |
597 | { | 593 | { |
598 | int retval; | 594 | int retval; |
599 | struct ocfs2_extent_list *el = NULL; | 595 | struct ocfs2_extent_list *el = NULL; |
@@ -617,7 +613,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |||
617 | el = &fe->id2.i_list; | 613 | el = &fe->id2.i_list; |
618 | } else if (type == OCFS2_XATTR_VALUE_EXTENT) { | 614 | } else if (type == OCFS2_XATTR_VALUE_EXTENT) { |
619 | struct ocfs2_xattr_value_root *xv = | 615 | struct ocfs2_xattr_value_root *xv = |
620 | (struct ocfs2_xattr_value_root *) private; | 616 | (struct ocfs2_xattr_value_root *) obj; |
621 | 617 | ||
622 | last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk); | 618 | last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk); |
623 | el = &xv->xr_list; | 619 | el = &xv->xr_list; |
@@ -4441,13 +4437,13 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb, | |||
4441 | u32 new_clusters, | 4437 | u32 new_clusters, |
4442 | u8 flags, | 4438 | u8 flags, |
4443 | struct ocfs2_alloc_context *meta_ac, | 4439 | struct ocfs2_alloc_context *meta_ac, |
4444 | void *private) | 4440 | void *obj) |
4445 | { | 4441 | { |
4446 | int status; | 4442 | int status; |
4447 | struct ocfs2_extent_tree et; | 4443 | struct ocfs2_extent_tree et; |
4448 | 4444 | ||
4449 | ocfs2_get_extent_tree(&et, inode, root_bh, | 4445 | ocfs2_get_extent_tree(&et, inode, root_bh, |
4450 | OCFS2_XATTR_VALUE_EXTENT, private); | 4446 | OCFS2_XATTR_VALUE_EXTENT, obj); |
4451 | status = ocfs2_insert_extent(osb, handle, inode, root_bh, | 4447 | status = ocfs2_insert_extent(osb, handle, inode, root_bh, |
4452 | cpos, start_blk, new_clusters, | 4448 | cpos, start_blk, new_clusters, |
4453 | flags, meta_ac, &et); | 4449 | flags, meta_ac, &et); |
@@ -4498,7 +4494,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |||
4498 | struct ocfs2_alloc_context *meta_ac, | 4494 | struct ocfs2_alloc_context *meta_ac, |
4499 | enum ocfs2_alloc_restarted *reason_ret, | 4495 | enum ocfs2_alloc_restarted *reason_ret, |
4500 | enum ocfs2_extent_tree_type type, | 4496 | enum ocfs2_extent_tree_type type, |
4501 | void *private) | 4497 | void *obj) |
4502 | { | 4498 | { |
4503 | int status = 0; | 4499 | int status = 0; |
4504 | int free_extents; | 4500 | int free_extents; |
@@ -4513,7 +4509,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |||
4513 | flags = OCFS2_EXT_UNWRITTEN; | 4509 | flags = OCFS2_EXT_UNWRITTEN; |
4514 | 4510 | ||
4515 | free_extents = ocfs2_num_free_extents(osb, inode, root_bh, type, | 4511 | free_extents = ocfs2_num_free_extents(osb, inode, root_bh, type, |
4516 | private); | 4512 | obj); |
4517 | if (free_extents < 0) { | 4513 | if (free_extents < 0) { |
4518 | status = free_extents; | 4514 | status = free_extents; |
4519 | mlog_errno(status); | 4515 | mlog_errno(status); |
@@ -4575,7 +4571,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |||
4575 | inode, root_bh, | 4571 | inode, root_bh, |
4576 | *logical_offset, | 4572 | *logical_offset, |
4577 | block, num_bits, flags, | 4573 | block, num_bits, flags, |
4578 | meta_ac, private); | 4574 | meta_ac, obj); |
4579 | if (status < 0) { | 4575 | if (status < 0) { |
4580 | mlog_errno(status); | 4576 | mlog_errno(status); |
4581 | goto leave; | 4577 | goto leave; |
@@ -4857,7 +4853,7 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, | |||
4857 | struct ocfs2_alloc_context *meta_ac, | 4853 | struct ocfs2_alloc_context *meta_ac, |
4858 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 4854 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
4859 | enum ocfs2_extent_tree_type et_type, | 4855 | enum ocfs2_extent_tree_type et_type, |
4860 | void *private) | 4856 | void *obj) |
4861 | { | 4857 | { |
4862 | int ret, index; | 4858 | int ret, index; |
4863 | u64 start_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys); | 4859 | u64 start_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys); |
@@ -4869,7 +4865,7 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, | |||
4869 | mlog(0, "Inode %lu cpos %u, len %u, phys %u (%llu)\n", | 4865 | mlog(0, "Inode %lu cpos %u, len %u, phys %u (%llu)\n", |
4870 | inode->i_ino, cpos, len, phys, (unsigned long long)start_blkno); | 4866 | inode->i_ino, cpos, len, phys, (unsigned long long)start_blkno); |
4871 | 4867 | ||
4872 | ocfs2_get_extent_tree(&et, inode, root_bh, et_type, private); | 4868 | ocfs2_get_extent_tree(&et, inode, root_bh, et_type, obj); |
4873 | 4869 | ||
4874 | if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { | 4870 | if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { |
4875 | ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " | 4871 | ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " |
@@ -5161,7 +5157,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, | |||
5161 | struct ocfs2_alloc_context *meta_ac, | 5157 | struct ocfs2_alloc_context *meta_ac, |
5162 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 5158 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
5163 | enum ocfs2_extent_tree_type et_type, | 5159 | enum ocfs2_extent_tree_type et_type, |
5164 | void *private) | 5160 | void *obj) |
5165 | { | 5161 | { |
5166 | int ret, index; | 5162 | int ret, index; |
5167 | u32 rec_range, trunc_range; | 5163 | u32 rec_range, trunc_range; |
@@ -5170,7 +5166,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, | |||
5170 | struct ocfs2_path *path = NULL; | 5166 | struct ocfs2_path *path = NULL; |
5171 | struct ocfs2_extent_tree et; | 5167 | struct ocfs2_extent_tree et; |
5172 | 5168 | ||
5173 | ocfs2_get_extent_tree(&et, inode, root_bh, et_type, private); | 5169 | ocfs2_get_extent_tree(&et, inode, root_bh, et_type, obj); |
5174 | 5170 | ||
5175 | ocfs2_extent_map_trunc(inode, 0); | 5171 | ocfs2_extent_map_trunc(inode, 0); |
5176 | 5172 | ||