fix 2.6.16 issues, from mini_fo git repository
[openwrt/svn-archive/archive.git] / openwrt / target / linux / package / mini_fo / patches / 102-mutex_change.patch
1 From: <mk@mary.denx.de>
2 Date: Tue, 24 Jan 2006 14:09:21 +0000 (+0100)
3 Subject: Support for new mutex infrastructure
4 X-Git-Url: http://www.denx.de/cgi-bin/gitweb.cgi?p=mini_fo.git;a=commitdiff;h=1dcc028729060ea83ea662155634b33ae8e2c493
5
6 Support for new mutex infrastructure
7 (7892f2f48d165a34b0b8130c8a195dfd807b8cb6)
8 ---
9
10 --- a/ChangeLog
11 +++ b/ChangeLog
12 @@ -1,3 +1,13 @@
13 +2006-01-24 Markus Klotzbuecher <mk@mary.denx.de>
14 +
15 + * Add tons of ugly ifdefs to Ed L. Cashin's mutex patch to
16 + retain backwards compatibility.
17 +
18 +2006-01-24 Ed L. Cashin <ecashin@coraid.com>
19 +
20 + * Support for the new mutex infrastructure
21 + (7892f2f48d165a34b0b8130c8a195dfd807b8cb6)
22 +
23 2005-10-15 Markus Klotzbuecher <mk@localhost.localdomain>
24
25 * Bugfix for a serious memory leak in mini_fo_follow_link.
26 --- a/aux.c
27 +++ b/aux.c
28 @@ -435,8 +435,11 @@ int build_sto_structure(dentry_t *dir, d
29
30 /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
31 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
32 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
33 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
34 +#else
35 down(&hidden_sto_dir_dentry->d_inode->i_sem);
36 -
37 +#endif
38 /* lets be safe */
39 if(dtohd2(dir) != hidden_sto_dir_dentry) {
40 printk(KERN_CRIT "mini_fo: build_sto_structure: invalid parameter or meta data corruption [2].\n");
41 @@ -457,7 +460,11 @@ int build_sto_structure(dentry_t *dir, d
42 if(err) {
43 printk(KERN_CRIT "mini_fo: build_sto_structure: failed to create storage dir [1].\n");
44 /* was: unlock_dir(dir); */
45 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
46 + mutex_unlock(&dir->d_inode->i_mutex);
47 +#else
48 up(&dir->d_inode->i_sem);
49 +#endif
50 dput(dir);
51 return err;
52 }
53 @@ -466,7 +473,11 @@ int build_sto_structure(dentry_t *dir, d
54 if(!dtohd2(dentry)->d_inode) {
55 printk(KERN_CRIT "mini_fo: build_sto_structure: failed to create storage dir [2].\n");
56 /* was: unlock_dir(dir); */
57 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
58 + mutex_unlock(&dir->d_inode->i_mutex);
59 +#else
60 up(&dir->d_inode->i_sem);
61 +#endif
62 dput(dir);
63 return 1;
64 }
65 @@ -485,7 +496,11 @@ int build_sto_structure(dentry_t *dir, d
66 hidden_sto_dir_dentry->d_inode);
67 dir->d_inode->i_nlink++;
68 /* was: unlock_dir(hidden_sto_dir_dentry); */
69 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
70 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
71 +#else
72 up(&hidden_sto_dir_dentry->d_inode->i_sem);
73 +#endif
74 dput(hidden_sto_dir_dentry);
75 return 0;
76 }
77 --- a/file.c
78 +++ b/file.c
79 @@ -613,18 +613,34 @@ mini_fo_fsync(file_t *file, dentry_t *de
80 if ((hidden_file = ftohf(file)) != NULL) {
81 hidden_dentry = dtohd(dentry);
82 if (hidden_file->f_op && hidden_file->f_op->fsync) {
83 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
84 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
85 +#else
86 down(&hidden_dentry->d_inode->i_sem);
87 +#endif
88 err1 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync);
89 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
90 + mutex_unlock(&hidden_dentry->d_inode->i_mutex);
91 +#else
92 up(&hidden_dentry->d_inode->i_sem);
93 +#endif
94 }
95 }
96
97 if ((hidden_file = ftohf2(file)) != NULL) {
98 hidden_dentry = dtohd2(dentry);
99 if (hidden_file->f_op && hidden_file->f_op->fsync) {
100 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
101 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
102 +#else
103 down(&hidden_dentry->d_inode->i_sem);
104 +#endif
105 err2 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync);
106 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
107 + mutex_unlock(&hidden_dentry->d_inode->i_mutex);
108 +#else
109 up(&hidden_dentry->d_inode->i_sem);
110 +#endif
111 }
112 }
113 else
114 --- a/inode.c
115 +++ b/inode.c
116 @@ -355,7 +355,11 @@ mini_fo_link(dentry_t *old_dentry, inode
117
118 /* was: hidden_dir_dentry = lock_parent(hidden_new_dentry); */
119 hidden_dir_dentry = dget(hidden_new_dentry->d_parent);
120 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
121 + mutex_lock(&hidden_dir_dentry->d_inode->i_mutex);
122 +#else
123 down(&hidden_dir_dentry->d_inode->i_sem);
124 +#endif
125
126 err = vfs_link(hidden_old_dentry,
127 hidden_dir_dentry->d_inode,
128 @@ -374,7 +378,11 @@ mini_fo_link(dentry_t *old_dentry, inode
129
130 out_lock:
131 /* was: unlock_dir(hidden_dir_dentry); */
132 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
133 + mutex_unlock(&hidden_dir_dentry->d_inode->i_mutex);
134 +#else
135 up(&hidden_dir_dentry->d_inode->i_sem);
136 +#endif
137 dput(hidden_dir_dentry);
138
139 dput(hidden_new_dentry);
140 @@ -452,7 +460,11 @@ mini_fo_symlink(inode_t *dir, dentry_t *
141 dget(hidden_sto_dentry);
142 /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
143 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
144 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
145 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
146 +#else
147 down(&hidden_sto_dir_dentry->d_inode->i_sem);
148 +#endif
149
150 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
151 mode = S_IALLUGO;
152 @@ -481,7 +493,11 @@ mini_fo_symlink(inode_t *dir, dentry_t *
153
154 out_lock:
155 /* was: unlock_dir(hidden_sto_dir_dentry); */
156 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
157 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
158 +#else
159 up(&hidden_sto_dir_dentry->d_inode->i_sem);
160 +#endif
161 dput(hidden_sto_dir_dentry);
162
163 dput(hidden_sto_dentry);
164 @@ -524,7 +540,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
165
166 /* was:hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
167 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
168 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
169 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
170 +#else
171 down(&hidden_sto_dir_dentry->d_inode->i_sem);
172 +#endif
173
174 /* avoid destroying the hidden inode if the file is in use */
175 dget(hidden_sto_dentry);
176 @@ -572,7 +592,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
177 dentry->d_name.len);
178 }
179 /* was: unlock_dir(hidden_sto_dir_dentry); */
180 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
181 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
182 +#else
183 up(&hidden_sto_dir_dentry->d_inode->i_sem);
184 +#endif
185 dput(hidden_sto_dir_dentry);
186 goto out;
187 }
188 @@ -602,7 +626,12 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
189
190 /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/
191 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
192 +
193 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
194 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
195 +#else
196 down(&hidden_sto_dir_dentry->d_inode->i_sem);
197 +#endif
198
199 /* avoid destroying the hidden inode if the file is in use */
200 dget(hidden_sto_dentry);
201 @@ -630,7 +659,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
202 dtopd(dentry)->state = NON_EXISTANT;
203
204 /* was: unlock_dir(hidden_sto_dir_dentry); */
205 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
206 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
207 +#else
208 up(&hidden_sto_dir_dentry->d_inode->i_sem);
209 +#endif
210 dput(hidden_sto_dir_dentry);
211
212 goto out;
213 @@ -641,7 +674,12 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
214
215 /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/
216 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
217 +
218 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
219 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
220 +#else
221 down(&hidden_sto_dir_dentry->d_inode->i_sem);
222 +#endif
223
224 /* avoid destroying the hidden inode if the file is in use */
225 dget(hidden_sto_dentry);
226 @@ -668,7 +706,12 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
227 dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink;
228 dtopd(dentry)->state = DELETED;
229 /* was: unlock_dir(hidden_sto_dir_dentry); */
230 +
231 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
232 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
233 +#else
234 up(&hidden_sto_dir_dentry->d_inode->i_sem);
235 +#endif
236 dput(hidden_sto_dir_dentry);
237 goto out;
238 }
239 @@ -1294,11 +1337,19 @@ mini_fo_getxattr(struct dentry *dentry,
240 encoded_name = (char *)name;
241 encoded_value = (char *)value;
242
243 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
244 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
245 +#else
246 down(&hidden_dentry->d_inode->i_sem);
247 +#endif
248 /* lock_kernel() already done by caller. */
249 err = hidden_dentry->d_inode->i_op->getxattr(hidden_dentry, encoded_name, encoded_value, size);
250 /* unlock_kernel() will be done by caller. */
251 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
252 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
253 +#else
254 up(&hidden_dentry->d_inode->i_sem);
255 +#endif
256 }
257 return err;
258 }
259 @@ -1340,11 +1391,19 @@ mini_fo_setxattr(struct dentry *dentry,
260 encoded_name = (char *)name;
261 encoded_value = (char *)value;
262
263 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
264 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
265 +#else
266 down(&hidden_dentry->d_inode->i_sem);
267 +#endif
268 /* lock_kernel() already done by caller. */
269 err = hidden_dentry->d_inode->i_op->setxattr(hidden_dentry, encoded_name, encoded_value, size, flags);
270 /* unlock_kernel() will be done by caller. */
271 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
272 + mutex_unlock(&hidden_dentry->d_inode->i_mutex);
273 +#else
274 up(&hidden_dentry->d_inode->i_sem);
275 +#endif
276 }
277 return err;
278 }
279 @@ -1372,11 +1431,19 @@ mini_fo_removexattr(struct dentry *dentr
280 if (hidden_dentry->d_inode->i_op->removexattr) {
281 encoded_name = (char *)name;
282
283 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
284 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
285 +#else
286 down(&hidden_dentry->d_inode->i_sem);
287 +#endif
288 /* lock_kernel() already done by caller. */
289 err = hidden_dentry->d_inode->i_op->removexattr(hidden_dentry, encoded_name);
290 /* unlock_kernel() will be done by caller. */
291 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
292 + mutex_unlock(&hidden_dentry->d_inode->i_mutex);
293 +#else
294 up(&hidden_dentry->d_inode->i_sem);
295 +#endif
296 }
297 return err;
298 }
299 @@ -1403,11 +1470,20 @@ mini_fo_listxattr(struct dentry *dentry,
300
301 if (hidden_dentry->d_inode->i_op->listxattr) {
302 encoded_list = list;
303 +
304 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
305 + mutex_lock(&hidden_dentry->d_inode->i_mutex);
306 +#else
307 down(&hidden_dentry->d_inode->i_sem);
308 +#endif
309 /* lock_kernel() already done by caller. */
310 err = hidden_dentry->d_inode->i_op->listxattr(hidden_dentry, encoded_list, size);
311 /* unlock_kernel() will be done by caller. */
312 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
313 + mutex_unlock(&hidden_dentry->d_inode->i_mutex);
314 +#else
315 up(&hidden_dentry->d_inode->i_sem);
316 +#endif
317 }
318 return err;
319 }
320 --- a/meta.c
321 +++ b/meta.c
322 @@ -650,9 +650,20 @@ int meta_sync_d_list(dentry_t *dentry, i
323 struct iattr newattrs;
324 newattrs.ia_size = 0;
325 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
326 +
327 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
328 + mutex_lock(&meta_dentry->d_inode->i_mutex);
329 +#else
330 down(&meta_dentry->d_inode->i_sem);
331 +#endif
332 err = notify_change(meta_dentry, &newattrs);
333 +
334 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
335 + mutex_unlock(&meta_dentry->d_inode->i_mutex);
336 +#else
337 up(&meta_dentry->d_inode->i_sem);
338 +#endif
339 +
340 if(err || meta_dentry->d_inode->i_size != 0) {
341 printk(KERN_CRIT "mini_fo: meta_sync_d_list: \
342 ERROR truncating meta file.\n");
343 @@ -780,9 +791,19 @@ int meta_sync_r_list(dentry_t *dentry, i
344 struct iattr newattrs;
345 newattrs.ia_size = 0;
346 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
347 +
348 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
349 + mutex_lock(&meta_dentry->d_inode->i_mutex);
350 +#else
351 down(&meta_dentry->d_inode->i_sem);
352 +#endif
353 err = notify_change(meta_dentry, &newattrs);
354 +
355 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
356 + mutex_unlock(&meta_dentry->d_inode->i_mutex);
357 +#else
358 up(&meta_dentry->d_inode->i_sem);
359 +#endif
360 if(err || meta_dentry->d_inode->i_size != 0) {
361 printk(KERN_CRIT "mini_fo: meta_sync_r_list: \
362 ERROR truncating meta file.\n");
363 --- a/mini_fo.h
364 +++ b/mini_fo.h
365 @@ -433,6 +433,33 @@ fist_copy_attr_all(inode_t *dest, const
366
367 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
368 /* copied from linux/fs.h */
369 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
370 +static inline void double_lock(struct dentry *d1, struct dentry *d2)
371 +{
372 + struct mutex *m1 = &d1->d_inode->i_mutex;
373 + struct mutex *m2 = &d2->d_inode->i_mutex;
374 + if (m1 != m2) {
375 + if ((unsigned long) m1 < (unsigned long) m2) {
376 + struct mutex *tmp = m2;
377 + m2 = m1; m1 = tmp;
378 + }
379 + mutex_lock(m1);
380 + }
381 + mutex_lock(m2);
382 +}
383 +
384 +static inline void double_unlock(struct dentry *d1, struct dentry *d2)
385 +{
386 + struct mutex *m1 = &d1->d_inode->i_mutex;
387 + struct mutex *m2 = &d2->d_inode->i_mutex;
388 + mutex_unlock(m1);
389 + if (m1 != m2)
390 + mutex_unlock(m2);
391 + dput(d1);
392 + dput(d2);
393 +}
394 +
395 +#else
396 static inline void double_down(struct semaphore *s1, struct semaphore *s2)
397 {
398 if (s1 != s2) {
399 @@ -463,8 +490,8 @@ static inline void double_unlock(struct
400 dput(d1);
401 dput(d2);
402 }
403 -
404 -#endif
405 +#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */
406 +#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
407 #endif /* __KERNEL__ */
408
409 /*
410 --- a/mmap.c
411 +++ b/mmap.c
412 @@ -478,7 +478,11 @@ mini_fo_commit_write(file_t *file, page_
413 if (ftopd(file) != NULL)
414 hidden_file = ftohf(file);
415
416 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
417 + mutex_lock(&hidden_inode->i_mutex);
418 +#else
419 down(&hidden_inode->i_sem);
420 +#endif
421 /* find lower page (returns a locked page) */
422 hidden_page = grab_cache_page(hidden_inode->i_mapping, page->index);
423 if (!hidden_page)
424 @@ -556,7 +560,12 @@ mini_fo_commit_write(file_t *file, page_
425 ClearPageUptodate(page);
426 else
427 SetPageUptodate(page);
428 +
429 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
430 + mutex_unlock(&hidden_inode->i_mutex);
431 +#else
432 up(&hidden_inode->i_sem);
433 +#endif
434 print_exit_status(err);
435 return err; /* assume all is ok */
436 }
437 --- a/state.c
438 +++ b/state.c
439 @@ -44,7 +44,12 @@ int create_sto_reg_file(dentry_t *dentry
440
441 /* lock parent */
442 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
443 +
444 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
445 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
446 +#else
447 down(&hidden_sto_dir_dentry->d_inode->i_sem);
448 +#endif
449
450 err = PTR_ERR(hidden_sto_dir_dentry);
451 if (IS_ERR(hidden_sto_dir_dentry))
452 @@ -97,7 +102,11 @@ int create_sto_reg_file(dentry_t *dentry
453 hidden_sto_dir_dentry->d_inode);
454
455 out_lock:
456 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
457 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
458 +#else
459 up(&hidden_sto_dir_dentry->d_inode->i_sem);
460 +#endif
461 dput(hidden_sto_dir_dentry);
462 out:
463 return err;
464 @@ -130,7 +139,12 @@ n");
465
466 /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
467 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
468 +
469 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
470 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
471 +#else
472 down(&hidden_sto_dir_dentry->d_inode->i_sem);
473 +#endif
474
475 err = PTR_ERR(hidden_sto_dir_dentry);
476 if (IS_ERR(hidden_sto_dir_dentry))
477 @@ -184,7 +198,11 @@ n");
478
479 out_lock:
480 /* was: unlock_dir(hidden_sto_dir_dentry); */
481 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
482 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
483 +#else
484 up(&hidden_sto_dir_dentry->d_inode->i_sem);
485 +#endif
486 dput(hidden_sto_dir_dentry);
487 out:
488 return err;
489 @@ -217,7 +235,12 @@ int create_sto_nod(dentry_t *dentry, int
490
491 /* lock parent */
492 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
493 +
494 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
495 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
496 +#else
497 down(&hidden_sto_dir_dentry->d_inode->i_sem);
498 +#endif
499
500 err = PTR_ERR(hidden_sto_dir_dentry);
501 if (IS_ERR(hidden_sto_dir_dentry))
502 @@ -260,7 +283,11 @@ int create_sto_nod(dentry_t *dentry, int
503 fist_copy_attr_timesizes(dir, hidden_sto_dir_dentry->d_inode);
504
505 out_lock:
506 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
507 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
508 +#else
509 up(&hidden_sto_dir_dentry->d_inode->i_sem);
510 +#endif
511 dput(hidden_sto_dir_dentry);
512 out:
513 return err;
514 @@ -314,7 +341,12 @@ int nondir_unmod_to_mod(dentry_t *dentry
515
516 /* lock parent */
517 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
518 +
519 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
520 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
521 +#else
522 down(&hidden_sto_dir_dentry->d_inode->i_sem);
523 +#endif
524
525 err = PTR_ERR(hidden_sto_dir_dentry);
526 if (IS_ERR(hidden_sto_dir_dentry))
527 @@ -365,7 +397,12 @@ int nondir_unmod_to_mod(dentry_t *dentry
528 if((cp_flag == 1) && S_ISREG(dentry->d_inode->i_mode)) {
529
530 /* unlock first */
531 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
532 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
533 +#else
534 up(&hidden_sto_dir_dentry->d_inode->i_sem);
535 +#endif
536 +
537 dput(hidden_sto_dir_dentry);
538
539 tgt_dentry = dtohd2(dentry);
540 @@ -383,7 +420,11 @@ int nondir_unmod_to_mod(dentry_t *dentry
541 }
542
543 out_lock:
544 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
545 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
546 +#else
547 up(&hidden_sto_dir_dentry->d_inode->i_sem);
548 +#endif
549 dput(hidden_sto_dir_dentry);
550 out:
551 return err;
552 @@ -420,7 +461,12 @@ int nondir_creat_to_del(dentry_t *dentry
553
554 /* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/
555 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
556 +
557 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
558 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
559 +#else
560 down(&hidden_sto_dir_dentry->d_inode->i_sem);
561 +#endif
562
563 /* avoid destroying the hidden inode if the file is in use */
564 dget(hidden_sto_dentry);
565 @@ -435,7 +481,11 @@ int nondir_creat_to_del(dentry_t *dentry
566 dtost(dentry) = NON_EXISTANT;
567
568 /* was: unlock_dir(hidden_sto_dir_dentry); */
569 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
570 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
571 +#else
572 up(&hidden_sto_dir_dentry->d_inode->i_sem);
573 +#endif
574 dput(hidden_sto_dir_dentry);
575
576 out:
577 @@ -464,7 +514,12 @@ int nondir_mod_to_del(dentry_t *dentry)
578
579 /* was hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
580 hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
581 +
582 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
583 + mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
584 +#else
585 down(&hidden_sto_dir_dentry->d_inode->i_sem);
586 +#endif
587
588 /* avoid destroying the hidden inode if the file is in use */
589 dget(hidden_sto_dentry);
590 @@ -488,7 +543,11 @@ int nondir_mod_to_del(dentry_t *dentry)
591 dentry->d_name.len);
592
593 /* was: unlock_dir(hidden_sto_dir_dentry); */
594 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
595 + mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
596 +#else
597 up(&hidden_sto_dir_dentry->d_inode->i_sem);
598 +#endif
599 dput(hidden_sto_dir_dentry);
600
601 out:
602