]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.31/patches.suse/ocfs2-Add-xattr-index-tree-operations.patch
Reenabled linux-xen, added patches for Xen Kernel Version 2.6.27.31,
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.suse / ocfs2-Add-xattr-index-tree-operations.patch
1 From: Tao Ma <tao.ma@oracle.com>
2 Subject: [PATCH 10/16] ocfs2: Add xattr index tree operations
3 Patch-mainline: 2.6.28?
4 References: FATE302067
5
6 When necessary, an ocfs2_xattr_block will embed an ocfs2_extent_list to
7 store large numbers of EAs. This patch adds a new type in
8 ocfs2_extent_tree_type and adds the implementation so that we can re-use the
9 b-tree code to handle the storage of many EAs.
10
11 Signed-off-by: Tao Ma <tao.ma@oracle.com>
12 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
13 ---
14 fs/ocfs2/alloc.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 fs/ocfs2/alloc.h | 10 ++++++
16 2 files changed, 99 insertions(+), 0 deletions(-)
17
18 diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
19 index d175db1..47cdea6 100644
20 --- a/fs/ocfs2/alloc.c
21 +++ b/fs/ocfs2/alloc.c
22 @@ -177,6 +177,48 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_et_ops = {
23 .sanity_check = ocfs2_xattr_value_sanity_check,
24 };
25
26 +static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et,
27 + u64 blkno)
28 +{
29 + struct ocfs2_xattr_block *xb =
30 + (struct ocfs2_xattr_block *) et->root_bh->b_data;
31 + struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root;
32 +
33 + xt->xt_last_eb_blk = cpu_to_le64(blkno);
34 +}
35 +
36 +static u64 ocfs2_xattr_tree_get_last_eb_blk(struct ocfs2_extent_tree *et)
37 +{
38 + struct ocfs2_xattr_block *xb =
39 + (struct ocfs2_xattr_block *) et->root_bh->b_data;
40 + struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root;
41 +
42 + return le64_to_cpu(xt->xt_last_eb_blk);
43 +}
44 +
45 +static void ocfs2_xattr_tree_update_clusters(struct inode *inode,
46 + struct ocfs2_extent_tree *et,
47 + u32 clusters)
48 +{
49 + struct ocfs2_xattr_block *xb =
50 + (struct ocfs2_xattr_block *)et->root_bh->b_data;
51 +
52 + le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, clusters);
53 +}
54 +
55 +static int ocfs2_xattr_tree_sanity_check(struct inode *inode,
56 + struct ocfs2_extent_tree *et)
57 +{
58 + return 0;
59 +}
60 +
61 +static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
62 + .set_last_eb_blk = ocfs2_xattr_tree_set_last_eb_blk,
63 + .get_last_eb_blk = ocfs2_xattr_tree_get_last_eb_blk,
64 + .update_clusters = ocfs2_xattr_tree_update_clusters,
65 + .sanity_check = ocfs2_xattr_tree_sanity_check,
66 +};
67 +
68 static struct ocfs2_extent_tree*
69 ocfs2_new_extent_tree(struct buffer_head *bh,
70 enum ocfs2_extent_tree_type et_type,
71 @@ -201,6 +243,11 @@ static struct ocfs2_extent_tree*
72 (struct ocfs2_xattr_value_root *) private;
73 et->root_el = &xv->xr_list;
74 et->eops = &ocfs2_xattr_et_ops;
75 + } else if (et_type == OCFS2_XATTR_TREE_EXTENT) {
76 + struct ocfs2_xattr_block *xb =
77 + (struct ocfs2_xattr_block *)bh->b_data;
78 + et->root_el = &xb->xb_attrs.xb_root.xt_list;
79 + et->eops = &ocfs2_xattr_tree_et_ops;
80 }
81
82 return et;
83 @@ -570,6 +617,12 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
84
85 last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk);
86 el = &xv->xr_list;
87 + } else if (type == OCFS2_XATTR_TREE_EXTENT) {
88 + struct ocfs2_xattr_block *xb =
89 + (struct ocfs2_xattr_block *)root_bh->b_data;
90 +
91 + last_eb_blk = le64_to_cpu(xb->xb_attrs.xb_root.xt_last_eb_blk);
92 + el = &xb->xb_attrs.xb_root.xt_list;
93 }
94
95 if (last_eb_blk) {
96 @@ -4406,6 +4459,36 @@ bail:
97 return status;
98 }
99
100 +int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,
101 + handle_t *handle,
102 + struct inode *inode,
103 + struct buffer_head *root_bh,
104 + u32 cpos,
105 + u64 start_blk,
106 + u32 new_clusters,
107 + u8 flags,
108 + struct ocfs2_alloc_context *meta_ac)
109 +{
110 + int status;
111 + struct ocfs2_extent_tree *et = NULL;
112 +
113 + et = ocfs2_new_extent_tree(root_bh, OCFS2_XATTR_TREE_EXTENT, NULL);
114 + if (!et) {
115 + status = -ENOMEM;
116 + mlog_errno(status);
117 + goto bail;
118 + }
119 +
120 + status = ocfs2_insert_extent(osb, handle, inode, root_bh,
121 + cpos, start_blk, new_clusters,
122 + flags, meta_ac, et);
123 +
124 + if (et)
125 + ocfs2_free_extent_tree(et);
126 +bail:
127 + return status;
128 +}
129 +
130 /*
131 * Allcate and add clusters into the extent b-tree.
132 * The new clusters(clusters_to_add) will be inserted at logical_offset.
133 @@ -4491,6 +4574,12 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb,
134 status = ocfs2_dinode_insert_extent(osb, handle, inode, root_bh,
135 *logical_offset, block,
136 num_bits, flags, meta_ac);
137 + else if (type == OCFS2_XATTR_TREE_EXTENT)
138 + status = ocfs2_xattr_tree_insert_extent(osb, handle,
139 + inode, root_bh,
140 + *logical_offset,
141 + block, num_bits, flags,
142 + meta_ac);
143 else
144 status = ocfs2_xattr_value_insert_extent(osb, handle,
145 inode, root_bh,
146 diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
147 index 168e86e..b8cfc53 100644
148 --- a/fs/ocfs2/alloc.h
149 +++ b/fs/ocfs2/alloc.h
150 @@ -29,6 +29,7 @@
151 enum ocfs2_extent_tree_type {
152 OCFS2_DINODE_EXTENT = 0,
153 OCFS2_XATTR_VALUE_EXTENT,
154 + OCFS2_XATTR_TREE_EXTENT,
155 };
156
157 struct ocfs2_alloc_context;
158 @@ -51,6 +52,15 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb,
159 u8 flags,
160 struct ocfs2_alloc_context *meta_ac,
161 void *private);
162 +int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,
163 + handle_t *handle,
164 + struct inode *inode,
165 + struct buffer_head *root_bh,
166 + u32 cpos,
167 + u64 start_blk,
168 + u32 new_clusters,
169 + u8 flags,
170 + struct ocfs2_alloc_context *meta_ac);
171 enum ocfs2_alloc_restarted {
172 RESTART_NONE = 0,
173 RESTART_TRANS,
174 --
175 1.5.4.5
176