diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-12-09 17:24:33 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:40:32 -0500 |
commit | 2a50a743bdaab104155bd9e988d2ba3bb4177263 (patch) | |
tree | a330bfffe09dfca4340075bd9c44f632a3284469 /fs/ocfs2 | |
parent | 4d0e214ee83185fcaa2cb97cd026d32bdc5c994a (diff) |
ocfs2: Create ocfs2_xattr_value_buf.
When an ocfs2 extended attribute is large enough to require its own
allocation tree, we root it with an ocfs2_xattr_value_root. However,
these roots can be a part of inodes, xattr blocks, or xattr buckets.
Thus, they need a different journal access function for each container.
We wrap the bh, its journal access function, and the value root (xv) in
a structure called ocfs2_xattr_valu_buf. This is a package that can
be passed around. In this first pass, we simply pass it to the
extent tree code.
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 | 25 | ||||
-rw-r--r-- | fs/ocfs2/alloc.h | 4 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 34 | ||||
-rw-r--r-- | fs/ocfs2/xattr.h | 14 |
4 files changed, 49 insertions, 28 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 6e58fd557e5b..874c0bd9e1cc 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "file.h" | 48 | #include "file.h" |
49 | #include "super.h" | 49 | #include "super.h" |
50 | #include "uptodate.h" | 50 | #include "uptodate.h" |
51 | #include "xattr.h" | ||
51 | 52 | ||
52 | #include "buffer_head_io.h" | 53 | #include "buffer_head_io.h" |
53 | 54 | ||
@@ -207,36 +208,33 @@ static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et) | |||
207 | 208 | ||
208 | static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et) | 209 | static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et) |
209 | { | 210 | { |
210 | struct ocfs2_xattr_value_root *xv = et->et_object; | 211 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
211 | 212 | ||
212 | et->et_root_el = &xv->xr_list; | 213 | et->et_root_el = &vb->vb_xv->xr_list; |
213 | } | 214 | } |
214 | 215 | ||
215 | static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | 216 | static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, |
216 | u64 blkno) | 217 | u64 blkno) |
217 | { | 218 | { |
218 | struct ocfs2_xattr_value_root *xv = | 219 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
219 | (struct ocfs2_xattr_value_root *)et->et_object; | ||
220 | 220 | ||
221 | xv->xr_last_eb_blk = cpu_to_le64(blkno); | 221 | vb->vb_xv->xr_last_eb_blk = cpu_to_le64(blkno); |
222 | } | 222 | } |
223 | 223 | ||
224 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) | 224 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) |
225 | { | 225 | { |
226 | struct ocfs2_xattr_value_root *xv = | 226 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
227 | (struct ocfs2_xattr_value_root *) et->et_object; | ||
228 | 227 | ||
229 | return le64_to_cpu(xv->xr_last_eb_blk); | 228 | return le64_to_cpu(vb->vb_xv->xr_last_eb_blk); |
230 | } | 229 | } |
231 | 230 | ||
232 | static void ocfs2_xattr_value_update_clusters(struct inode *inode, | 231 | static void ocfs2_xattr_value_update_clusters(struct inode *inode, |
233 | struct ocfs2_extent_tree *et, | 232 | struct ocfs2_extent_tree *et, |
234 | u32 clusters) | 233 | u32 clusters) |
235 | { | 234 | { |
236 | struct ocfs2_xattr_value_root *xv = | 235 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
237 | (struct ocfs2_xattr_value_root *)et->et_object; | ||
238 | 236 | ||
239 | le32_add_cpu(&xv->xr_clusters, clusters); | 237 | le32_add_cpu(&vb->vb_xv->xr_clusters, clusters); |
240 | } | 238 | } |
241 | 239 | ||
242 | static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = { | 240 | static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = { |
@@ -334,10 +332,9 @@ void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, | |||
334 | 332 | ||
335 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | 333 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, |
336 | struct inode *inode, | 334 | struct inode *inode, |
337 | struct buffer_head *bh, | 335 | struct ocfs2_xattr_value_buf *vb) |
338 | struct ocfs2_xattr_value_root *xv) | ||
339 | { | 336 | { |
340 | __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access, xv, | 337 | __ocfs2_init_extent_tree(et, inode, vb->vb_bh, vb->vb_access, vb, |
341 | &ocfs2_xattr_value_et_ops); | 338 | &ocfs2_xattr_value_et_ops); |
342 | } | 339 | } |
343 | 340 | ||
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 4b6fea22748a..cceff5c37f47 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -71,10 +71,10 @@ void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, | |||
71 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, | 71 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, |
72 | struct inode *inode, | 72 | struct inode *inode, |
73 | struct buffer_head *bh); | 73 | struct buffer_head *bh); |
74 | struct ocfs2_xattr_value_buf; | ||
74 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | 75 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, |
75 | struct inode *inode, | 76 | struct inode *inode, |
76 | struct buffer_head *bh, | 77 | struct ocfs2_xattr_value_buf *vb); |
77 | struct ocfs2_xattr_value_root *xv); | ||
78 | 78 | ||
79 | /* | 79 | /* |
80 | * Read an extent block into *bh. If *bh is NULL, a bh will be | 80 | * Read an extent block into *bh. If *bh is NULL, a bh will be |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 7c2f4c9d1bd9..123d378aba9e 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -581,21 +581,26 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
581 | handle_t *handle = ctxt->handle; | 581 | handle_t *handle = ctxt->handle; |
582 | enum ocfs2_alloc_restarted why; | 582 | enum ocfs2_alloc_restarted why; |
583 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 583 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
584 | u32 prev_clusters, logical_start = le32_to_cpu(xv->xr_clusters); | 584 | struct ocfs2_xattr_value_buf vb = { |
585 | .vb_bh = xattr_bh, | ||
586 | .vb_xv = xv, | ||
587 | .vb_access = ocfs2_journal_access, | ||
588 | }; | ||
589 | u32 prev_clusters, logical_start = le32_to_cpu(vb.vb_xv->xr_clusters); | ||
585 | struct ocfs2_extent_tree et; | 590 | struct ocfs2_extent_tree et; |
586 | 591 | ||
587 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); | 592 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); |
588 | 593 | ||
589 | ocfs2_init_xattr_value_extent_tree(&et, inode, xattr_bh, xv); | 594 | ocfs2_init_xattr_value_extent_tree(&et, inode, &vb); |
590 | 595 | ||
591 | status = ocfs2_journal_access(handle, inode, xattr_bh, | 596 | status = vb.vb_access(handle, inode, vb.vb_bh, |
592 | OCFS2_JOURNAL_ACCESS_WRITE); | 597 | OCFS2_JOURNAL_ACCESS_WRITE); |
593 | if (status < 0) { | 598 | if (status < 0) { |
594 | mlog_errno(status); | 599 | mlog_errno(status); |
595 | goto leave; | 600 | goto leave; |
596 | } | 601 | } |
597 | 602 | ||
598 | prev_clusters = le32_to_cpu(xv->xr_clusters); | 603 | prev_clusters = le32_to_cpu(vb.vb_xv->xr_clusters); |
599 | status = ocfs2_add_clusters_in_btree(osb, | 604 | status = ocfs2_add_clusters_in_btree(osb, |
600 | inode, | 605 | inode, |
601 | &logical_start, | 606 | &logical_start, |
@@ -611,13 +616,13 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
611 | goto leave; | 616 | goto leave; |
612 | } | 617 | } |
613 | 618 | ||
614 | status = ocfs2_journal_dirty(handle, xattr_bh); | 619 | status = ocfs2_journal_dirty(handle, vb.vb_bh); |
615 | if (status < 0) { | 620 | if (status < 0) { |
616 | mlog_errno(status); | 621 | mlog_errno(status); |
617 | goto leave; | 622 | goto leave; |
618 | } | 623 | } |
619 | 624 | ||
620 | clusters_to_add -= le32_to_cpu(xv->xr_clusters) - prev_clusters; | 625 | clusters_to_add -= le32_to_cpu(vb.vb_xv->xr_clusters) - prev_clusters; |
621 | 626 | ||
622 | /* | 627 | /* |
623 | * We should have already allocated enough space before the transaction, | 628 | * We should have already allocated enough space before the transaction, |
@@ -640,11 +645,16 @@ static int __ocfs2_remove_xattr_range(struct inode *inode, | |||
640 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | 645 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
641 | handle_t *handle = ctxt->handle; | 646 | handle_t *handle = ctxt->handle; |
642 | struct ocfs2_extent_tree et; | 647 | struct ocfs2_extent_tree et; |
648 | struct ocfs2_xattr_value_buf vb = { | ||
649 | .vb_bh = root_bh, | ||
650 | .vb_xv = xv, | ||
651 | .vb_access = ocfs2_journal_access, | ||
652 | }; | ||
643 | 653 | ||
644 | ocfs2_init_xattr_value_extent_tree(&et, inode, root_bh, xv); | 654 | ocfs2_init_xattr_value_extent_tree(&et, inode, &vb); |
645 | 655 | ||
646 | ret = ocfs2_journal_access(handle, inode, root_bh, | 656 | ret = vb.vb_access(handle, inode, vb.vb_bh, |
647 | OCFS2_JOURNAL_ACCESS_WRITE); | 657 | OCFS2_JOURNAL_ACCESS_WRITE); |
648 | if (ret) { | 658 | if (ret) { |
649 | mlog_errno(ret); | 659 | mlog_errno(ret); |
650 | goto out; | 660 | goto out; |
@@ -657,9 +667,9 @@ static int __ocfs2_remove_xattr_range(struct inode *inode, | |||
657 | goto out; | 667 | goto out; |
658 | } | 668 | } |
659 | 669 | ||
660 | le32_add_cpu(&xv->xr_clusters, -len); | 670 | le32_add_cpu(&vb.vb_xv->xr_clusters, -len); |
661 | 671 | ||
662 | ret = ocfs2_journal_dirty(handle, root_bh); | 672 | ret = ocfs2_journal_dirty(handle, vb.vb_bh); |
663 | if (ret) { | 673 | if (ret) { |
664 | mlog_errno(ret); | 674 | mlog_errno(ret); |
665 | goto out; | 675 | goto out; |
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h index 9a67e7d8f812..5a1ebc789f7e 100644 --- a/fs/ocfs2/xattr.h +++ b/fs/ocfs2/xattr.h | |||
@@ -70,4 +70,18 @@ int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *, | |||
70 | int, struct ocfs2_security_xattr_info *, | 70 | int, struct ocfs2_security_xattr_info *, |
71 | int *, int *, struct ocfs2_alloc_context **); | 71 | int *, int *, struct ocfs2_alloc_context **); |
72 | 72 | ||
73 | /* | ||
74 | * xattrs can live inside an inode, as part of an external xattr block, | ||
75 | * or inside an xattr bucket, which is the leaf of a tree rooted in an | ||
76 | * xattr block. Some of the xattr calls, especially the value setting | ||
77 | * functions, want to treat each of these locations as equal. Let's wrap | ||
78 | * them in a structure that we can pass around instead of raw buffer_heads. | ||
79 | */ | ||
80 | struct ocfs2_xattr_value_buf { | ||
81 | struct buffer_head *vb_bh; | ||
82 | ocfs2_journal_access_func vb_access; | ||
83 | struct ocfs2_xattr_value_root *vb_xv; | ||
84 | }; | ||
85 | |||
86 | |||
73 | #endif /* OCFS2_XATTR_H */ | 87 | #endif /* OCFS2_XATTR_H */ |