diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-02-12 22:32:43 -0500 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-04 19:07:57 -0400 |
commit | 6136ca5f5f9fd38da399e9ff9380f537c1b3b901 (patch) | |
tree | e2927c3b6084a7ea16f872a61011cbcf505f570c /fs/ocfs2/alloc.c | |
parent | 7dc028056750328e74ca807041c822068384fe16 (diff) |
ocfs2: Drop struct inode from ocfs2_extent_tree_operations.
We can get to the inode from the caching information. Other parent
types don't need it.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 93 |
1 files changed, 38 insertions, 55 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index c3edd02c74e8..072f7fe54073 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -79,18 +79,16 @@ struct ocfs2_extent_tree_operations { | |||
79 | * that value. new_clusters is the delta, and must be | 79 | * that value. new_clusters is the delta, and must be |
80 | * added to the total. Required. | 80 | * added to the total. Required. |
81 | */ | 81 | */ |
82 | void (*eo_update_clusters)(struct inode *inode, | 82 | void (*eo_update_clusters)(struct ocfs2_extent_tree *et, |
83 | struct ocfs2_extent_tree *et, | ||
84 | u32 new_clusters); | 83 | u32 new_clusters); |
85 | 84 | ||
86 | /* | 85 | /* |
87 | * If ->eo_insert_check() exists, it is called before rec is | 86 | * If ->eo_insert_check() exists, it is called before rec is |
88 | * inserted into the extent tree. It is optional. | 87 | * inserted into the extent tree. It is optional. |
89 | */ | 88 | */ |
90 | int (*eo_insert_check)(struct inode *inode, | 89 | int (*eo_insert_check)(struct ocfs2_extent_tree *et, |
91 | struct ocfs2_extent_tree *et, | ||
92 | struct ocfs2_extent_rec *rec); | 90 | struct ocfs2_extent_rec *rec); |
93 | int (*eo_sanity_check)(struct inode *inode, struct ocfs2_extent_tree *et); | 91 | int (*eo_sanity_check)(struct ocfs2_extent_tree *et); |
94 | 92 | ||
95 | /* | 93 | /* |
96 | * -------------------------------------------------------------- | 94 | * -------------------------------------------------------------- |
@@ -109,8 +107,7 @@ struct ocfs2_extent_tree_operations { | |||
109 | * it exists. If it does not, et->et_max_leaf_clusters is set | 107 | * it exists. If it does not, et->et_max_leaf_clusters is set |
110 | * to 0 (unlimited). Optional. | 108 | * to 0 (unlimited). Optional. |
111 | */ | 109 | */ |
112 | void (*eo_fill_max_leaf_clusters)(struct inode *inode, | 110 | void (*eo_fill_max_leaf_clusters)(struct ocfs2_extent_tree *et); |
113 | struct ocfs2_extent_tree *et); | ||
114 | }; | 111 | }; |
115 | 112 | ||
116 | 113 | ||
@@ -121,14 +118,11 @@ struct ocfs2_extent_tree_operations { | |||
121 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et); | 118 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et); |
122 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | 119 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, |
123 | u64 blkno); | 120 | u64 blkno); |
124 | static void ocfs2_dinode_update_clusters(struct inode *inode, | 121 | static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et, |
125 | struct ocfs2_extent_tree *et, | ||
126 | u32 clusters); | 122 | u32 clusters); |
127 | static int ocfs2_dinode_insert_check(struct inode *inode, | 123 | static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et, |
128 | struct ocfs2_extent_tree *et, | ||
129 | struct ocfs2_extent_rec *rec); | 124 | struct ocfs2_extent_rec *rec); |
130 | static int ocfs2_dinode_sanity_check(struct inode *inode, | 125 | static int ocfs2_dinode_sanity_check(struct ocfs2_extent_tree *et); |
131 | struct ocfs2_extent_tree *et); | ||
132 | static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et); | 126 | static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et); |
133 | static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = { | 127 | static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = { |
134 | .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, | 128 | .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, |
@@ -156,40 +150,37 @@ static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et) | |||
156 | return le64_to_cpu(di->i_last_eb_blk); | 150 | return le64_to_cpu(di->i_last_eb_blk); |
157 | } | 151 | } |
158 | 152 | ||
159 | static void ocfs2_dinode_update_clusters(struct inode *inode, | 153 | static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et, |
160 | struct ocfs2_extent_tree *et, | ||
161 | u32 clusters) | 154 | u32 clusters) |
162 | { | 155 | { |
156 | struct ocfs2_inode_info *oi = cache_info_to_inode(et->et_ci); | ||
163 | struct ocfs2_dinode *di = et->et_object; | 157 | struct ocfs2_dinode *di = et->et_object; |
164 | 158 | ||
165 | le32_add_cpu(&di->i_clusters, clusters); | 159 | le32_add_cpu(&di->i_clusters, clusters); |
166 | spin_lock(&OCFS2_I(inode)->ip_lock); | 160 | spin_lock(&oi->ip_lock); |
167 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(di->i_clusters); | 161 | oi->ip_clusters = le32_to_cpu(di->i_clusters); |
168 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 162 | spin_unlock(&oi->ip_lock); |
169 | } | 163 | } |
170 | 164 | ||
171 | static int ocfs2_dinode_insert_check(struct inode *inode, | 165 | static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et, |
172 | struct ocfs2_extent_tree *et, | ||
173 | struct ocfs2_extent_rec *rec) | 166 | struct ocfs2_extent_rec *rec) |
174 | { | 167 | { |
175 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 168 | struct ocfs2_inode_info *oi = cache_info_to_inode(et->et_ci); |
169 | struct ocfs2_super *osb = OCFS2_SB(oi->vfs_inode.i_sb); | ||
176 | 170 | ||
177 | BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL); | 171 | BUG_ON(oi->ip_dyn_features & OCFS2_INLINE_DATA_FL); |
178 | mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) && | 172 | mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) && |
179 | (OCFS2_I(inode)->ip_clusters != | 173 | (oi->ip_clusters != le32_to_cpu(rec->e_cpos)), |
180 | le32_to_cpu(rec->e_cpos)), | ||
181 | "Device %s, asking for sparse allocation: inode %llu, " | 174 | "Device %s, asking for sparse allocation: inode %llu, " |
182 | "cpos %u, clusters %u\n", | 175 | "cpos %u, clusters %u\n", |
183 | osb->dev_str, | 176 | osb->dev_str, |
184 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 177 | (unsigned long long)oi->ip_blkno, |
185 | rec->e_cpos, | 178 | rec->e_cpos, oi->ip_clusters); |
186 | OCFS2_I(inode)->ip_clusters); | ||
187 | 179 | ||
188 | return 0; | 180 | return 0; |
189 | } | 181 | } |
190 | 182 | ||
191 | static int ocfs2_dinode_sanity_check(struct inode *inode, | 183 | static int ocfs2_dinode_sanity_check(struct ocfs2_extent_tree *et) |
192 | struct ocfs2_extent_tree *et) | ||
193 | { | 184 | { |
194 | struct ocfs2_dinode *di = et->et_object; | 185 | struct ocfs2_dinode *di = et->et_object; |
195 | 186 | ||
@@ -229,8 +220,7 @@ static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) | |||
229 | return le64_to_cpu(vb->vb_xv->xr_last_eb_blk); | 220 | return le64_to_cpu(vb->vb_xv->xr_last_eb_blk); |
230 | } | 221 | } |
231 | 222 | ||
232 | static void ocfs2_xattr_value_update_clusters(struct inode *inode, | 223 | static void ocfs2_xattr_value_update_clusters(struct ocfs2_extent_tree *et, |
233 | struct ocfs2_extent_tree *et, | ||
234 | u32 clusters) | 224 | u32 clusters) |
235 | { | 225 | { |
236 | struct ocfs2_xattr_value_buf *vb = et->et_object; | 226 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
@@ -252,12 +242,11 @@ static void ocfs2_xattr_tree_fill_root_el(struct ocfs2_extent_tree *et) | |||
252 | et->et_root_el = &xb->xb_attrs.xb_root.xt_list; | 242 | et->et_root_el = &xb->xb_attrs.xb_root.xt_list; |
253 | } | 243 | } |
254 | 244 | ||
255 | static void ocfs2_xattr_tree_fill_max_leaf_clusters(struct inode *inode, | 245 | static void ocfs2_xattr_tree_fill_max_leaf_clusters(struct ocfs2_extent_tree *et) |
256 | struct ocfs2_extent_tree *et) | ||
257 | { | 246 | { |
247 | struct super_block *sb = ocfs2_metadata_cache_get_super(et->et_ci); | ||
258 | et->et_max_leaf_clusters = | 248 | et->et_max_leaf_clusters = |
259 | ocfs2_clusters_for_bytes(inode->i_sb, | 249 | ocfs2_clusters_for_bytes(sb, OCFS2_MAX_XATTR_TREE_LEAF_SIZE); |
260 | OCFS2_MAX_XATTR_TREE_LEAF_SIZE); | ||
261 | } | 250 | } |
262 | 251 | ||
263 | static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, | 252 | static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, |
@@ -277,8 +266,7 @@ static u64 ocfs2_xattr_tree_get_last_eb_blk(struct ocfs2_extent_tree *et) | |||
277 | return le64_to_cpu(xt->xt_last_eb_blk); | 266 | return le64_to_cpu(xt->xt_last_eb_blk); |
278 | } | 267 | } |
279 | 268 | ||
280 | static void ocfs2_xattr_tree_update_clusters(struct inode *inode, | 269 | static void ocfs2_xattr_tree_update_clusters(struct ocfs2_extent_tree *et, |
281 | struct ocfs2_extent_tree *et, | ||
282 | u32 clusters) | 270 | u32 clusters) |
283 | { | 271 | { |
284 | struct ocfs2_xattr_block *xb = et->et_object; | 272 | struct ocfs2_xattr_block *xb = et->et_object; |
@@ -309,8 +297,7 @@ static u64 ocfs2_dx_root_get_last_eb_blk(struct ocfs2_extent_tree *et) | |||
309 | return le64_to_cpu(dx_root->dr_last_eb_blk); | 297 | return le64_to_cpu(dx_root->dr_last_eb_blk); |
310 | } | 298 | } |
311 | 299 | ||
312 | static void ocfs2_dx_root_update_clusters(struct inode *inode, | 300 | static void ocfs2_dx_root_update_clusters(struct ocfs2_extent_tree *et, |
313 | struct ocfs2_extent_tree *et, | ||
314 | u32 clusters) | 301 | u32 clusters) |
315 | { | 302 | { |
316 | struct ocfs2_dx_root_block *dx_root = et->et_object; | 303 | struct ocfs2_dx_root_block *dx_root = et->et_object; |
@@ -318,8 +305,7 @@ static void ocfs2_dx_root_update_clusters(struct inode *inode, | |||
318 | le32_add_cpu(&dx_root->dr_clusters, clusters); | 305 | le32_add_cpu(&dx_root->dr_clusters, clusters); |
319 | } | 306 | } |
320 | 307 | ||
321 | static int ocfs2_dx_root_sanity_check(struct inode *inode, | 308 | static int ocfs2_dx_root_sanity_check(struct ocfs2_extent_tree *et) |
322 | struct ocfs2_extent_tree *et) | ||
323 | { | 309 | { |
324 | struct ocfs2_dx_root_block *dx_root = et->et_object; | 310 | struct ocfs2_dx_root_block *dx_root = et->et_object; |
325 | 311 | ||
@@ -362,7 +348,7 @@ static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, | |||
362 | if (!et->et_ops->eo_fill_max_leaf_clusters) | 348 | if (!et->et_ops->eo_fill_max_leaf_clusters) |
363 | et->et_max_leaf_clusters = 0; | 349 | et->et_max_leaf_clusters = 0; |
364 | else | 350 | else |
365 | et->et_ops->eo_fill_max_leaf_clusters(inode, et); | 351 | et->et_ops->eo_fill_max_leaf_clusters(et); |
366 | } | 352 | } |
367 | 353 | ||
368 | void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, | 354 | void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, |
@@ -408,11 +394,10 @@ static inline u64 ocfs2_et_get_last_eb_blk(struct ocfs2_extent_tree *et) | |||
408 | return et->et_ops->eo_get_last_eb_blk(et); | 394 | return et->et_ops->eo_get_last_eb_blk(et); |
409 | } | 395 | } |
410 | 396 | ||
411 | static inline void ocfs2_et_update_clusters(struct inode *inode, | 397 | static inline void ocfs2_et_update_clusters(struct ocfs2_extent_tree *et, |
412 | struct ocfs2_extent_tree *et, | ||
413 | u32 clusters) | 398 | u32 clusters) |
414 | { | 399 | { |
415 | et->et_ops->eo_update_clusters(inode, et, clusters); | 400 | et->et_ops->eo_update_clusters(et, clusters); |
416 | } | 401 | } |
417 | 402 | ||
418 | static inline int ocfs2_et_root_journal_access(handle_t *handle, | 403 | static inline int ocfs2_et_root_journal_access(handle_t *handle, |
@@ -423,24 +408,22 @@ static inline int ocfs2_et_root_journal_access(handle_t *handle, | |||
423 | type); | 408 | type); |
424 | } | 409 | } |
425 | 410 | ||
426 | static inline int ocfs2_et_insert_check(struct inode *inode, | 411 | static inline int ocfs2_et_insert_check(struct ocfs2_extent_tree *et, |
427 | struct ocfs2_extent_tree *et, | ||
428 | struct ocfs2_extent_rec *rec) | 412 | struct ocfs2_extent_rec *rec) |
429 | { | 413 | { |
430 | int ret = 0; | 414 | int ret = 0; |
431 | 415 | ||
432 | if (et->et_ops->eo_insert_check) | 416 | if (et->et_ops->eo_insert_check) |
433 | ret = et->et_ops->eo_insert_check(inode, et, rec); | 417 | ret = et->et_ops->eo_insert_check(et, rec); |
434 | return ret; | 418 | return ret; |
435 | } | 419 | } |
436 | 420 | ||
437 | static inline int ocfs2_et_sanity_check(struct inode *inode, | 421 | static inline int ocfs2_et_sanity_check(struct ocfs2_extent_tree *et) |
438 | struct ocfs2_extent_tree *et) | ||
439 | { | 422 | { |
440 | int ret = 0; | 423 | int ret = 0; |
441 | 424 | ||
442 | if (et->et_ops->eo_sanity_check) | 425 | if (et->et_ops->eo_sanity_check) |
443 | ret = et->et_ops->eo_sanity_check(inode, et); | 426 | ret = et->et_ops->eo_sanity_check(et); |
444 | return ret; | 427 | return ret; |
445 | } | 428 | } |
446 | 429 | ||
@@ -3016,7 +2999,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | |||
3016 | struct ocfs2_extent_list *el; | 2999 | struct ocfs2_extent_list *el; |
3017 | 3000 | ||
3018 | 3001 | ||
3019 | ret = ocfs2_et_sanity_check(inode, et); | 3002 | ret = ocfs2_et_sanity_check(et); |
3020 | if (ret) | 3003 | if (ret) |
3021 | goto out; | 3004 | goto out; |
3022 | /* | 3005 | /* |
@@ -4308,7 +4291,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
4308 | 4291 | ||
4309 | out_update_clusters: | 4292 | out_update_clusters: |
4310 | if (type->ins_split == SPLIT_NONE) | 4293 | if (type->ins_split == SPLIT_NONE) |
4311 | ocfs2_et_update_clusters(inode, et, | 4294 | ocfs2_et_update_clusters(et, |
4312 | le16_to_cpu(insert_rec->e_leaf_clusters)); | 4295 | le16_to_cpu(insert_rec->e_leaf_clusters)); |
4313 | 4296 | ||
4314 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); | 4297 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); |
@@ -4697,7 +4680,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, | |||
4697 | rec.e_blkno = cpu_to_le64(start_blk); | 4680 | rec.e_blkno = cpu_to_le64(start_blk); |
4698 | rec.e_leaf_clusters = cpu_to_le16(new_clusters); | 4681 | rec.e_leaf_clusters = cpu_to_le16(new_clusters); |
4699 | rec.e_flags = flags; | 4682 | rec.e_flags = flags; |
4700 | status = ocfs2_et_insert_check(inode, et, &rec); | 4683 | status = ocfs2_et_insert_check(et, &rec); |
4701 | if (status) { | 4684 | if (status) { |
4702 | mlog_errno(status); | 4685 | mlog_errno(status); |
4703 | goto bail; | 4686 | goto bail; |
@@ -5603,7 +5586,7 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
5603 | goto out_commit; | 5586 | goto out_commit; |
5604 | } | 5587 | } |
5605 | 5588 | ||
5606 | ocfs2_et_update_clusters(inode, et, -len); | 5589 | ocfs2_et_update_clusters(et, -len); |
5607 | 5590 | ||
5608 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); | 5591 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); |
5609 | if (ret) { | 5592 | if (ret) { |