]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.suse/ocfs2-turn-__ocfs2_remove_inode_range-into-ocfs2_.patch
Updated xen patches taken from suse.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.suse / ocfs2-turn-__ocfs2_remove_inode_range-into-ocfs2_.patch
1 From: Mark Fasheh <mfasheh@suse.com>
2 Date: Wed, 12 Nov 2008 15:16:38 -0800
3 Subject: ocfs2: turn __ocfs2_remove_inode_range() into ocfs2_remove_btree_range()
4 Patch-mainline: 2.6.29
5
6 This patch genericizes the high level handling of extent removal.
7 ocfs2_remove_btree_range() is nearly identical to
8 __ocfs2_remove_inode_range(), except that extent tree operations have been
9 used where necessary. We update ocfs2_remove_inode_range() to use the
10 generic helper. Now extent tree based structures have an easy way to
11 truncate ranges.
12
13 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
14 Acked-by: Joel Becker <joel.becker@oracle.com>
15 ---
16 fs/ocfs2/alloc.c | 72 +++++++++++++++++++++++++++++++++++++++++++++
17 fs/ocfs2/alloc.h | 5 +++
18 fs/ocfs2/file.c | 85 +++--------------------------------------------------
19 3 files changed, 82 insertions(+), 80 deletions(-)
20
21 Index: linux-2.6.27-ocfs2/fs/ocfs2/alloc.c
22 ===================================================================
23 --- linux-2.6.27-ocfs2.orig/fs/ocfs2/alloc.c
24 +++ linux-2.6.27-ocfs2/fs/ocfs2/alloc.c
25 @@ -5264,6 +5264,78 @@ out:
26 return ret;
27 }
28
29 +int ocfs2_remove_btree_range(struct inode *inode,
30 + struct ocfs2_extent_tree *et,
31 + u32 cpos, u32 phys_cpos, u32 len,
32 + struct ocfs2_cached_dealloc_ctxt *dealloc)
33 +{
34 + int ret;
35 + u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
36 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
37 + struct inode *tl_inode = osb->osb_tl_inode;
38 + handle_t *handle;
39 + struct ocfs2_alloc_context *meta_ac = NULL;
40 +
41 + ret = ocfs2_lock_allocators(inode, et, 0, 1, NULL, &meta_ac);
42 + if (ret) {
43 + mlog_errno(ret);
44 + return ret;
45 + }
46 +
47 + mutex_lock(&tl_inode->i_mutex);
48 +
49 + if (ocfs2_truncate_log_needs_flush(osb)) {
50 + ret = __ocfs2_flush_truncate_log(osb);
51 + if (ret < 0) {
52 + mlog_errno(ret);
53 + goto out;
54 + }
55 + }
56 +
57 + handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS);
58 + if (IS_ERR(handle)) {
59 + ret = PTR_ERR(handle);
60 + mlog_errno(ret);
61 + goto out;
62 + }
63 +
64 + ret = ocfs2_journal_access(handle, inode, et->et_root_bh,
65 + OCFS2_JOURNAL_ACCESS_WRITE);
66 + if (ret) {
67 + mlog_errno(ret);
68 + goto out;
69 + }
70 +
71 + ret = ocfs2_remove_extent(inode, et, cpos, len, handle, meta_ac,
72 + dealloc);
73 + if (ret) {
74 + mlog_errno(ret);
75 + goto out_commit;
76 + }
77 +
78 + ocfs2_et_update_clusters(inode, et, -len);
79 +
80 + ret = ocfs2_journal_dirty(handle, et->et_root_bh);
81 + if (ret) {
82 + mlog_errno(ret);
83 + goto out_commit;
84 + }
85 +
86 + ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len);
87 + if (ret)
88 + mlog_errno(ret);
89 +
90 +out_commit:
91 + ocfs2_commit_trans(osb, handle);
92 +out:
93 + mutex_unlock(&tl_inode->i_mutex);
94 +
95 + if (meta_ac)
96 + ocfs2_free_alloc_context(meta_ac);
97 +
98 + return ret;
99 +}
100 +
101 int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb)
102 {
103 struct buffer_head *tl_bh = osb->osb_tl_bh;
104 Index: linux-2.6.27-ocfs2/fs/ocfs2/alloc.h
105 ===================================================================
106 --- linux-2.6.27-ocfs2.orig/fs/ocfs2/alloc.h
107 +++ linux-2.6.27-ocfs2/fs/ocfs2/alloc.h
108 @@ -110,6 +110,11 @@ int ocfs2_remove_extent(struct inode *in
109 u32 cpos, u32 len, handle_t *handle,
110 struct ocfs2_alloc_context *meta_ac,
111 struct ocfs2_cached_dealloc_ctxt *dealloc);
112 +int ocfs2_remove_btree_range(struct inode *inode,
113 + struct ocfs2_extent_tree *et,
114 + u32 cpos, u32 phys_cpos, u32 len,
115 + struct ocfs2_cached_dealloc_ctxt *dealloc);
116 +
117 int ocfs2_num_free_extents(struct ocfs2_super *osb,
118 struct inode *inode,
119 struct ocfs2_extent_tree *et);
120 Index: linux-2.6.27-ocfs2/fs/ocfs2/file.c
121 ===================================================================
122 --- linux-2.6.27-ocfs2.orig/fs/ocfs2/file.c
123 +++ linux-2.6.27-ocfs2/fs/ocfs2/file.c
124 @@ -1226,83 +1226,6 @@ out:
125 return ret;
126 }
127
128 -static int __ocfs2_remove_inode_range(struct inode *inode,
129 - struct buffer_head *di_bh,
130 - u32 cpos, u32 phys_cpos, u32 len,
131 - struct ocfs2_cached_dealloc_ctxt *dealloc)
132 -{
133 - int ret;
134 - u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
135 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
136 - struct inode *tl_inode = osb->osb_tl_inode;
137 - handle_t *handle;
138 - struct ocfs2_alloc_context *meta_ac = NULL;
139 - struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
140 - struct ocfs2_extent_tree et;
141 -
142 - ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
143 -
144 - ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
145 - if (ret) {
146 - mlog_errno(ret);
147 - return ret;
148 - }
149 -
150 - mutex_lock(&tl_inode->i_mutex);
151 -
152 - if (ocfs2_truncate_log_needs_flush(osb)) {
153 - ret = __ocfs2_flush_truncate_log(osb);
154 - if (ret < 0) {
155 - mlog_errno(ret);
156 - goto out;
157 - }
158 - }
159 -
160 - handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS);
161 - if (IS_ERR(handle)) {
162 - ret = PTR_ERR(handle);
163 - mlog_errno(ret);
164 - goto out;
165 - }
166 -
167 - ret = ocfs2_journal_access(handle, inode, di_bh,
168 - OCFS2_JOURNAL_ACCESS_WRITE);
169 - if (ret) {
170 - mlog_errno(ret);
171 - goto out;
172 - }
173 -
174 - ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, meta_ac,
175 - dealloc);
176 - if (ret) {
177 - mlog_errno(ret);
178 - goto out_commit;
179 - }
180 -
181 - OCFS2_I(inode)->ip_clusters -= len;
182 - di->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters);
183 -
184 - ret = ocfs2_journal_dirty(handle, di_bh);
185 - if (ret) {
186 - mlog_errno(ret);
187 - goto out_commit;
188 - }
189 -
190 - ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len);
191 - if (ret)
192 - mlog_errno(ret);
193 -
194 -out_commit:
195 - ocfs2_commit_trans(osb, handle);
196 -out:
197 - mutex_unlock(&tl_inode->i_mutex);
198 -
199 - if (meta_ac)
200 - ocfs2_free_alloc_context(meta_ac);
201 -
202 - return ret;
203 -}
204 -
205 /*
206 * Truncate a byte range, avoiding pages within partial clusters. This
207 * preserves those pages for the zeroing code to write to.
208 @@ -1402,7 +1325,9 @@ static int ocfs2_remove_inode_range(stru
209 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
210 struct ocfs2_cached_dealloc_ctxt dealloc;
211 struct address_space *mapping = inode->i_mapping;
212 + struct ocfs2_extent_tree et;
213
214 + ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
215 ocfs2_init_dealloc_ctxt(&dealloc);
216
217 if (byte_len == 0)
218 @@ -1458,9 +1383,9 @@ static int ocfs2_remove_inode_range(stru
219
220 /* Only do work for non-holes */
221 if (phys_cpos != 0) {
222 - ret = __ocfs2_remove_inode_range(inode, di_bh, cpos,
223 - phys_cpos, alloc_size,
224 - &dealloc);
225 + ret = ocfs2_remove_btree_range(inode, &et, cpos,
226 + phys_cpos, alloc_size,
227 + &dealloc);
228 if (ret) {
229 mlog_errno(ret);
230 goto out;