summaryrefslogtreecommitdiffstats
path: root/openwrt/target/linux/package/mini_fo/patches/102-mutex_change.patch
blob: 4dec47bf5e5025ffc9865cb1f7e1f35767f2cb52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
From:  <mk@mary.denx.de>
Date: Tue, 24 Jan 2006 14:09:21 +0000 (+0100)
Subject:     Support for new mutex infrastructure
X-Git-Url: http://www.denx.de/cgi-bin/gitweb.cgi?p=mini_fo.git;a=commitdiff;h=1dcc028729060ea83ea662155634b33ae8e2c493

  Support for new mutex infrastructure
  (7892f2f48d165a34b0b8130c8a195dfd807b8cb6)
---

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-01-24  Markus Klotzbuecher  <mk@mary.denx.de>
+
+	* Add tons of ugly ifdefs to Ed L. Cashin's mutex patch to
+          retain backwards compatibility.
+	
+2006-01-24  Ed L. Cashin <ecashin@coraid.com>
+
+	* Support for the new mutex infrastructure
+	(7892f2f48d165a34b0b8130c8a195dfd807b8cb6)
+
 2005-10-15  Markus Klotzbuecher  <mk@localhost.localdomain>
 
 	* Bugfix for a serious memory leak in mini_fo_follow_link.
--- a/aux.c
+++ b/aux.c
@@ -435,8 +435,11 @@ int build_sto_structure(dentry_t *dir, d
 
 	/* was:	hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_sto_dir_dentry->d_inode->i_sem);
-
+#endif
 	/* lets be safe */
 	if(dtohd2(dir) != hidden_sto_dir_dentry) {
 		printk(KERN_CRIT "mini_fo: build_sto_structure: invalid parameter or meta data corruption [2].\n");
@@ -457,7 +460,11 @@ int build_sto_structure(dentry_t *dir, d
 	if(err) {
 		printk(KERN_CRIT "mini_fo: build_sto_structure: failed to create storage dir [1].\n");
 		/* was: unlock_dir(dir); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&dir->d_inode->i_mutex);
+#else
 		up(&dir->d_inode->i_sem);
+#endif
 		dput(dir);
 		return err;
 	}
@@ -466,7 +473,11 @@ int build_sto_structure(dentry_t *dir, d
 	if(!dtohd2(dentry)->d_inode) {
 		printk(KERN_CRIT "mini_fo: build_sto_structure: failed to create storage dir [2].\n");
 		/* was: unlock_dir(dir); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&dir->d_inode->i_mutex);
+#else
 		up(&dir->d_inode->i_sem);
+#endif
 		dput(dir);
 		return 1;
 	}
@@ -485,7 +496,11 @@ int build_sto_structure(dentry_t *dir, d
 				 hidden_sto_dir_dentry->d_inode);
 	dir->d_inode->i_nlink++;
 	/* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_sto_dir_dentry);
 	return 0;
 }
--- a/file.c
+++ b/file.c
@@ -613,18 +613,34 @@ mini_fo_fsync(file_t *file, dentry_t *de
 	if ((hidden_file = ftohf(file)) != NULL) {
 		hidden_dentry = dtohd(dentry);
 		if (hidden_file->f_op && hidden_file->f_op->fsync) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+			mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 			down(&hidden_dentry->d_inode->i_sem);
+#endif
 			err1 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+			mutex_unlock(&hidden_dentry->d_inode->i_mutex);
+#else
 			up(&hidden_dentry->d_inode->i_sem);
+#endif
 		}
 	}
 
 	if ((hidden_file = ftohf2(file)) != NULL) {
 		hidden_dentry = dtohd2(dentry);
 		if (hidden_file->f_op && hidden_file->f_op->fsync) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+			mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 			down(&hidden_dentry->d_inode->i_sem);
+#endif
 			err2 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+			mutex_unlock(&hidden_dentry->d_inode->i_mutex);
+#else
 			up(&hidden_dentry->d_inode->i_sem);
+#endif
 		}
 	}
 	else
--- a/inode.c
+++ b/inode.c
@@ -355,7 +355,11 @@ mini_fo_link(dentry_t *old_dentry, inode
 
 	/* was: hidden_dir_dentry = lock_parent(hidden_new_dentry); */
 	hidden_dir_dentry = dget(hidden_new_dentry->d_parent);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_dir_dentry->d_inode->i_sem);
+#endif
 
 	err = vfs_link(hidden_old_dentry,
 		       hidden_dir_dentry->d_inode,
@@ -374,7 +378,11 @@ mini_fo_link(dentry_t *old_dentry, inode
 
  out_lock:
 	/* was: unlock_dir(hidden_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_dir_dentry);
 
 	dput(hidden_new_dentry);
@@ -452,7 +460,11 @@ mini_fo_symlink(inode_t *dir, dentry_t *
 	dget(hidden_sto_dentry);
 	/* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 	mode = S_IALLUGO;
@@ -481,7 +493,11 @@ mini_fo_symlink(inode_t *dir, dentry_t *
 	
  out_lock:
         /* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_sto_dir_dentry);
 
         dput(hidden_sto_dentry);
@@ -524,7 +540,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
 
 		/* was:hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
 		hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 		/* avoid destroying the hidden inode if the file is in use */
 		dget(hidden_sto_dentry);
@@ -572,7 +592,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
 					 dentry->d_name.len);
 		}
 		/* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 		dput(hidden_sto_dir_dentry);
 		goto out;
 	}
@@ -602,7 +626,12 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
 
 		/* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/
 		hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 		/* avoid destroying the hidden inode if the file is in use */
 		dget(hidden_sto_dentry);
@@ -630,7 +659,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
 		dtopd(dentry)->state = NON_EXISTANT;
 
 		/* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 		dput(hidden_sto_dir_dentry);
 
 		goto out;
@@ -641,7 +674,12 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
 
 		/* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/
 		hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 		/* avoid destroying the hidden inode if the file is in use */
 		dget(hidden_sto_dentry);
@@ -668,7 +706,12 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
 		dentry->d_inode->i_nlink = itohi2(dentry->d_inode)->i_nlink;
 		dtopd(dentry)->state = DELETED;
 		/* was: unlock_dir(hidden_sto_dir_dentry); */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 		dput(hidden_sto_dir_dentry);
 		goto out;
 	}
@@ -1294,11 +1337,19 @@ mini_fo_getxattr(struct dentry *dentry, 
 		encoded_name = (char *)name;
 		encoded_value = (char *)value;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_dentry->d_inode->i_sem);
+#endif
 		/* lock_kernel() already done by caller. */
 		err = hidden_dentry->d_inode->i_op->getxattr(hidden_dentry, encoded_name, encoded_value, size);
 		/* unlock_kernel() will be done by caller. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_dentry->d_inode->i_sem);
+#endif
 	}
 	return err;
 }
@@ -1340,11 +1391,19 @@ mini_fo_setxattr(struct dentry *dentry, 
 		encoded_name = (char *)name;
 		encoded_value = (char *)value;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_dentry->d_inode->i_sem);
+#endif
 		/* lock_kernel() already done by caller. */
 		err = hidden_dentry->d_inode->i_op->setxattr(hidden_dentry, encoded_name, encoded_value, size, flags);
 		/* unlock_kernel() will be done by caller. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_dentry->d_inode->i_sem);
+#endif
 	}
 	return err;
 }
@@ -1372,11 +1431,19 @@ mini_fo_removexattr(struct dentry *dentr
 	if (hidden_dentry->d_inode->i_op->removexattr) {
 		encoded_name = (char *)name;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_dentry->d_inode->i_sem);
+#endif
 		/* lock_kernel() already done by caller. */
 		err = hidden_dentry->d_inode->i_op->removexattr(hidden_dentry, encoded_name);
 		/* unlock_kernel() will be done by caller. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_dentry->d_inode->i_sem);
+#endif
 	}
 	return err;
 }
@@ -1403,11 +1470,20 @@ mini_fo_listxattr(struct dentry *dentry,
 
 	if (hidden_dentry->d_inode->i_op->listxattr) {
 		encoded_list = list;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&hidden_dentry->d_inode->i_mutex);
+#else
 		down(&hidden_dentry->d_inode->i_sem);
+#endif
 		/* lock_kernel() already done by caller. */
 		err = hidden_dentry->d_inode->i_op->listxattr(hidden_dentry, encoded_list, size);
 		/* unlock_kernel() will be done by caller. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_dentry->d_inode->i_sem);
+#endif
 	}
 	return err;
 }
--- a/meta.c
+++ b/meta.c
@@ -650,9 +650,20 @@ int meta_sync_d_list(dentry_t *dentry, i
 		struct iattr newattrs;
                 newattrs.ia_size = 0;
                 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&meta_dentry->d_inode->i_mutex);
+#else
                 down(&meta_dentry->d_inode->i_sem);
+#endif
                 err = notify_change(meta_dentry, &newattrs);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&meta_dentry->d_inode->i_mutex);
+#else
                 up(&meta_dentry->d_inode->i_sem);
+#endif
+
                 if(err || meta_dentry->d_inode->i_size != 0) {
                         printk(KERN_CRIT "mini_fo: meta_sync_d_list: \
                                           ERROR truncating meta file.\n");
@@ -780,9 +791,19 @@ int meta_sync_r_list(dentry_t *dentry, i
 		struct iattr newattrs;
                 newattrs.ia_size = 0;
                 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_lock(&meta_dentry->d_inode->i_mutex);
+#else
                 down(&meta_dentry->d_inode->i_sem);
+#endif
                 err = notify_change(meta_dentry, &newattrs);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&meta_dentry->d_inode->i_mutex);
+#else
                 up(&meta_dentry->d_inode->i_sem);
+#endif
                 if(err || meta_dentry->d_inode->i_size != 0) {
                         printk(KERN_CRIT "mini_fo: meta_sync_r_list: \
                                           ERROR truncating meta file.\n");
--- a/mini_fo.h
+++ b/mini_fo.h
@@ -433,6 +433,33 @@ fist_copy_attr_all(inode_t *dest, const 
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 /* copied from linux/fs.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+static inline void double_lock(struct dentry *d1, struct dentry *d2)
+{
+	struct mutex *m1 = &d1->d_inode->i_mutex;
+	struct mutex *m2 = &d2->d_inode->i_mutex;
+	if (m1 != m2) {
+		if ((unsigned long) m1 < (unsigned long) m2) {
+			struct mutex *tmp = m2;
+			m2 = m1; m1 = tmp;
+		}
+		mutex_lock(m1);
+	}
+	mutex_lock(m2);
+}
+
+static inline void double_unlock(struct dentry *d1, struct dentry *d2)
+{
+	struct mutex *m1 = &d1->d_inode->i_mutex;
+	struct mutex *m2 = &d2->d_inode->i_mutex;
+	mutex_unlock(m1);
+	if (m1 != m2)
+		mutex_unlock(m2);
+	dput(d1);
+	dput(d2);
+}
+
+#else
 static inline void double_down(struct semaphore *s1, struct semaphore *s2)
 {
         if (s1 != s2) {
@@ -463,8 +490,8 @@ static inline void double_unlock(struct 
         dput(d1);
         dput(d2);
 }
-
-#endif
+#endif   /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */
+#endif  /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
 #endif /* __KERNEL__ */
 
 /*
--- a/mmap.c
+++ b/mmap.c
@@ -478,7 +478,11 @@ mini_fo_commit_write(file_t *file, page_
 	if (ftopd(file) != NULL)
 		hidden_file = ftohf(file);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_inode->i_mutex);
+#else
 	down(&hidden_inode->i_sem);
+#endif
 	/* find lower page (returns a locked page) */
 	hidden_page = grab_cache_page(hidden_inode->i_mapping, page->index);
 	if (!hidden_page)
@@ -556,7 +560,12 @@ mini_fo_commit_write(file_t *file, page_
 		ClearPageUptodate(page);
 	else
 		SetPageUptodate(page);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_inode->i_mutex);
+#else
 	up(&hidden_inode->i_sem);
+#endif
 	print_exit_status(err);
 	return err;			/* assume all is ok */
 }
--- a/state.c
+++ b/state.c
@@ -44,7 +44,12 @@ int create_sto_reg_file(dentry_t *dentry
 
 	/* lock parent */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
         down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 	err = PTR_ERR(hidden_sto_dir_dentry);
         if (IS_ERR(hidden_sto_dir_dentry))
@@ -97,7 +102,11 @@ int create_sto_reg_file(dentry_t *dentry
 				 hidden_sto_dir_dentry->d_inode);
 
  out_lock:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
         dput(hidden_sto_dir_dentry);
  out:
 	return err;
@@ -130,7 +139,12 @@ n");
 
 	/* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 	err = PTR_ERR(hidden_sto_dir_dentry);
 	if (IS_ERR(hidden_sto_dir_dentry))
@@ -184,7 +198,11 @@ n");
 
  out_lock:
 	/* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_sto_dir_dentry);
  out:
 	return err;
@@ -217,7 +235,12 @@ int create_sto_nod(dentry_t *dentry, int
 	
 	/* lock parent */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	
 	err = PTR_ERR(hidden_sto_dir_dentry);
 	if (IS_ERR(hidden_sto_dir_dentry))
@@ -260,7 +283,11 @@ int create_sto_nod(dentry_t *dentry, int
 	fist_copy_attr_timesizes(dir, hidden_sto_dir_dentry->d_inode);
 
  out_lock:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_sto_dir_dentry);
  out:
 	return err;
@@ -314,7 +341,12 @@ int nondir_unmod_to_mod(dentry_t *dentry
 
 	/* lock parent */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
         down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 
 	err = PTR_ERR(hidden_sto_dir_dentry);
         if (IS_ERR(hidden_sto_dir_dentry))
@@ -365,7 +397,12 @@ int nondir_unmod_to_mod(dentry_t *dentry
 	if((cp_flag == 1) && S_ISREG(dentry->d_inode->i_mode)) {
 
 		/* unlock first */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+		mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 		up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
+
 		dput(hidden_sto_dir_dentry);
 
 		tgt_dentry = dtohd2(dentry);
@@ -383,7 +420,11 @@ int nondir_unmod_to_mod(dentry_t *dentry
 	}
 
  out_lock:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
         dput(hidden_sto_dir_dentry);
  out:
 	return err;
@@ -420,7 +461,12 @@ int nondir_creat_to_del(dentry_t *dentry
 	
 	/* was: hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry);*/
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	
 	/* avoid destroying the hidden inode if the file is in use */
 	dget(hidden_sto_dentry);
@@ -435,7 +481,11 @@ int nondir_creat_to_del(dentry_t *dentry
 	dtost(dentry) = NON_EXISTANT;
 	
 	/* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_sto_dir_dentry);
 	
  out:
@@ -464,7 +514,12 @@ int nondir_mod_to_del(dentry_t *dentry)
 	
 	/* was hidden_sto_dir_dentry = lock_parent(hidden_sto_dentry); */
 	hidden_sto_dir_dentry = dget(hidden_sto_dentry->d_parent);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	down(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	
 	/* avoid destroying the hidden inode if the file is in use */
 	dget(hidden_sto_dentry);
@@ -488,7 +543,11 @@ int nondir_mod_to_del(dentry_t *dentry)
 			 dentry->d_name.len);
 	
 	/* was: unlock_dir(hidden_sto_dir_dentry); */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+	mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+#else
 	up(&hidden_sto_dir_dentry->d_inode->i_sem);
+#endif
 	dput(hidden_sto_dir_dentry);
 
  out: