]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Miklos Szeredi <mszeredi@suse.cz> |
2 | Subject: fix kabi breakage from i_mutex locking fix | |
3 | Patch-mainline: no | |
4 | References: bnc#495065 | |
5 | ||
6 | Splice splice_desc into two structures, splice_desc (the old version) | |
7 | and splice_desc_ext, containing the new fields. | |
8 | ||
9 | Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> | |
10 | --- | |
11 | fs/ocfs2/file.c | 18 +++++++++-------- | |
12 | fs/splice.c | 51 ++++++++++++++++++++++++++----------------------- | |
13 | include/linux/splice.h | 12 +++++++---- | |
14 | 3 files changed, 46 insertions(+), 35 deletions(-) | |
15 | ||
16 | Index: linux-2.6.25-SL110_BRANCH/fs/ocfs2/file.c | |
17 | =================================================================== | |
18 | --- linux-2.6.25-SL110_BRANCH.orig/fs/ocfs2/file.c 2009-05-26 17:23:28.000000000 +0200 | |
19 | +++ linux-2.6.25-SL110_BRANCH/fs/ocfs2/file.c 2009-05-27 10:10:28.000000000 +0200 | |
20 | @@ -2073,9 +2073,10 @@ out_sems: | |
21 | ||
22 | static int ocfs2_splice_to_file(struct pipe_inode_info *pipe, | |
23 | struct file *out, | |
24 | - struct splice_desc *sd) | |
25 | + struct splice_desc_ext *esd) | |
26 | { | |
27 | int ret; | |
28 | + struct splice_desc *sd = esd->sd; | |
29 | ||
30 | ret = ocfs2_prepare_inode_for_write(out->f_path.dentry, &sd->pos, | |
31 | sd->total_len, 0, NULL); | |
32 | @@ -2084,7 +2085,7 @@ static int ocfs2_splice_to_file(struct p | |
33 | return ret; | |
34 | } | |
35 | ||
36 | - return splice_from_pipe_feed(pipe, sd, pipe_to_file); | |
37 | + return splice_from_pipe_feed(pipe, esd, pipe_to_file); | |
38 | } | |
39 | ||
40 | static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, | |
41 | @@ -2102,6 +2103,7 @@ static ssize_t ocfs2_file_splice_write(s | |
42 | .pos = *ppos, | |
43 | .u.file = out, | |
44 | }; | |
45 | + struct splice_desc_ext esd = { .sd = &sd }; | |
46 | ||
47 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe, | |
48 | (unsigned int)len, | |
49 | @@ -2111,9 +2113,9 @@ static ssize_t ocfs2_file_splice_write(s | |
50 | if (pipe->inode) | |
51 | mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_PARENT); | |
52 | ||
53 | - splice_from_pipe_begin(&sd); | |
54 | + splice_from_pipe_begin(&esd); | |
55 | do { | |
56 | - ret = splice_from_pipe_next(pipe, &sd); | |
57 | + ret = splice_from_pipe_next(pipe, &esd); | |
58 | if (ret <= 0) | |
59 | break; | |
60 | ||
61 | @@ -2122,18 +2124,18 @@ static ssize_t ocfs2_file_splice_write(s | |
62 | if (ret < 0) | |
63 | mlog_errno(ret); | |
64 | else { | |
65 | - ret = ocfs2_splice_to_file(pipe, out, &sd); | |
66 | + ret = ocfs2_splice_to_file(pipe, out, &esd); | |
67 | ocfs2_rw_unlock(inode, 1); | |
68 | } | |
69 | mutex_unlock(&inode->i_mutex); | |
70 | } while (ret > 0); | |
71 | - splice_from_pipe_end(pipe, &sd); | |
72 | + splice_from_pipe_end(pipe, &esd); | |
73 | ||
74 | if (pipe->inode) | |
75 | mutex_unlock(&pipe->inode->i_mutex); | |
76 | ||
77 | - if (sd.num_spliced) | |
78 | - ret = sd.num_spliced; | |
79 | + if (esd.num_spliced) | |
80 | + ret = esd.num_spliced; | |
81 | ||
82 | if (ret > 0) { | |
83 | unsigned long nr_pages; | |
84 | Index: linux-2.6.25-SL110_BRANCH/fs/splice.c | |
85 | =================================================================== | |
86 | --- linux-2.6.25-SL110_BRANCH.orig/fs/splice.c 2009-05-26 17:23:29.000000000 +0200 | |
87 | +++ linux-2.6.25-SL110_BRANCH/fs/splice.c 2009-05-27 10:09:01.000000000 +0200 | |
88 | @@ -619,10 +619,11 @@ static void wakeup_pipe_writers(struct p | |
89 | * locking is required around copying the pipe buffers to the | |
90 | * destination. | |
91 | */ | |
92 | -int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd, | |
93 | +int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc_ext *esd, | |
94 | splice_actor *actor) | |
95 | { | |
96 | int ret; | |
97 | + struct splice_desc *sd = esd->sd; | |
98 | ||
99 | while (pipe->nrbufs) { | |
100 | struct pipe_buffer *buf = pipe->bufs + pipe->curbuf; | |
101 | @@ -641,7 +642,7 @@ int splice_from_pipe_feed(struct pipe_in | |
102 | buf->offset += ret; | |
103 | buf->len -= ret; | |
104 | ||
105 | - sd->num_spliced += ret; | |
106 | + esd->num_spliced += ret; | |
107 | sd->len -= ret; | |
108 | sd->pos += ret; | |
109 | sd->total_len -= ret; | |
110 | @@ -652,7 +653,7 @@ int splice_from_pipe_feed(struct pipe_in | |
111 | pipe->curbuf = (pipe->curbuf + 1) & (PIPE_BUFFERS - 1); | |
112 | pipe->nrbufs--; | |
113 | if (pipe->inode) | |
114 | - sd->need_wakeup = true; | |
115 | + esd->need_wakeup = true; | |
116 | } | |
117 | ||
118 | if (!sd->total_len) | |
119 | @@ -673,13 +674,15 @@ EXPORT_SYMBOL(splice_from_pipe_feed); | |
120 | * value (one) if pipe buffers are available. It will return zero | |
121 | * or -errno if no more data needs to be spliced. | |
122 | */ | |
123 | -int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd) | |
124 | +int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc_ext *esd) | |
125 | { | |
126 | + struct splice_desc *sd = esd->sd; | |
127 | + | |
128 | while (!pipe->nrbufs) { | |
129 | if (!pipe->writers) | |
130 | return 0; | |
131 | ||
132 | - if (!pipe->waiting_writers && sd->num_spliced) | |
133 | + if (!pipe->waiting_writers && esd->num_spliced) | |
134 | return 0; | |
135 | ||
136 | if (sd->flags & SPLICE_F_NONBLOCK) | |
137 | @@ -688,9 +691,9 @@ int splice_from_pipe_next(struct pipe_in | |
138 | if (signal_pending(current)) | |
139 | return -ERESTARTSYS; | |
140 | ||
141 | - if (sd->need_wakeup) { | |
142 | + if (esd->need_wakeup) { | |
143 | wakeup_pipe_writers(pipe); | |
144 | - sd->need_wakeup = false; | |
145 | + esd->need_wakeup = false; | |
146 | } | |
147 | ||
148 | pipe_wait(pipe); | |
149 | @@ -709,10 +712,10 @@ EXPORT_SYMBOL(splice_from_pipe_next); | |
150 | * splice_from_pipe_next() and splice_from_pipe_feed() to | |
151 | * initialize the necessary fields of @sd. | |
152 | */ | |
153 | -void splice_from_pipe_begin(struct splice_desc *sd) | |
154 | +void splice_from_pipe_begin(struct splice_desc_ext *esd) | |
155 | { | |
156 | - sd->num_spliced = 0; | |
157 | - sd->need_wakeup = false; | |
158 | + esd->num_spliced = 0; | |
159 | + esd->need_wakeup = false; | |
160 | } | |
161 | EXPORT_SYMBOL(splice_from_pipe_begin); | |
162 | ||
163 | @@ -726,9 +729,9 @@ EXPORT_SYMBOL(splice_from_pipe_begin); | |
164 | * be called after a loop containing splice_from_pipe_next() and | |
165 | * splice_from_pipe_feed(). | |
166 | */ | |
167 | -void splice_from_pipe_end(struct pipe_inode_info *pipe, struct splice_desc *sd) | |
168 | +void splice_from_pipe_end(struct pipe_inode_info *pipe, struct splice_desc_ext *esd) | |
169 | { | |
170 | - if (sd->need_wakeup) | |
171 | + if (esd->need_wakeup) | |
172 | wakeup_pipe_writers(pipe); | |
173 | } | |
174 | EXPORT_SYMBOL(splice_from_pipe_end); | |
175 | @@ -750,16 +753,17 @@ ssize_t __splice_from_pipe(struct pipe_i | |
176 | splice_actor *actor) | |
177 | { | |
178 | int ret; | |
179 | + struct splice_desc_ext esd = { .sd = sd }; | |
180 | ||
181 | - splice_from_pipe_begin(sd); | |
182 | + splice_from_pipe_begin(&esd); | |
183 | do { | |
184 | - ret = splice_from_pipe_next(pipe, sd); | |
185 | + ret = splice_from_pipe_next(pipe, &esd); | |
186 | if (ret > 0) | |
187 | - ret = splice_from_pipe_feed(pipe, sd, actor); | |
188 | + ret = splice_from_pipe_feed(pipe, &esd, actor); | |
189 | } while (ret > 0); | |
190 | - splice_from_pipe_end(pipe, sd); | |
191 | + splice_from_pipe_end(pipe, &esd); | |
192 | ||
193 | - return sd->num_spliced ? sd->num_spliced : ret; | |
194 | + return esd.num_spliced ? esd.num_spliced : ret; | |
195 | } | |
196 | EXPORT_SYMBOL(__splice_from_pipe); | |
197 | ||
198 | @@ -882,30 +886,31 @@ generic_file_splice_write(struct pipe_in | |
199 | .pos = *ppos, | |
200 | .u.file = out, | |
201 | }; | |
202 | + struct splice_desc_ext esd = { .sd = &sd }; | |
203 | ssize_t ret; | |
204 | ||
205 | if (pipe->inode) | |
206 | mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_PARENT); | |
207 | ||
208 | - splice_from_pipe_begin(&sd); | |
209 | + splice_from_pipe_begin(&esd); | |
210 | do { | |
211 | - ret = splice_from_pipe_next(pipe, &sd); | |
212 | + ret = splice_from_pipe_next(pipe, &esd); | |
213 | if (ret <= 0) | |
214 | break; | |
215 | ||
216 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD); | |
217 | ret = file_remove_suid(out); | |
218 | if (!ret) | |
219 | - ret = splice_from_pipe_feed(pipe, &sd, pipe_to_file); | |
220 | + ret = splice_from_pipe_feed(pipe, &esd, pipe_to_file); | |
221 | mutex_unlock(&inode->i_mutex); | |
222 | } while (ret > 0); | |
223 | - splice_from_pipe_end(pipe, &sd); | |
224 | + splice_from_pipe_end(pipe, &esd); | |
225 | ||
226 | if (pipe->inode) | |
227 | mutex_unlock(&pipe->inode->i_mutex); | |
228 | ||
229 | - if (sd.num_spliced) | |
230 | - ret = sd.num_spliced; | |
231 | + if (esd.num_spliced) | |
232 | + ret = esd.num_spliced; | |
233 | ||
234 | if (ret > 0) { | |
235 | unsigned long nr_pages; | |
236 | Index: linux-2.6.25-SL110_BRANCH/include/linux/splice.h | |
237 | =================================================================== | |
238 | --- linux-2.6.25-SL110_BRANCH.orig/include/linux/splice.h 2009-05-26 17:23:28.000000000 +0200 | |
239 | +++ linux-2.6.25-SL110_BRANCH/include/linux/splice.h 2009-05-27 09:59:51.000000000 +0200 | |
240 | @@ -36,6 +36,10 @@ struct splice_desc { | |
241 | void *data; /* cookie */ | |
242 | } u; | |
243 | loff_t pos; /* file position */ | |
244 | +}; | |
245 | + | |
246 | +struct splice_desc_ext { | |
247 | + struct splice_desc *sd; | |
248 | size_t num_spliced; /* number of bytes already spliced */ | |
249 | bool need_wakeup; /* need to wake up writer */ | |
250 | }; | |
251 | @@ -68,13 +72,13 @@ extern ssize_t splice_from_pipe(struct p | |
252 | splice_actor *); | |
253 | extern ssize_t __splice_from_pipe(struct pipe_inode_info *, | |
254 | struct splice_desc *, splice_actor *); | |
255 | -extern int splice_from_pipe_feed(struct pipe_inode_info *, struct splice_desc *, | |
256 | +extern int splice_from_pipe_feed(struct pipe_inode_info *, struct splice_desc_ext *, | |
257 | splice_actor *); | |
258 | extern int splice_from_pipe_next(struct pipe_inode_info *, | |
259 | - struct splice_desc *); | |
260 | -extern void splice_from_pipe_begin(struct splice_desc *); | |
261 | + struct splice_desc_ext *); | |
262 | +extern void splice_from_pipe_begin(struct splice_desc_ext *); | |
263 | extern void splice_from_pipe_end(struct pipe_inode_info *, | |
264 | - struct splice_desc *); | |
265 | + struct splice_desc_ext *); | |
266 | extern int pipe_to_file(struct pipe_inode_info *, struct pipe_buffer *, | |
267 | struct splice_desc *); | |
268 |