diff options
-rw-r--r-- | fs/jffs2/README.Locking | 22 | ||||
-rw-r--r-- | fs/jffs2/debug.c | 8 | ||||
-rw-r--r-- | fs/jffs2/dir.c | 58 | ||||
-rw-r--r-- | fs/jffs2/erase.c | 42 | ||||
-rw-r--r-- | fs/jffs2/file.c | 16 | ||||
-rw-r--r-- | fs/jffs2/fs.c | 28 | ||||
-rw-r--r-- | fs/jffs2/gc.c | 32 | ||||
-rw-r--r-- | fs/jffs2/jffs2_fs_i.h | 2 | ||||
-rw-r--r-- | fs/jffs2/jffs2_fs_sb.h | 6 | ||||
-rw-r--r-- | fs/jffs2/nodemgmt.c | 18 | ||||
-rw-r--r-- | fs/jffs2/readinode.c | 23 | ||||
-rw-r--r-- | fs/jffs2/super.c | 14 | ||||
-rw-r--r-- | fs/jffs2/wbuf.c | 16 | ||||
-rw-r--r-- | fs/jffs2/write.c | 50 |
14 files changed, 168 insertions, 167 deletions
diff --git a/fs/jffs2/README.Locking b/fs/jffs2/README.Locking index d14d5a4dc5ac..3ea36554107f 100644 --- a/fs/jffs2/README.Locking +++ b/fs/jffs2/README.Locking | |||
@@ -14,7 +14,7 @@ be fairly close. | |||
14 | alloc_sem | 14 | alloc_sem |
15 | --------- | 15 | --------- |
16 | 16 | ||
17 | The alloc_sem is a per-filesystem semaphore, used primarily to ensure | 17 | The alloc_sem is a per-filesystem mutex, used primarily to ensure |
18 | contiguous allocation of space on the medium. It is automatically | 18 | contiguous allocation of space on the medium. It is automatically |
19 | obtained during space allocations (jffs2_reserve_space()) and freed | 19 | obtained during space allocations (jffs2_reserve_space()) and freed |
20 | upon write completion (jffs2_complete_reservation()). Note that | 20 | upon write completion (jffs2_complete_reservation()). Note that |
@@ -41,10 +41,10 @@ if the wbuf is currently holding any data is permitted, though. | |||
41 | Ordering constraints: See f->sem. | 41 | Ordering constraints: See f->sem. |
42 | 42 | ||
43 | 43 | ||
44 | File Semaphore f->sem | 44 | File Mutex f->sem |
45 | --------------------- | 45 | --------------------- |
46 | 46 | ||
47 | This is the JFFS2-internal equivalent of the inode semaphore i->i_sem. | 47 | This is the JFFS2-internal equivalent of the inode mutex i->i_sem. |
48 | It protects the contents of the jffs2_inode_info private inode data, | 48 | It protects the contents of the jffs2_inode_info private inode data, |
49 | including the linked list of node fragments (but see the notes below on | 49 | including the linked list of node fragments (but see the notes below on |
50 | erase_completion_lock), etc. | 50 | erase_completion_lock), etc. |
@@ -60,14 +60,14 @@ lead to deadlock, unless we played games with unlocking the i_sem | |||
60 | before calling the space allocation functions. | 60 | before calling the space allocation functions. |
61 | 61 | ||
62 | Instead of playing such games, we just have an extra internal | 62 | Instead of playing such games, we just have an extra internal |
63 | semaphore, which is obtained by the garbage collection code and also | 63 | mutex, which is obtained by the garbage collection code and also |
64 | by the normal file system code _after_ allocation of space. | 64 | by the normal file system code _after_ allocation of space. |
65 | 65 | ||
66 | Ordering constraints: | 66 | Ordering constraints: |
67 | 67 | ||
68 | 1. Never attempt to allocate space or lock alloc_sem with | 68 | 1. Never attempt to allocate space or lock alloc_sem with |
69 | any f->sem held. | 69 | any f->sem held. |
70 | 2. Never attempt to lock two file semaphores in one thread. | 70 | 2. Never attempt to lock two file mutexes in one thread. |
71 | No ordering rules have been made for doing so. | 71 | No ordering rules have been made for doing so. |
72 | 72 | ||
73 | 73 | ||
@@ -86,8 +86,8 @@ a simple spin_lock() rather than spin_lock_bh(). | |||
86 | 86 | ||
87 | Note that the per-inode list of physical nodes (f->nodes) is a special | 87 | Note that the per-inode list of physical nodes (f->nodes) is a special |
88 | case. Any changes to _valid_ nodes (i.e. ->flash_offset & 1 == 0) in | 88 | case. Any changes to _valid_ nodes (i.e. ->flash_offset & 1 == 0) in |
89 | the list are protected by the file semaphore f->sem. But the erase | 89 | the list are protected by the file mutex f->sem. But the erase code |
90 | code may remove _obsolete_ nodes from the list while holding only the | 90 | may remove _obsolete_ nodes from the list while holding only the |
91 | erase_completion_lock. So you can walk the list only while holding the | 91 | erase_completion_lock. So you can walk the list only while holding the |
92 | erase_completion_lock, and can drop the lock temporarily mid-walk as | 92 | erase_completion_lock, and can drop the lock temporarily mid-walk as |
93 | long as the pointer you're holding is to a _valid_ node, not an | 93 | long as the pointer you're holding is to a _valid_ node, not an |
@@ -124,10 +124,10 @@ Ordering constraints: | |||
124 | erase_free_sem | 124 | erase_free_sem |
125 | -------------- | 125 | -------------- |
126 | 126 | ||
127 | This semaphore is only used by the erase code which frees obsolete | 127 | This mutex is only used by the erase code which frees obsolete node |
128 | node references and the jffs2_garbage_collect_deletion_dirent() | 128 | references and the jffs2_garbage_collect_deletion_dirent() function. |
129 | function. The latter function on NAND flash must read _obsolete_ nodes | 129 | The latter function on NAND flash must read _obsolete_ nodes to |
130 | to determine whether the 'deletion dirent' under consideration can be | 130 | determine whether the 'deletion dirent' under consideration can be |
131 | discarded or whether it is still required to show that an inode has | 131 | discarded or whether it is still required to show that an inode has |
132 | been unlinked. Because reading from the flash may sleep, the | 132 | been unlinked. Because reading from the flash may sleep, the |
133 | erase_completion_lock cannot be held, so an alternative, more | 133 | erase_completion_lock cannot be held, so an alternative, more |
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index 3a32c64ed497..660793107e92 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c | |||
@@ -62,9 +62,9 @@ __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, | |||
62 | void | 62 | void |
63 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | 63 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) |
64 | { | 64 | { |
65 | down(&f->sem); | 65 | mutex_lock(&f->sem); |
66 | __jffs2_dbg_fragtree_paranoia_check_nolock(f); | 66 | __jffs2_dbg_fragtree_paranoia_check_nolock(f); |
67 | up(&f->sem); | 67 | mutex_unlock(&f->sem); |
68 | } | 68 | } |
69 | 69 | ||
70 | void | 70 | void |
@@ -532,9 +532,9 @@ __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c) | |||
532 | void | 532 | void |
533 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) | 533 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) |
534 | { | 534 | { |
535 | down(&f->sem); | 535 | mutex_lock(&f->sem); |
536 | jffs2_dbg_dump_fragtree_nolock(f); | 536 | jffs2_dbg_dump_fragtree_nolock(f); |
537 | up(&f->sem); | 537 | mutex_unlock(&f->sem); |
538 | } | 538 | } |
539 | 539 | ||
540 | void | 540 | void |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index f948f7e6ec82..c63e7a96af0d 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -86,7 +86,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
86 | dir_f = JFFS2_INODE_INFO(dir_i); | 86 | dir_f = JFFS2_INODE_INFO(dir_i); |
87 | c = JFFS2_SB_INFO(dir_i->i_sb); | 87 | c = JFFS2_SB_INFO(dir_i->i_sb); |
88 | 88 | ||
89 | down(&dir_f->sem); | 89 | mutex_lock(&dir_f->sem); |
90 | 90 | ||
91 | /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */ | 91 | /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */ |
92 | for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) { | 92 | for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) { |
@@ -99,7 +99,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
99 | } | 99 | } |
100 | if (fd) | 100 | if (fd) |
101 | ino = fd->ino; | 101 | ino = fd->ino; |
102 | up(&dir_f->sem); | 102 | mutex_unlock(&dir_f->sem); |
103 | if (ino) { | 103 | if (ino) { |
104 | inode = jffs2_iget(dir_i->i_sb, ino); | 104 | inode = jffs2_iget(dir_i->i_sb, ino); |
105 | if (IS_ERR(inode)) { | 105 | if (IS_ERR(inode)) { |
@@ -146,7 +146,7 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
146 | } | 146 | } |
147 | 147 | ||
148 | curofs=1; | 148 | curofs=1; |
149 | down(&f->sem); | 149 | mutex_lock(&f->sem); |
150 | for (fd = f->dents; fd; fd = fd->next) { | 150 | for (fd = f->dents; fd; fd = fd->next) { |
151 | 151 | ||
152 | curofs++; | 152 | curofs++; |
@@ -166,7 +166,7 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
166 | break; | 166 | break; |
167 | offset++; | 167 | offset++; |
168 | } | 168 | } |
169 | up(&f->sem); | 169 | mutex_unlock(&f->sem); |
170 | out: | 170 | out: |
171 | filp->f_pos = offset; | 171 | filp->f_pos = offset; |
172 | return 0; | 172 | return 0; |
@@ -275,9 +275,9 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de | |||
275 | ret = jffs2_do_link(c, dir_f, f->inocache->ino, type, dentry->d_name.name, dentry->d_name.len, now); | 275 | ret = jffs2_do_link(c, dir_f, f->inocache->ino, type, dentry->d_name.name, dentry->d_name.len, now); |
276 | 276 | ||
277 | if (!ret) { | 277 | if (!ret) { |
278 | down(&f->sem); | 278 | mutex_lock(&f->sem); |
279 | old_dentry->d_inode->i_nlink = ++f->inocache->nlink; | 279 | old_dentry->d_inode->i_nlink = ++f->inocache->nlink; |
280 | up(&f->sem); | 280 | mutex_unlock(&f->sem); |
281 | d_instantiate(dentry, old_dentry->d_inode); | 281 | d_instantiate(dentry, old_dentry->d_inode); |
282 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | 282 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); |
283 | atomic_inc(&old_dentry->d_inode->i_count); | 283 | atomic_inc(&old_dentry->d_inode->i_count); |
@@ -351,7 +351,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
351 | 351 | ||
352 | if (IS_ERR(fn)) { | 352 | if (IS_ERR(fn)) { |
353 | /* Eeek. Wave bye bye */ | 353 | /* Eeek. Wave bye bye */ |
354 | up(&f->sem); | 354 | mutex_unlock(&f->sem); |
355 | jffs2_complete_reservation(c); | 355 | jffs2_complete_reservation(c); |
356 | jffs2_clear_inode(inode); | 356 | jffs2_clear_inode(inode); |
357 | return PTR_ERR(fn); | 357 | return PTR_ERR(fn); |
@@ -361,7 +361,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
361 | f->target = kmalloc(targetlen + 1, GFP_KERNEL); | 361 | f->target = kmalloc(targetlen + 1, GFP_KERNEL); |
362 | if (!f->target) { | 362 | if (!f->target) { |
363 | printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); | 363 | printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); |
364 | up(&f->sem); | 364 | mutex_unlock(&f->sem); |
365 | jffs2_complete_reservation(c); | 365 | jffs2_complete_reservation(c); |
366 | jffs2_clear_inode(inode); | 366 | jffs2_clear_inode(inode); |
367 | return -ENOMEM; | 367 | return -ENOMEM; |
@@ -374,7 +374,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
374 | obsoleted by the first data write | 374 | obsoleted by the first data write |
375 | */ | 375 | */ |
376 | f->metadata = fn; | 376 | f->metadata = fn; |
377 | up(&f->sem); | 377 | mutex_unlock(&f->sem); |
378 | 378 | ||
379 | jffs2_complete_reservation(c); | 379 | jffs2_complete_reservation(c); |
380 | 380 | ||
@@ -406,7 +406,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
406 | } | 406 | } |
407 | 407 | ||
408 | dir_f = JFFS2_INODE_INFO(dir_i); | 408 | dir_f = JFFS2_INODE_INFO(dir_i); |
409 | down(&dir_f->sem); | 409 | mutex_lock(&dir_f->sem); |
410 | 410 | ||
411 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 411 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
412 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); | 412 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); |
@@ -429,7 +429,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
429 | as if it were the final unlink() */ | 429 | as if it were the final unlink() */ |
430 | jffs2_complete_reservation(c); | 430 | jffs2_complete_reservation(c); |
431 | jffs2_free_raw_dirent(rd); | 431 | jffs2_free_raw_dirent(rd); |
432 | up(&dir_f->sem); | 432 | mutex_unlock(&dir_f->sem); |
433 | jffs2_clear_inode(inode); | 433 | jffs2_clear_inode(inode); |
434 | return PTR_ERR(fd); | 434 | return PTR_ERR(fd); |
435 | } | 435 | } |
@@ -442,7 +442,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
442 | one if necessary. */ | 442 | one if necessary. */ |
443 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 443 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
444 | 444 | ||
445 | up(&dir_f->sem); | 445 | mutex_unlock(&dir_f->sem); |
446 | jffs2_complete_reservation(c); | 446 | jffs2_complete_reservation(c); |
447 | 447 | ||
448 | d_instantiate(dentry, inode); | 448 | d_instantiate(dentry, inode); |
@@ -507,7 +507,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
507 | 507 | ||
508 | if (IS_ERR(fn)) { | 508 | if (IS_ERR(fn)) { |
509 | /* Eeek. Wave bye bye */ | 509 | /* Eeek. Wave bye bye */ |
510 | up(&f->sem); | 510 | mutex_unlock(&f->sem); |
511 | jffs2_complete_reservation(c); | 511 | jffs2_complete_reservation(c); |
512 | jffs2_clear_inode(inode); | 512 | jffs2_clear_inode(inode); |
513 | return PTR_ERR(fn); | 513 | return PTR_ERR(fn); |
@@ -516,7 +516,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
516 | obsoleted by the first data write | 516 | obsoleted by the first data write |
517 | */ | 517 | */ |
518 | f->metadata = fn; | 518 | f->metadata = fn; |
519 | up(&f->sem); | 519 | mutex_unlock(&f->sem); |
520 | 520 | ||
521 | jffs2_complete_reservation(c); | 521 | jffs2_complete_reservation(c); |
522 | 522 | ||
@@ -548,7 +548,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
548 | } | 548 | } |
549 | 549 | ||
550 | dir_f = JFFS2_INODE_INFO(dir_i); | 550 | dir_f = JFFS2_INODE_INFO(dir_i); |
551 | down(&dir_f->sem); | 551 | mutex_lock(&dir_f->sem); |
552 | 552 | ||
553 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 553 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
554 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); | 554 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); |
@@ -571,7 +571,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
571 | as if it were the final unlink() */ | 571 | as if it were the final unlink() */ |
572 | jffs2_complete_reservation(c); | 572 | jffs2_complete_reservation(c); |
573 | jffs2_free_raw_dirent(rd); | 573 | jffs2_free_raw_dirent(rd); |
574 | up(&dir_f->sem); | 574 | mutex_unlock(&dir_f->sem); |
575 | jffs2_clear_inode(inode); | 575 | jffs2_clear_inode(inode); |
576 | return PTR_ERR(fd); | 576 | return PTR_ERR(fd); |
577 | } | 577 | } |
@@ -585,7 +585,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
585 | one if necessary. */ | 585 | one if necessary. */ |
586 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 586 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
587 | 587 | ||
588 | up(&dir_f->sem); | 588 | mutex_unlock(&dir_f->sem); |
589 | jffs2_complete_reservation(c); | 589 | jffs2_complete_reservation(c); |
590 | 590 | ||
591 | d_instantiate(dentry, inode); | 591 | d_instantiate(dentry, inode); |
@@ -673,7 +673,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
673 | 673 | ||
674 | if (IS_ERR(fn)) { | 674 | if (IS_ERR(fn)) { |
675 | /* Eeek. Wave bye bye */ | 675 | /* Eeek. Wave bye bye */ |
676 | up(&f->sem); | 676 | mutex_unlock(&f->sem); |
677 | jffs2_complete_reservation(c); | 677 | jffs2_complete_reservation(c); |
678 | jffs2_clear_inode(inode); | 678 | jffs2_clear_inode(inode); |
679 | return PTR_ERR(fn); | 679 | return PTR_ERR(fn); |
@@ -682,7 +682,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
682 | obsoleted by the first data write | 682 | obsoleted by the first data write |
683 | */ | 683 | */ |
684 | f->metadata = fn; | 684 | f->metadata = fn; |
685 | up(&f->sem); | 685 | mutex_unlock(&f->sem); |
686 | 686 | ||
687 | jffs2_complete_reservation(c); | 687 | jffs2_complete_reservation(c); |
688 | 688 | ||
@@ -714,7 +714,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
714 | } | 714 | } |
715 | 715 | ||
716 | dir_f = JFFS2_INODE_INFO(dir_i); | 716 | dir_f = JFFS2_INODE_INFO(dir_i); |
717 | down(&dir_f->sem); | 717 | mutex_lock(&dir_f->sem); |
718 | 718 | ||
719 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 719 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
720 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); | 720 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); |
@@ -740,7 +740,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
740 | as if it were the final unlink() */ | 740 | as if it were the final unlink() */ |
741 | jffs2_complete_reservation(c); | 741 | jffs2_complete_reservation(c); |
742 | jffs2_free_raw_dirent(rd); | 742 | jffs2_free_raw_dirent(rd); |
743 | up(&dir_f->sem); | 743 | mutex_unlock(&dir_f->sem); |
744 | jffs2_clear_inode(inode); | 744 | jffs2_clear_inode(inode); |
745 | return PTR_ERR(fd); | 745 | return PTR_ERR(fd); |
746 | } | 746 | } |
@@ -753,7 +753,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
753 | one if necessary. */ | 753 | one if necessary. */ |
754 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 754 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
755 | 755 | ||
756 | up(&dir_f->sem); | 756 | mutex_unlock(&dir_f->sem); |
757 | jffs2_complete_reservation(c); | 757 | jffs2_complete_reservation(c); |
758 | 758 | ||
759 | d_instantiate(dentry, inode); | 759 | d_instantiate(dentry, inode); |
@@ -780,14 +780,14 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
780 | if (S_ISDIR(new_dentry->d_inode->i_mode)) { | 780 | if (S_ISDIR(new_dentry->d_inode->i_mode)) { |
781 | struct jffs2_full_dirent *fd; | 781 | struct jffs2_full_dirent *fd; |
782 | 782 | ||
783 | down(&victim_f->sem); | 783 | mutex_lock(&victim_f->sem); |
784 | for (fd = victim_f->dents; fd; fd = fd->next) { | 784 | for (fd = victim_f->dents; fd; fd = fd->next) { |
785 | if (fd->ino) { | 785 | if (fd->ino) { |
786 | up(&victim_f->sem); | 786 | mutex_unlock(&victim_f->sem); |
787 | return -ENOTEMPTY; | 787 | return -ENOTEMPTY; |
788 | } | 788 | } |
789 | } | 789 | } |
790 | up(&victim_f->sem); | 790 | mutex_unlock(&victim_f->sem); |
791 | } | 791 | } |
792 | } | 792 | } |
793 | 793 | ||
@@ -816,9 +816,9 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
816 | /* Don't oops if the victim was a dirent pointing to an | 816 | /* Don't oops if the victim was a dirent pointing to an |
817 | inode which didn't exist. */ | 817 | inode which didn't exist. */ |
818 | if (victim_f->inocache) { | 818 | if (victim_f->inocache) { |
819 | down(&victim_f->sem); | 819 | mutex_lock(&victim_f->sem); |
820 | victim_f->inocache->nlink--; | 820 | victim_f->inocache->nlink--; |
821 | up(&victim_f->sem); | 821 | mutex_unlock(&victim_f->sem); |
822 | } | 822 | } |
823 | } | 823 | } |
824 | 824 | ||
@@ -836,11 +836,11 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
836 | if (ret) { | 836 | if (ret) { |
837 | /* Oh shit. We really ought to make a single node which can do both atomically */ | 837 | /* Oh shit. We really ought to make a single node which can do both atomically */ |
838 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); | 838 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); |
839 | down(&f->sem); | 839 | mutex_lock(&f->sem); |
840 | inc_nlink(old_dentry->d_inode); | 840 | inc_nlink(old_dentry->d_inode); |
841 | if (f->inocache) | 841 | if (f->inocache) |
842 | f->inocache->nlink++; | 842 | f->inocache->nlink++; |
843 | up(&f->sem); | 843 | mutex_unlock(&f->sem); |
844 | 844 | ||
845 | printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); | 845 | printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); |
846 | /* Might as well let the VFS know */ | 846 | /* Might as well let the VFS know */ |
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index a1db9180633f..96d9ad56e573 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
@@ -50,14 +50,14 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
50 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); | 50 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); |
51 | if (!instr) { | 51 | if (!instr) { |
52 | printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); | 52 | printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); |
53 | down(&c->erase_free_sem); | 53 | mutex_lock(&c->erase_free_sem); |
54 | spin_lock(&c->erase_completion_lock); | 54 | spin_lock(&c->erase_completion_lock); |
55 | list_move(&jeb->list, &c->erase_pending_list); | 55 | list_move(&jeb->list, &c->erase_pending_list); |
56 | c->erasing_size -= c->sector_size; | 56 | c->erasing_size -= c->sector_size; |
57 | c->dirty_size += c->sector_size; | 57 | c->dirty_size += c->sector_size; |
58 | jeb->dirty_size = c->sector_size; | 58 | jeb->dirty_size = c->sector_size; |
59 | spin_unlock(&c->erase_completion_lock); | 59 | spin_unlock(&c->erase_completion_lock); |
60 | up(&c->erase_free_sem); | 60 | mutex_unlock(&c->erase_free_sem); |
61 | return; | 61 | return; |
62 | } | 62 | } |
63 | 63 | ||
@@ -84,14 +84,14 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
84 | if (ret == -ENOMEM || ret == -EAGAIN) { | 84 | if (ret == -ENOMEM || ret == -EAGAIN) { |
85 | /* Erase failed immediately. Refile it on the list */ | 85 | /* Erase failed immediately. Refile it on the list */ |
86 | D1(printk(KERN_DEBUG "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", jeb->offset, ret)); | 86 | D1(printk(KERN_DEBUG "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", jeb->offset, ret)); |
87 | down(&c->erase_free_sem); | 87 | mutex_lock(&c->erase_free_sem); |
88 | spin_lock(&c->erase_completion_lock); | 88 | spin_lock(&c->erase_completion_lock); |
89 | list_move(&jeb->list, &c->erase_pending_list); | 89 | list_move(&jeb->list, &c->erase_pending_list); |
90 | c->erasing_size -= c->sector_size; | 90 | c->erasing_size -= c->sector_size; |
91 | c->dirty_size += c->sector_size; | 91 | c->dirty_size += c->sector_size; |
92 | jeb->dirty_size = c->sector_size; | 92 | jeb->dirty_size = c->sector_size; |
93 | spin_unlock(&c->erase_completion_lock); | 93 | spin_unlock(&c->erase_completion_lock); |
94 | up(&c->erase_free_sem); | 94 | mutex_unlock(&c->erase_free_sem); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | 97 | ||
@@ -107,7 +107,7 @@ void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
107 | { | 107 | { |
108 | struct jffs2_eraseblock *jeb; | 108 | struct jffs2_eraseblock *jeb; |
109 | 109 | ||
110 | down(&c->erase_free_sem); | 110 | mutex_lock(&c->erase_free_sem); |
111 | 111 | ||
112 | spin_lock(&c->erase_completion_lock); | 112 | spin_lock(&c->erase_completion_lock); |
113 | 113 | ||
@@ -118,7 +118,7 @@ void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
118 | jeb = list_entry(c->erase_complete_list.next, struct jffs2_eraseblock, list); | 118 | jeb = list_entry(c->erase_complete_list.next, struct jffs2_eraseblock, list); |
119 | list_del(&jeb->list); | 119 | list_del(&jeb->list); |
120 | spin_unlock(&c->erase_completion_lock); | 120 | spin_unlock(&c->erase_completion_lock); |
121 | up(&c->erase_free_sem); | 121 | mutex_unlock(&c->erase_free_sem); |
122 | jffs2_mark_erased_block(c, jeb); | 122 | jffs2_mark_erased_block(c, jeb); |
123 | 123 | ||
124 | if (!--count) { | 124 | if (!--count) { |
@@ -139,7 +139,7 @@ void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
139 | jffs2_free_jeb_node_refs(c, jeb); | 139 | jffs2_free_jeb_node_refs(c, jeb); |
140 | list_add(&jeb->list, &c->erasing_list); | 140 | list_add(&jeb->list, &c->erasing_list); |
141 | spin_unlock(&c->erase_completion_lock); | 141 | spin_unlock(&c->erase_completion_lock); |
142 | up(&c->erase_free_sem); | 142 | mutex_unlock(&c->erase_free_sem); |
143 | 143 | ||
144 | jffs2_erase_block(c, jeb); | 144 | jffs2_erase_block(c, jeb); |
145 | 145 | ||
@@ -149,12 +149,12 @@ void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
149 | 149 | ||
150 | /* Be nice */ | 150 | /* Be nice */ |
151 | yield(); | 151 | yield(); |
152 | down(&c->erase_free_sem); | 152 | mutex_lock(&c->erase_free_sem); |
153 | spin_lock(&c->erase_completion_lock); | 153 | spin_lock(&c->erase_completion_lock); |
154 | } | 154 | } |
155 | 155 | ||
156 | spin_unlock(&c->erase_completion_lock); | 156 | spin_unlock(&c->erase_completion_lock); |
157 | up(&c->erase_free_sem); | 157 | mutex_unlock(&c->erase_free_sem); |
158 | done: | 158 | done: |
159 | D1(printk(KERN_DEBUG "jffs2_erase_pending_blocks completed\n")); | 159 | D1(printk(KERN_DEBUG "jffs2_erase_pending_blocks completed\n")); |
160 | } | 160 | } |
@@ -162,11 +162,11 @@ void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
162 | static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 162 | static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) |
163 | { | 163 | { |
164 | D1(printk(KERN_DEBUG "Erase completed successfully at 0x%08x\n", jeb->offset)); | 164 | D1(printk(KERN_DEBUG "Erase completed successfully at 0x%08x\n", jeb->offset)); |
165 | down(&c->erase_free_sem); | 165 | mutex_lock(&c->erase_free_sem); |
166 | spin_lock(&c->erase_completion_lock); | 166 | spin_lock(&c->erase_completion_lock); |
167 | list_move_tail(&jeb->list, &c->erase_complete_list); | 167 | list_move_tail(&jeb->list, &c->erase_complete_list); |
168 | spin_unlock(&c->erase_completion_lock); | 168 | spin_unlock(&c->erase_completion_lock); |
169 | up(&c->erase_free_sem); | 169 | mutex_unlock(&c->erase_free_sem); |
170 | /* Ensure that kupdated calls us again to mark them clean */ | 170 | /* Ensure that kupdated calls us again to mark them clean */ |
171 | jffs2_erase_pending_trigger(c); | 171 | jffs2_erase_pending_trigger(c); |
172 | } | 172 | } |
@@ -180,26 +180,26 @@ static void jffs2_erase_failed(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
180 | failed too many times. */ | 180 | failed too many times. */ |
181 | if (!jffs2_write_nand_badblock(c, jeb, bad_offset)) { | 181 | if (!jffs2_write_nand_badblock(c, jeb, bad_offset)) { |
182 | /* We'd like to give this block another try. */ | 182 | /* We'd like to give this block another try. */ |
183 | down(&c->erase_free_sem); | 183 | mutex_lock(&c->erase_free_sem); |
184 | spin_lock(&c->erase_completion_lock); | 184 | spin_lock(&c->erase_completion_lock); |
185 | list_move(&jeb->list, &c->erase_pending_list); | 185 | list_move(&jeb->list, &c->erase_pending_list); |
186 | c->erasing_size -= c->sector_size; | 186 | c->erasing_size -= c->sector_size; |
187 | c->dirty_size += c->sector_size; | 187 | c->dirty_size += c->sector_size; |
188 | jeb->dirty_size = c->sector_size; | 188 | jeb->dirty_size = c->sector_size; |
189 | spin_unlock(&c->erase_completion_lock); | 189 | spin_unlock(&c->erase_completion_lock); |
190 | up(&c->erase_free_sem); | 190 | mutex_unlock(&c->erase_free_sem); |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | down(&c->erase_free_sem); | 195 | mutex_lock(&c->erase_free_sem); |
196 | spin_lock(&c->erase_completion_lock); | 196 | spin_lock(&c->erase_completion_lock); |
197 | c->erasing_size -= c->sector_size; | 197 | c->erasing_size -= c->sector_size; |
198 | c->bad_size += c->sector_size; | 198 | c->bad_size += c->sector_size; |
199 | list_move(&jeb->list, &c->bad_list); | 199 | list_move(&jeb->list, &c->bad_list); |
200 | c->nr_erasing_blocks--; | 200 | c->nr_erasing_blocks--; |
201 | spin_unlock(&c->erase_completion_lock); | 201 | spin_unlock(&c->erase_completion_lock); |
202 | up(&c->erase_free_sem); | 202 | mutex_unlock(&c->erase_free_sem); |
203 | wake_up(&c->erase_wait); | 203 | wake_up(&c->erase_wait); |
204 | } | 204 | } |
205 | 205 | ||
@@ -456,7 +456,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
456 | jffs2_link_node_ref(c, jeb, jeb->offset | REF_NORMAL, c->cleanmarker_size, NULL); | 456 | jffs2_link_node_ref(c, jeb, jeb->offset | REF_NORMAL, c->cleanmarker_size, NULL); |
457 | } | 457 | } |
458 | 458 | ||
459 | down(&c->erase_free_sem); | 459 | mutex_lock(&c->erase_free_sem); |
460 | spin_lock(&c->erase_completion_lock); | 460 | spin_lock(&c->erase_completion_lock); |
461 | c->erasing_size -= c->sector_size; | 461 | c->erasing_size -= c->sector_size; |
462 | c->free_size += jeb->free_size; | 462 | c->free_size += jeb->free_size; |
@@ -469,28 +469,28 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
469 | c->nr_erasing_blocks--; | 469 | c->nr_erasing_blocks--; |
470 | c->nr_free_blocks++; | 470 | c->nr_free_blocks++; |
471 | spin_unlock(&c->erase_completion_lock); | 471 | spin_unlock(&c->erase_completion_lock); |
472 | up(&c->erase_free_sem); | 472 | mutex_unlock(&c->erase_free_sem); |
473 | wake_up(&c->erase_wait); | 473 | wake_up(&c->erase_wait); |
474 | return; | 474 | return; |
475 | 475 | ||
476 | filebad: | 476 | filebad: |
477 | down(&c->erase_free_sem); | 477 | mutex_lock(&c->erase_free_sem); |
478 | spin_lock(&c->erase_completion_lock); | 478 | spin_lock(&c->erase_completion_lock); |
479 | /* Stick it on a list (any list) so erase_failed can take it | 479 | /* Stick it on a list (any list) so erase_failed can take it |
480 | right off again. Silly, but shouldn't happen often. */ | 480 | right off again. Silly, but shouldn't happen often. */ |
481 | list_add(&jeb->list, &c->erasing_list); | 481 | list_add(&jeb->list, &c->erasing_list); |
482 | spin_unlock(&c->erase_completion_lock); | 482 | spin_unlock(&c->erase_completion_lock); |
483 | up(&c->erase_free_sem); | 483 | mutex_unlock(&c->erase_free_sem); |
484 | jffs2_erase_failed(c, jeb, bad_offset); | 484 | jffs2_erase_failed(c, jeb, bad_offset); |
485 | return; | 485 | return; |
486 | 486 | ||
487 | refile: | 487 | refile: |
488 | /* Stick it back on the list from whence it came and come back later */ | 488 | /* Stick it back on the list from whence it came and come back later */ |
489 | jffs2_erase_pending_trigger(c); | 489 | jffs2_erase_pending_trigger(c); |
490 | down(&c->erase_free_sem); | 490 | mutex_lock(&c->erase_free_sem); |
491 | spin_lock(&c->erase_completion_lock); | 491 | spin_lock(&c->erase_completion_lock); |
492 | list_add(&jeb->list, &c->erase_complete_list); | 492 | list_add(&jeb->list, &c->erase_complete_list); |
493 | spin_unlock(&c->erase_completion_lock); | 493 | spin_unlock(&c->erase_completion_lock); |
494 | up(&c->erase_free_sem); | 494 | mutex_unlock(&c->erase_free_sem); |
495 | return; | 495 | return; |
496 | } | 496 | } |
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index dcc2734e0b5d..5e920343b2c5 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -115,9 +115,9 @@ static int jffs2_readpage (struct file *filp, struct page *pg) | |||
115 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host); | 115 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host); |
116 | int ret; | 116 | int ret; |
117 | 117 | ||
118 | down(&f->sem); | 118 | mutex_lock(&f->sem); |
119 | ret = jffs2_do_readpage_unlock(pg->mapping->host, pg); | 119 | ret = jffs2_do_readpage_unlock(pg->mapping->host, pg); |
120 | up(&f->sem); | 120 | mutex_unlock(&f->sem); |
121 | return ret; | 121 | return ret; |
122 | } | 122 | } |
123 | 123 | ||
@@ -154,7 +154,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
154 | if (ret) | 154 | if (ret) |
155 | goto out_page; | 155 | goto out_page; |
156 | 156 | ||
157 | down(&f->sem); | 157 | mutex_lock(&f->sem); |
158 | memset(&ri, 0, sizeof(ri)); | 158 | memset(&ri, 0, sizeof(ri)); |
159 | 159 | ||
160 | ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 160 | ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -181,7 +181,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
181 | if (IS_ERR(fn)) { | 181 | if (IS_ERR(fn)) { |
182 | ret = PTR_ERR(fn); | 182 | ret = PTR_ERR(fn); |
183 | jffs2_complete_reservation(c); | 183 | jffs2_complete_reservation(c); |
184 | up(&f->sem); | 184 | mutex_unlock(&f->sem); |
185 | goto out_page; | 185 | goto out_page; |
186 | } | 186 | } |
187 | ret = jffs2_add_full_dnode_to_inode(c, f, fn); | 187 | ret = jffs2_add_full_dnode_to_inode(c, f, fn); |
@@ -195,12 +195,12 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
195 | jffs2_mark_node_obsolete(c, fn->raw); | 195 | jffs2_mark_node_obsolete(c, fn->raw); |
196 | jffs2_free_full_dnode(fn); | 196 | jffs2_free_full_dnode(fn); |
197 | jffs2_complete_reservation(c); | 197 | jffs2_complete_reservation(c); |
198 | up(&f->sem); | 198 | mutex_unlock(&f->sem); |
199 | goto out_page; | 199 | goto out_page; |
200 | } | 200 | } |
201 | jffs2_complete_reservation(c); | 201 | jffs2_complete_reservation(c); |
202 | inode->i_size = pageofs; | 202 | inode->i_size = pageofs; |
203 | up(&f->sem); | 203 | mutex_unlock(&f->sem); |
204 | } | 204 | } |
205 | 205 | ||
206 | /* | 206 | /* |
@@ -209,9 +209,9 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
209 | * case of a short-copy. | 209 | * case of a short-copy. |
210 | */ | 210 | */ |
211 | if (!PageUptodate(pg)) { | 211 | if (!PageUptodate(pg)) { |
212 | down(&f->sem); | 212 | mutex_lock(&f->sem); |
213 | ret = jffs2_do_readpage_nolock(inode, pg); | 213 | ret = jffs2_do_readpage_nolock(inode, pg); |
214 | up(&f->sem); | 214 | mutex_unlock(&f->sem); |
215 | if (ret) | 215 | if (ret) |
216 | goto out_page; | 216 | goto out_page; |
217 | } | 217 | } |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 9dafb53fb1d1..3eb1c84b0a33 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -51,20 +51,20 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
51 | mdata = (char *)&dev; | 51 | mdata = (char *)&dev; |
52 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen)); | 52 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen)); |
53 | } else if (S_ISLNK(inode->i_mode)) { | 53 | } else if (S_ISLNK(inode->i_mode)) { |
54 | down(&f->sem); | 54 | mutex_lock(&f->sem); |
55 | mdatalen = f->metadata->size; | 55 | mdatalen = f->metadata->size; |
56 | mdata = kmalloc(f->metadata->size, GFP_USER); | 56 | mdata = kmalloc(f->metadata->size, GFP_USER); |
57 | if (!mdata) { | 57 | if (!mdata) { |
58 | up(&f->sem); | 58 | mutex_unlock(&f->sem); |
59 | return -ENOMEM; | 59 | return -ENOMEM; |
60 | } | 60 | } |
61 | ret = jffs2_read_dnode(c, f, f->metadata, mdata, 0, mdatalen); | 61 | ret = jffs2_read_dnode(c, f, f->metadata, mdata, 0, mdatalen); |
62 | if (ret) { | 62 | if (ret) { |
63 | up(&f->sem); | 63 | mutex_unlock(&f->sem); |
64 | kfree(mdata); | 64 | kfree(mdata); |
65 | return ret; | 65 | return ret; |
66 | } | 66 | } |
67 | up(&f->sem); | 67 | mutex_unlock(&f->sem); |
68 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen)); | 68 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen)); |
69 | } | 69 | } |
70 | 70 | ||
@@ -83,7 +83,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
83 | kfree(mdata); | 83 | kfree(mdata); |
84 | return ret; | 84 | return ret; |
85 | } | 85 | } |
86 | down(&f->sem); | 86 | mutex_lock(&f->sem); |
87 | ivalid = iattr->ia_valid; | 87 | ivalid = iattr->ia_valid; |
88 | 88 | ||
89 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 89 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -134,7 +134,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
134 | if (IS_ERR(new_metadata)) { | 134 | if (IS_ERR(new_metadata)) { |
135 | jffs2_complete_reservation(c); | 135 | jffs2_complete_reservation(c); |
136 | jffs2_free_raw_inode(ri); | 136 | jffs2_free_raw_inode(ri); |
137 | up(&f->sem); | 137 | mutex_unlock(&f->sem); |
138 | return PTR_ERR(new_metadata); | 138 | return PTR_ERR(new_metadata); |
139 | } | 139 | } |
140 | /* It worked. Update the inode */ | 140 | /* It worked. Update the inode */ |
@@ -165,7 +165,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
165 | } | 165 | } |
166 | jffs2_free_raw_inode(ri); | 166 | jffs2_free_raw_inode(ri); |
167 | 167 | ||
168 | up(&f->sem); | 168 | mutex_unlock(&f->sem); |
169 | jffs2_complete_reservation(c); | 169 | jffs2_complete_reservation(c); |
170 | 170 | ||
171 | /* We have to do the vmtruncate() without f->sem held, since | 171 | /* We have to do the vmtruncate() without f->sem held, since |
@@ -256,12 +256,12 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
256 | c = JFFS2_SB_INFO(inode->i_sb); | 256 | c = JFFS2_SB_INFO(inode->i_sb); |
257 | 257 | ||
258 | jffs2_init_inode_info(f); | 258 | jffs2_init_inode_info(f); |
259 | down(&f->sem); | 259 | mutex_lock(&f->sem); |
260 | 260 | ||
261 | ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); | 261 | ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); |
262 | 262 | ||
263 | if (ret) { | 263 | if (ret) { |
264 | up(&f->sem); | 264 | mutex_unlock(&f->sem); |
265 | iget_failed(inode); | 265 | iget_failed(inode); |
266 | return ERR_PTR(ret); | 266 | return ERR_PTR(ret); |
267 | } | 267 | } |
@@ -338,7 +338,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
338 | printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino); | 338 | printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino); |
339 | } | 339 | } |
340 | 340 | ||
341 | up(&f->sem); | 341 | mutex_unlock(&f->sem); |
342 | 342 | ||
343 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); | 343 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); |
344 | unlock_new_inode(inode); | 344 | unlock_new_inode(inode); |
@@ -347,7 +347,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
347 | error_io: | 347 | error_io: |
348 | ret = -EIO; | 348 | ret = -EIO; |
349 | error: | 349 | error: |
350 | up(&f->sem); | 350 | mutex_unlock(&f->sem); |
351 | jffs2_do_clear_inode(c, f); | 351 | jffs2_do_clear_inode(c, f); |
352 | iget_failed(inode); | 352 | iget_failed(inode); |
353 | return ERR_PTR(ret); | 353 | return ERR_PTR(ret); |
@@ -388,9 +388,9 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) | |||
388 | Flush the writebuffer, if neccecary, else we loose it */ | 388 | Flush the writebuffer, if neccecary, else we loose it */ |
389 | if (!(sb->s_flags & MS_RDONLY)) { | 389 | if (!(sb->s_flags & MS_RDONLY)) { |
390 | jffs2_stop_garbage_collect_thread(c); | 390 | jffs2_stop_garbage_collect_thread(c); |
391 | down(&c->alloc_sem); | 391 | mutex_lock(&c->alloc_sem); |
392 | jffs2_flush_wbuf_pad(c); | 392 | jffs2_flush_wbuf_pad(c); |
393 | up(&c->alloc_sem); | 393 | mutex_unlock(&c->alloc_sem); |
394 | } | 394 | } |
395 | 395 | ||
396 | if (!(*flags & MS_RDONLY)) | 396 | if (!(*flags & MS_RDONLY)) |
@@ -437,7 +437,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i | |||
437 | 437 | ||
438 | f = JFFS2_INODE_INFO(inode); | 438 | f = JFFS2_INODE_INFO(inode); |
439 | jffs2_init_inode_info(f); | 439 | jffs2_init_inode_info(f); |
440 | down(&f->sem); | 440 | mutex_lock(&f->sem); |
441 | 441 | ||
442 | memset(ri, 0, sizeof(*ri)); | 442 | memset(ri, 0, sizeof(*ri)); |
443 | /* Set OS-specific defaults for new inodes */ | 443 | /* Set OS-specific defaults for new inodes */ |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 59aeb9820435..26c7992c45ca 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -126,7 +126,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
126 | int ret = 0, inum, nlink; | 126 | int ret = 0, inum, nlink; |
127 | int xattr = 0; | 127 | int xattr = 0; |
128 | 128 | ||
129 | if (down_interruptible(&c->alloc_sem)) | 129 | if (mutex_lock_interruptible(&c->alloc_sem)) |
130 | return -EINTR; | 130 | return -EINTR; |
131 | 131 | ||
132 | for (;;) { | 132 | for (;;) { |
@@ -143,7 +143,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
143 | c->unchecked_size); | 143 | c->unchecked_size); |
144 | jffs2_dbg_dump_block_lists_nolock(c); | 144 | jffs2_dbg_dump_block_lists_nolock(c); |
145 | spin_unlock(&c->erase_completion_lock); | 145 | spin_unlock(&c->erase_completion_lock); |
146 | up(&c->alloc_sem); | 146 | mutex_unlock(&c->alloc_sem); |
147 | return -ENOSPC; | 147 | return -ENOSPC; |
148 | } | 148 | } |
149 | 149 | ||
@@ -190,7 +190,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
190 | made no progress in this case, but that should be OK */ | 190 | made no progress in this case, but that should be OK */ |
191 | c->checked_ino--; | 191 | c->checked_ino--; |
192 | 192 | ||
193 | up(&c->alloc_sem); | 193 | mutex_unlock(&c->alloc_sem); |
194 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 194 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
195 | return 0; | 195 | return 0; |
196 | 196 | ||
@@ -210,7 +210,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
210 | printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino); | 210 | printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino); |
211 | 211 | ||
212 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); | 212 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); |
213 | up(&c->alloc_sem); | 213 | mutex_unlock(&c->alloc_sem); |
214 | return ret; | 214 | return ret; |
215 | } | 215 | } |
216 | 216 | ||
@@ -223,7 +223,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
223 | if (!jeb) { | 223 | if (!jeb) { |
224 | D1 (printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); | 224 | D1 (printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); |
225 | spin_unlock(&c->erase_completion_lock); | 225 | spin_unlock(&c->erase_completion_lock); |
226 | up(&c->alloc_sem); | 226 | mutex_unlock(&c->alloc_sem); |
227 | return -EIO; | 227 | return -EIO; |
228 | } | 228 | } |
229 | 229 | ||
@@ -232,7 +232,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
232 | printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size)); | 232 | printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size)); |
233 | 233 | ||
234 | if (!jeb->used_size) { | 234 | if (!jeb->used_size) { |
235 | up(&c->alloc_sem); | 235 | mutex_unlock(&c->alloc_sem); |
236 | goto eraseit; | 236 | goto eraseit; |
237 | } | 237 | } |
238 | 238 | ||
@@ -248,7 +248,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
248 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); | 248 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); |
249 | jeb->gc_node = raw; | 249 | jeb->gc_node = raw; |
250 | spin_unlock(&c->erase_completion_lock); | 250 | spin_unlock(&c->erase_completion_lock); |
251 | up(&c->alloc_sem); | 251 | mutex_unlock(&c->alloc_sem); |
252 | BUG(); | 252 | BUG(); |
253 | } | 253 | } |
254 | } | 254 | } |
@@ -266,7 +266,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
266 | /* Just mark it obsolete */ | 266 | /* Just mark it obsolete */ |
267 | jffs2_mark_node_obsolete(c, raw); | 267 | jffs2_mark_node_obsolete(c, raw); |
268 | } | 268 | } |
269 | up(&c->alloc_sem); | 269 | mutex_unlock(&c->alloc_sem); |
270 | goto eraseit_lock; | 270 | goto eraseit_lock; |
271 | } | 271 | } |
272 | 272 | ||
@@ -334,7 +334,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
334 | */ | 334 | */ |
335 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", | 335 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", |
336 | ic->ino, ic->state); | 336 | ic->ino, ic->state); |
337 | up(&c->alloc_sem); | 337 | mutex_unlock(&c->alloc_sem); |
338 | spin_unlock(&c->inocache_lock); | 338 | spin_unlock(&c->inocache_lock); |
339 | BUG(); | 339 | BUG(); |
340 | 340 | ||
@@ -345,7 +345,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
345 | the alloc_sem() (for marking nodes invalid) so we must | 345 | the alloc_sem() (for marking nodes invalid) so we must |
346 | drop the alloc_sem before sleeping. */ | 346 | drop the alloc_sem before sleeping. */ |
347 | 347 | ||
348 | up(&c->alloc_sem); | 348 | mutex_unlock(&c->alloc_sem); |
349 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", | 349 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", |
350 | ic->ino, ic->state)); | 350 | ic->ino, ic->state)); |
351 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 351 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
@@ -416,7 +416,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
416 | ret = -ENOSPC; | 416 | ret = -ENOSPC; |
417 | } | 417 | } |
418 | release_sem: | 418 | release_sem: |
419 | up(&c->alloc_sem); | 419 | mutex_unlock(&c->alloc_sem); |
420 | 420 | ||
421 | eraseit_lock: | 421 | eraseit_lock: |
422 | /* If we've finished this block, start it erasing */ | 422 | /* If we've finished this block, start it erasing */ |
@@ -445,7 +445,7 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
445 | uint32_t start = 0, end = 0, nrfrags = 0; | 445 | uint32_t start = 0, end = 0, nrfrags = 0; |
446 | int ret = 0; | 446 | int ret = 0; |
447 | 447 | ||
448 | down(&f->sem); | 448 | mutex_lock(&f->sem); |
449 | 449 | ||
450 | /* Now we have the lock for this inode. Check that it's still the one at the head | 450 | /* Now we have the lock for this inode. Check that it's still the one at the head |
451 | of the list. */ | 451 | of the list. */ |
@@ -525,7 +525,7 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
525 | } | 525 | } |
526 | } | 526 | } |
527 | upnout: | 527 | upnout: |
528 | up(&f->sem); | 528 | mutex_unlock(&f->sem); |
529 | 529 | ||
530 | return ret; | 530 | return ret; |
531 | } | 531 | } |
@@ -846,7 +846,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
846 | /* Prevent the erase code from nicking the obsolete node refs while | 846 | /* Prevent the erase code from nicking the obsolete node refs while |
847 | we're looking at them. I really don't like this extra lock but | 847 | we're looking at them. I really don't like this extra lock but |
848 | can't see any alternative. Suggestions on a postcard to... */ | 848 | can't see any alternative. Suggestions on a postcard to... */ |
849 | down(&c->erase_free_sem); | 849 | mutex_lock(&c->erase_free_sem); |
850 | 850 | ||
851 | for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) { | 851 | for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) { |
852 | 852 | ||
@@ -899,7 +899,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
899 | /* OK. The name really does match. There really is still an older node on | 899 | /* OK. The name really does match. There really is still an older node on |
900 | the flash which our deletion dirent obsoletes. So we have to write out | 900 | the flash which our deletion dirent obsoletes. So we have to write out |
901 | a new deletion dirent to replace it */ | 901 | a new deletion dirent to replace it */ |
902 | up(&c->erase_free_sem); | 902 | mutex_unlock(&c->erase_free_sem); |
903 | 903 | ||
904 | D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", | 904 | D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", |
905 | ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino))); | 905 | ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino))); |
@@ -908,7 +908,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
908 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); | 908 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); |
909 | } | 909 | } |
910 | 910 | ||
911 | up(&c->erase_free_sem); | 911 | mutex_unlock(&c->erase_free_sem); |
912 | kfree(rd); | 912 | kfree(rd); |
913 | } | 913 | } |
914 | 914 | ||
diff --git a/fs/jffs2/jffs2_fs_i.h b/fs/jffs2/jffs2_fs_i.h index a841f4973a74..b5427b5c9483 100644 --- a/fs/jffs2/jffs2_fs_i.h +++ b/fs/jffs2/jffs2_fs_i.h | |||
@@ -24,7 +24,7 @@ struct jffs2_inode_info { | |||
24 | before letting GC proceed. Or we'd have to put ugliness | 24 | before letting GC proceed. Or we'd have to put ugliness |
25 | into the GC code so it didn't attempt to obtain the i_mutex | 25 | into the GC code so it didn't attempt to obtain the i_mutex |
26 | for the inode(s) which are already locked */ | 26 | for the inode(s) which are already locked */ |
27 | struct semaphore sem; | 27 | struct mutex sem; |
28 | 28 | ||
29 | /* The highest (datanode) version number used for this ino */ | 29 | /* The highest (datanode) version number used for this ino */ |
30 | uint32_t highest_version; | 30 | uint32_t highest_version; |
diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h index 18fca2b9e531..d9c4b27575e8 100644 --- a/fs/jffs2/jffs2_fs_sb.h +++ b/fs/jffs2/jffs2_fs_sb.h | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/spinlock.h> | 16 | #include <linux/spinlock.h> |
17 | #include <linux/workqueue.h> | 17 | #include <linux/workqueue.h> |
18 | #include <linux/completion.h> | 18 | #include <linux/completion.h> |
19 | #include <linux/semaphore.h> | 19 | #include <linux/mutex.h> |
20 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
21 | #include <linux/wait.h> | 21 | #include <linux/wait.h> |
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
@@ -44,7 +44,7 @@ struct jffs2_sb_info { | |||
44 | struct completion gc_thread_start; /* GC thread start completion */ | 44 | struct completion gc_thread_start; /* GC thread start completion */ |
45 | struct completion gc_thread_exit; /* GC thread exit completion port */ | 45 | struct completion gc_thread_exit; /* GC thread exit completion port */ |
46 | 46 | ||
47 | struct semaphore alloc_sem; /* Used to protect all the following | 47 | struct mutex alloc_sem; /* Used to protect all the following |
48 | fields, and also to protect against | 48 | fields, and also to protect against |
49 | out-of-order writing of nodes. And GC. */ | 49 | out-of-order writing of nodes. And GC. */ |
50 | uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER | 50 | uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER |
@@ -104,7 +104,7 @@ struct jffs2_sb_info { | |||
104 | /* Sem to allow jffs2_garbage_collect_deletion_dirent to | 104 | /* Sem to allow jffs2_garbage_collect_deletion_dirent to |
105 | drop the erase_completion_lock while it's holding a pointer | 105 | drop the erase_completion_lock while it's holding a pointer |
106 | to an obsoleted node. I don't like this. Alternatives welcomed. */ | 106 | to an obsoleted node. I don't like this. Alternatives welcomed. */ |
107 | struct semaphore erase_free_sem; | 107 | struct mutex erase_free_sem; |
108 | 108 | ||
109 | uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */ | 109 | uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */ |
110 | 110 | ||
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index a3e67a4ed675..747a73f0aa4d 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -48,7 +48,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
48 | minsize = PAD(minsize); | 48 | minsize = PAD(minsize); |
49 | 49 | ||
50 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); | 50 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); |
51 | down(&c->alloc_sem); | 51 | mutex_lock(&c->alloc_sem); |
52 | 52 | ||
53 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); | 53 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); |
54 | 54 | ||
@@ -81,7 +81,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
81 | dirty, c->unchecked_size, c->sector_size)); | 81 | dirty, c->unchecked_size, c->sector_size)); |
82 | 82 | ||
83 | spin_unlock(&c->erase_completion_lock); | 83 | spin_unlock(&c->erase_completion_lock); |
84 | up(&c->alloc_sem); | 84 | mutex_unlock(&c->alloc_sem); |
85 | return -ENOSPC; | 85 | return -ENOSPC; |
86 | } | 86 | } |
87 | 87 | ||
@@ -104,11 +104,11 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
104 | D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", | 104 | D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", |
105 | avail, blocksneeded * c->sector_size)); | 105 | avail, blocksneeded * c->sector_size)); |
106 | spin_unlock(&c->erase_completion_lock); | 106 | spin_unlock(&c->erase_completion_lock); |
107 | up(&c->alloc_sem); | 107 | mutex_unlock(&c->alloc_sem); |
108 | return -ENOSPC; | 108 | return -ENOSPC; |
109 | } | 109 | } |
110 | 110 | ||
111 | up(&c->alloc_sem); | 111 | mutex_unlock(&c->alloc_sem); |
112 | 112 | ||
113 | D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", | 113 | D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", |
114 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, | 114 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, |
@@ -124,7 +124,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
124 | if (signal_pending(current)) | 124 | if (signal_pending(current)) |
125 | return -EINTR; | 125 | return -EINTR; |
126 | 126 | ||
127 | down(&c->alloc_sem); | 127 | mutex_lock(&c->alloc_sem); |
128 | spin_lock(&c->erase_completion_lock); | 128 | spin_lock(&c->erase_completion_lock); |
129 | } | 129 | } |
130 | 130 | ||
@@ -137,7 +137,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
137 | if (!ret) | 137 | if (!ret) |
138 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); | 138 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); |
139 | if (ret) | 139 | if (ret) |
140 | up(&c->alloc_sem); | 140 | mutex_unlock(&c->alloc_sem); |
141 | return ret; | 141 | return ret; |
142 | } | 142 | } |
143 | 143 | ||
@@ -462,7 +462,7 @@ void jffs2_complete_reservation(struct jffs2_sb_info *c) | |||
462 | { | 462 | { |
463 | D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); | 463 | D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); |
464 | jffs2_garbage_collect_trigger(c); | 464 | jffs2_garbage_collect_trigger(c); |
465 | up(&c->alloc_sem); | 465 | mutex_unlock(&c->alloc_sem); |
466 | } | 466 | } |
467 | 467 | ||
468 | static inline int on_list(struct list_head *obj, struct list_head *head) | 468 | static inline int on_list(struct list_head *obj, struct list_head *head) |
@@ -511,7 +511,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
511 | any jffs2_raw_node_refs. So we don't need to stop erases from | 511 | any jffs2_raw_node_refs. So we don't need to stop erases from |
512 | happening, or protect against people holding an obsolete | 512 | happening, or protect against people holding an obsolete |
513 | jffs2_raw_node_ref without the erase_completion_lock. */ | 513 | jffs2_raw_node_ref without the erase_completion_lock. */ |
514 | down(&c->erase_free_sem); | 514 | mutex_lock(&c->erase_free_sem); |
515 | } | 515 | } |
516 | 516 | ||
517 | spin_lock(&c->erase_completion_lock); | 517 | spin_lock(&c->erase_completion_lock); |
@@ -714,7 +714,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
714 | } | 714 | } |
715 | 715 | ||
716 | out_erase_sem: | 716 | out_erase_sem: |
717 | up(&c->erase_free_sem); | 717 | mutex_unlock(&c->erase_free_sem); |
718 | } | 718 | } |
719 | 719 | ||
720 | int jffs2_thread_should_wake(struct jffs2_sb_info *c) | 720 | int jffs2_thread_should_wake(struct jffs2_sb_info *c) |
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index e512a93d6249..8a7cf1e8d68a 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -1193,7 +1193,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1193 | JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n", | 1193 | JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n", |
1194 | ret, retlen, sizeof(*latest_node)); | 1194 | ret, retlen, sizeof(*latest_node)); |
1195 | /* FIXME: If this fails, there seems to be a memory leak. Find it. */ | 1195 | /* FIXME: If this fails, there seems to be a memory leak. Find it. */ |
1196 | up(&f->sem); | 1196 | mutex_unlock(&f->sem); |
1197 | jffs2_do_clear_inode(c, f); | 1197 | jffs2_do_clear_inode(c, f); |
1198 | return ret?ret:-EIO; | 1198 | return ret?ret:-EIO; |
1199 | } | 1199 | } |
@@ -1202,7 +1202,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1202 | if (crc != je32_to_cpu(latest_node->node_crc)) { | 1202 | if (crc != je32_to_cpu(latest_node->node_crc)) { |
1203 | JFFS2_ERROR("CRC failed for read_inode of inode %u at physical location 0x%x\n", | 1203 | JFFS2_ERROR("CRC failed for read_inode of inode %u at physical location 0x%x\n", |
1204 | f->inocache->ino, ref_offset(rii.latest_ref)); | 1204 | f->inocache->ino, ref_offset(rii.latest_ref)); |
1205 | up(&f->sem); | 1205 | mutex_unlock(&f->sem); |
1206 | jffs2_do_clear_inode(c, f); | 1206 | jffs2_do_clear_inode(c, f); |
1207 | return -EIO; | 1207 | return -EIO; |
1208 | } | 1208 | } |
@@ -1242,7 +1242,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1242 | f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); | 1242 | f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); |
1243 | if (!f->target) { | 1243 | if (!f->target) { |
1244 | JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize)); | 1244 | JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize)); |
1245 | up(&f->sem); | 1245 | mutex_unlock(&f->sem); |
1246 | jffs2_do_clear_inode(c, f); | 1246 | jffs2_do_clear_inode(c, f); |
1247 | return -ENOMEM; | 1247 | return -ENOMEM; |
1248 | } | 1248 | } |
@@ -1255,7 +1255,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1255 | ret = -EIO; | 1255 | ret = -EIO; |
1256 | kfree(f->target); | 1256 | kfree(f->target); |
1257 | f->target = NULL; | 1257 | f->target = NULL; |
1258 | up(&f->sem); | 1258 | mutex_unlock(&f->sem); |
1259 | jffs2_do_clear_inode(c, f); | 1259 | jffs2_do_clear_inode(c, f); |
1260 | return -ret; | 1260 | return -ret; |
1261 | } | 1261 | } |
@@ -1273,14 +1273,14 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1273 | if (f->metadata) { | 1273 | if (f->metadata) { |
1274 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n", | 1274 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n", |
1275 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 1275 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
1276 | up(&f->sem); | 1276 | mutex_unlock(&f->sem); |
1277 | jffs2_do_clear_inode(c, f); | 1277 | jffs2_do_clear_inode(c, f); |
1278 | return -EIO; | 1278 | return -EIO; |
1279 | } | 1279 | } |
1280 | if (!frag_first(&f->fragtree)) { | 1280 | if (!frag_first(&f->fragtree)) { |
1281 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n", | 1281 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n", |
1282 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 1282 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
1283 | up(&f->sem); | 1283 | mutex_unlock(&f->sem); |
1284 | jffs2_do_clear_inode(c, f); | 1284 | jffs2_do_clear_inode(c, f); |
1285 | return -EIO; | 1285 | return -EIO; |
1286 | } | 1286 | } |
@@ -1289,7 +1289,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1289 | JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had more than one node\n", | 1289 | JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had more than one node\n", |
1290 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 1290 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
1291 | /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ | 1291 | /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ |
1292 | up(&f->sem); | 1292 | mutex_unlock(&f->sem); |
1293 | jffs2_do_clear_inode(c, f); | 1293 | jffs2_do_clear_inode(c, f); |
1294 | return -EIO; | 1294 | return -EIO; |
1295 | } | 1295 | } |
@@ -1379,12 +1379,13 @@ int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *i | |||
1379 | if (!f) | 1379 | if (!f) |
1380 | return -ENOMEM; | 1380 | return -ENOMEM; |
1381 | 1381 | ||
1382 | init_MUTEX_LOCKED(&f->sem); | 1382 | mutex_init(&f->sem); |
1383 | mutex_lock(&f->sem); | ||
1383 | f->inocache = ic; | 1384 | f->inocache = ic; |
1384 | 1385 | ||
1385 | ret = jffs2_do_read_inode_internal(c, f, &n); | 1386 | ret = jffs2_do_read_inode_internal(c, f, &n); |
1386 | if (!ret) { | 1387 | if (!ret) { |
1387 | up(&f->sem); | 1388 | mutex_unlock(&f->sem); |
1388 | jffs2_do_clear_inode(c, f); | 1389 | jffs2_do_clear_inode(c, f); |
1389 | } | 1390 | } |
1390 | kfree (f); | 1391 | kfree (f); |
@@ -1398,7 +1399,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | |||
1398 | 1399 | ||
1399 | jffs2_clear_acl(f); | 1400 | jffs2_clear_acl(f); |
1400 | jffs2_xattr_delete_inode(c, f->inocache); | 1401 | jffs2_xattr_delete_inode(c, f->inocache); |
1401 | down(&f->sem); | 1402 | mutex_lock(&f->sem); |
1402 | deleted = f->inocache && !f->inocache->nlink; | 1403 | deleted = f->inocache && !f->inocache->nlink; |
1403 | 1404 | ||
1404 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) | 1405 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) |
@@ -1430,5 +1431,5 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | |||
1430 | jffs2_del_ino_cache(c, f->inocache); | 1431 | jffs2_del_ino_cache(c, f->inocache); |
1431 | } | 1432 | } |
1432 | 1433 | ||
1433 | up(&f->sem); | 1434 | mutex_unlock(&f->sem); |
1434 | } | 1435 | } |
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 4677355996cc..f3353df178e7 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -47,7 +47,7 @@ static void jffs2_i_init_once(struct kmem_cache *cachep, void *foo) | |||
47 | { | 47 | { |
48 | struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo; | 48 | struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo; |
49 | 49 | ||
50 | init_MUTEX(&ei->sem); | 50 | mutex_init(&ei->sem); |
51 | inode_init_once(&ei->vfs_inode); | 51 | inode_init_once(&ei->vfs_inode); |
52 | } | 52 | } |
53 | 53 | ||
@@ -55,9 +55,9 @@ static int jffs2_sync_fs(struct super_block *sb, int wait) | |||
55 | { | 55 | { |
56 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | 56 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
57 | 57 | ||
58 | down(&c->alloc_sem); | 58 | mutex_lock(&c->alloc_sem); |
59 | jffs2_flush_wbuf_pad(c); | 59 | jffs2_flush_wbuf_pad(c); |
60 | up(&c->alloc_sem); | 60 | mutex_unlock(&c->alloc_sem); |
61 | return 0; | 61 | return 0; |
62 | } | 62 | } |
63 | 63 | ||
@@ -95,8 +95,8 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) | |||
95 | 95 | ||
96 | /* Initialize JFFS2 superblock locks, the further initialization will | 96 | /* Initialize JFFS2 superblock locks, the further initialization will |
97 | * be done later */ | 97 | * be done later */ |
98 | init_MUTEX(&c->alloc_sem); | 98 | mutex_init(&c->alloc_sem); |
99 | init_MUTEX(&c->erase_free_sem); | 99 | mutex_init(&c->erase_free_sem); |
100 | init_waitqueue_head(&c->erase_wait); | 100 | init_waitqueue_head(&c->erase_wait); |
101 | init_waitqueue_head(&c->inocache_wq); | 101 | init_waitqueue_head(&c->inocache_wq); |
102 | spin_lock_init(&c->erase_completion_lock); | 102 | spin_lock_init(&c->erase_completion_lock); |
@@ -125,9 +125,9 @@ static void jffs2_put_super (struct super_block *sb) | |||
125 | 125 | ||
126 | D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); | 126 | D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); |
127 | 127 | ||
128 | down(&c->alloc_sem); | 128 | mutex_lock(&c->alloc_sem); |
129 | jffs2_flush_wbuf_pad(c); | 129 | jffs2_flush_wbuf_pad(c); |
130 | up(&c->alloc_sem); | 130 | mutex_unlock(&c->alloc_sem); |
131 | 131 | ||
132 | jffs2_sum_exit(c); | 132 | jffs2_sum_exit(c); |
133 | 133 | ||
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index ba49f19cff85..8de52b607678 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -578,8 +578,8 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
578 | if (!jffs2_is_writebuffered(c)) | 578 | if (!jffs2_is_writebuffered(c)) |
579 | return 0; | 579 | return 0; |
580 | 580 | ||
581 | if (!down_trylock(&c->alloc_sem)) { | 581 | if (mutex_trylock(&c->alloc_sem)) { |
582 | up(&c->alloc_sem); | 582 | mutex_unlock(&c->alloc_sem); |
583 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); | 583 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); |
584 | BUG(); | 584 | BUG(); |
585 | } | 585 | } |
@@ -702,10 +702,10 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
702 | if (!c->wbuf) | 702 | if (!c->wbuf) |
703 | return 0; | 703 | return 0; |
704 | 704 | ||
705 | down(&c->alloc_sem); | 705 | mutex_lock(&c->alloc_sem); |
706 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { | 706 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { |
707 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); | 707 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); |
708 | up(&c->alloc_sem); | 708 | mutex_unlock(&c->alloc_sem); |
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
711 | 711 | ||
@@ -725,14 +725,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
725 | } else while (old_wbuf_len && | 725 | } else while (old_wbuf_len && |
726 | old_wbuf_ofs == c->wbuf_ofs) { | 726 | old_wbuf_ofs == c->wbuf_ofs) { |
727 | 727 | ||
728 | up(&c->alloc_sem); | 728 | mutex_unlock(&c->alloc_sem); |
729 | 729 | ||
730 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); | 730 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); |
731 | 731 | ||
732 | ret = jffs2_garbage_collect_pass(c); | 732 | ret = jffs2_garbage_collect_pass(c); |
733 | if (ret) { | 733 | if (ret) { |
734 | /* GC failed. Flush it with padding instead */ | 734 | /* GC failed. Flush it with padding instead */ |
735 | down(&c->alloc_sem); | 735 | mutex_lock(&c->alloc_sem); |
736 | down_write(&c->wbuf_sem); | 736 | down_write(&c->wbuf_sem); |
737 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 737 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
738 | /* retry flushing wbuf in case jffs2_wbuf_recover | 738 | /* retry flushing wbuf in case jffs2_wbuf_recover |
@@ -742,12 +742,12 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
742 | up_write(&c->wbuf_sem); | 742 | up_write(&c->wbuf_sem); |
743 | break; | 743 | break; |
744 | } | 744 | } |
745 | down(&c->alloc_sem); | 745 | mutex_lock(&c->alloc_sem); |
746 | } | 746 | } |
747 | 747 | ||
748 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); | 748 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); |
749 | 749 | ||
750 | up(&c->alloc_sem); | 750 | mutex_unlock(&c->alloc_sem); |
751 | return ret; | 751 | return ret; |
752 | } | 752 | } |
753 | 753 | ||
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index beade550909c..665fce9797d3 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -137,12 +137,12 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
137 | JFFS2_SUMMARY_INODE_SIZE); | 137 | JFFS2_SUMMARY_INODE_SIZE); |
138 | } else { | 138 | } else { |
139 | /* Locking pain */ | 139 | /* Locking pain */ |
140 | up(&f->sem); | 140 | mutex_unlock(&f->sem); |
141 | jffs2_complete_reservation(c); | 141 | jffs2_complete_reservation(c); |
142 | 142 | ||
143 | ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &dummy, | 143 | ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &dummy, |
144 | alloc_mode, JFFS2_SUMMARY_INODE_SIZE); | 144 | alloc_mode, JFFS2_SUMMARY_INODE_SIZE); |
145 | down(&f->sem); | 145 | mutex_lock(&f->sem); |
146 | } | 146 | } |
147 | 147 | ||
148 | if (!ret) { | 148 | if (!ret) { |
@@ -285,12 +285,12 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
285 | JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | 285 | JFFS2_SUMMARY_DIRENT_SIZE(namelen)); |
286 | } else { | 286 | } else { |
287 | /* Locking pain */ | 287 | /* Locking pain */ |
288 | up(&f->sem); | 288 | mutex_unlock(&f->sem); |
289 | jffs2_complete_reservation(c); | 289 | jffs2_complete_reservation(c); |
290 | 290 | ||
291 | ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &dummy, | 291 | ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &dummy, |
292 | alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | 292 | alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); |
293 | down(&f->sem); | 293 | mutex_lock(&f->sem); |
294 | } | 294 | } |
295 | 295 | ||
296 | if (!ret) { | 296 | if (!ret) { |
@@ -353,7 +353,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
353 | D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); | 353 | D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); |
354 | break; | 354 | break; |
355 | } | 355 | } |
356 | down(&f->sem); | 356 | mutex_lock(&f->sem); |
357 | datalen = min_t(uint32_t, writelen, PAGE_CACHE_SIZE - (offset & (PAGE_CACHE_SIZE-1))); | 357 | datalen = min_t(uint32_t, writelen, PAGE_CACHE_SIZE - (offset & (PAGE_CACHE_SIZE-1))); |
358 | cdatalen = min_t(uint32_t, alloclen - sizeof(*ri), datalen); | 358 | cdatalen = min_t(uint32_t, alloclen - sizeof(*ri), datalen); |
359 | 359 | ||
@@ -381,7 +381,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
381 | 381 | ||
382 | if (IS_ERR(fn)) { | 382 | if (IS_ERR(fn)) { |
383 | ret = PTR_ERR(fn); | 383 | ret = PTR_ERR(fn); |
384 | up(&f->sem); | 384 | mutex_unlock(&f->sem); |
385 | jffs2_complete_reservation(c); | 385 | jffs2_complete_reservation(c); |
386 | if (!retried) { | 386 | if (!retried) { |
387 | /* Write error to be retried */ | 387 | /* Write error to be retried */ |
@@ -403,11 +403,11 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
403 | jffs2_mark_node_obsolete(c, fn->raw); | 403 | jffs2_mark_node_obsolete(c, fn->raw); |
404 | jffs2_free_full_dnode(fn); | 404 | jffs2_free_full_dnode(fn); |
405 | 405 | ||
406 | up(&f->sem); | 406 | mutex_unlock(&f->sem); |
407 | jffs2_complete_reservation(c); | 407 | jffs2_complete_reservation(c); |
408 | break; | 408 | break; |
409 | } | 409 | } |
410 | up(&f->sem); | 410 | mutex_unlock(&f->sem); |
411 | jffs2_complete_reservation(c); | 411 | jffs2_complete_reservation(c); |
412 | if (!datalen) { | 412 | if (!datalen) { |
413 | printk(KERN_WARNING "Eep. We didn't actually write any data in jffs2_write_inode_range()\n"); | 413 | printk(KERN_WARNING "Eep. We didn't actually write any data in jffs2_write_inode_range()\n"); |
@@ -439,7 +439,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
439 | JFFS2_SUMMARY_INODE_SIZE); | 439 | JFFS2_SUMMARY_INODE_SIZE); |
440 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); | 440 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); |
441 | if (ret) { | 441 | if (ret) { |
442 | up(&f->sem); | 442 | mutex_unlock(&f->sem); |
443 | return ret; | 443 | return ret; |
444 | } | 444 | } |
445 | 445 | ||
@@ -454,7 +454,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
454 | if (IS_ERR(fn)) { | 454 | if (IS_ERR(fn)) { |
455 | D1(printk(KERN_DEBUG "jffs2_write_dnode() failed\n")); | 455 | D1(printk(KERN_DEBUG "jffs2_write_dnode() failed\n")); |
456 | /* Eeek. Wave bye bye */ | 456 | /* Eeek. Wave bye bye */ |
457 | up(&f->sem); | 457 | mutex_unlock(&f->sem); |
458 | jffs2_complete_reservation(c); | 458 | jffs2_complete_reservation(c); |
459 | return PTR_ERR(fn); | 459 | return PTR_ERR(fn); |
460 | } | 460 | } |
@@ -463,7 +463,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
463 | */ | 463 | */ |
464 | f->metadata = fn; | 464 | f->metadata = fn; |
465 | 465 | ||
466 | up(&f->sem); | 466 | mutex_unlock(&f->sem); |
467 | jffs2_complete_reservation(c); | 467 | jffs2_complete_reservation(c); |
468 | 468 | ||
469 | ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode); | 469 | ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode); |
@@ -489,7 +489,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
489 | return -ENOMEM; | 489 | return -ENOMEM; |
490 | } | 490 | } |
491 | 491 | ||
492 | down(&dir_f->sem); | 492 | mutex_lock(&dir_f->sem); |
493 | 493 | ||
494 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 494 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
495 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); | 495 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); |
@@ -513,7 +513,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
513 | /* dirent failed to write. Delete the inode normally | 513 | /* dirent failed to write. Delete the inode normally |
514 | as if it were the final unlink() */ | 514 | as if it were the final unlink() */ |
515 | jffs2_complete_reservation(c); | 515 | jffs2_complete_reservation(c); |
516 | up(&dir_f->sem); | 516 | mutex_unlock(&dir_f->sem); |
517 | return PTR_ERR(fd); | 517 | return PTR_ERR(fd); |
518 | } | 518 | } |
519 | 519 | ||
@@ -522,7 +522,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
522 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 522 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
523 | 523 | ||
524 | jffs2_complete_reservation(c); | 524 | jffs2_complete_reservation(c); |
525 | up(&dir_f->sem); | 525 | mutex_unlock(&dir_f->sem); |
526 | 526 | ||
527 | return 0; | 527 | return 0; |
528 | } | 528 | } |
@@ -551,7 +551,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
551 | return ret; | 551 | return ret; |
552 | } | 552 | } |
553 | 553 | ||
554 | down(&dir_f->sem); | 554 | mutex_lock(&dir_f->sem); |
555 | 555 | ||
556 | /* Build a deletion node */ | 556 | /* Build a deletion node */ |
557 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 557 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -574,21 +574,21 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
574 | 574 | ||
575 | if (IS_ERR(fd)) { | 575 | if (IS_ERR(fd)) { |
576 | jffs2_complete_reservation(c); | 576 | jffs2_complete_reservation(c); |
577 | up(&dir_f->sem); | 577 | mutex_unlock(&dir_f->sem); |
578 | return PTR_ERR(fd); | 578 | return PTR_ERR(fd); |
579 | } | 579 | } |
580 | 580 | ||
581 | /* File it. This will mark the old one obsolete. */ | 581 | /* File it. This will mark the old one obsolete. */ |
582 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 582 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
583 | up(&dir_f->sem); | 583 | mutex_unlock(&dir_f->sem); |
584 | } else { | 584 | } else { |
585 | uint32_t nhash = full_name_hash(name, namelen); | 585 | uint32_t nhash = full_name_hash(name, namelen); |
586 | 586 | ||
587 | fd = dir_f->dents; | 587 | fd = dir_f->dents; |
588 | /* We don't actually want to reserve any space, but we do | 588 | /* We don't actually want to reserve any space, but we do |
589 | want to be holding the alloc_sem when we write to flash */ | 589 | want to be holding the alloc_sem when we write to flash */ |
590 | down(&c->alloc_sem); | 590 | mutex_lock(&c->alloc_sem); |
591 | down(&dir_f->sem); | 591 | mutex_lock(&dir_f->sem); |
592 | 592 | ||
593 | for (fd = dir_f->dents; fd; fd = fd->next) { | 593 | for (fd = dir_f->dents; fd; fd = fd->next) { |
594 | if (fd->nhash == nhash && | 594 | if (fd->nhash == nhash && |
@@ -607,7 +607,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | } | 609 | } |
610 | up(&dir_f->sem); | 610 | mutex_unlock(&dir_f->sem); |
611 | } | 611 | } |
612 | 612 | ||
613 | /* dead_f is NULL if this was a rename not a real unlink */ | 613 | /* dead_f is NULL if this was a rename not a real unlink */ |
@@ -615,7 +615,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
615 | pointing to an inode which didn't exist. */ | 615 | pointing to an inode which didn't exist. */ |
616 | if (dead_f && dead_f->inocache) { | 616 | if (dead_f && dead_f->inocache) { |
617 | 617 | ||
618 | down(&dead_f->sem); | 618 | mutex_lock(&dead_f->sem); |
619 | 619 | ||
620 | if (S_ISDIR(OFNI_EDONI_2SFFJ(dead_f)->i_mode)) { | 620 | if (S_ISDIR(OFNI_EDONI_2SFFJ(dead_f)->i_mode)) { |
621 | while (dead_f->dents) { | 621 | while (dead_f->dents) { |
@@ -639,7 +639,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
639 | 639 | ||
640 | dead_f->inocache->nlink--; | 640 | dead_f->inocache->nlink--; |
641 | /* NB: Caller must set inode nlink if appropriate */ | 641 | /* NB: Caller must set inode nlink if appropriate */ |
642 | up(&dead_f->sem); | 642 | mutex_unlock(&dead_f->sem); |
643 | } | 643 | } |
644 | 644 | ||
645 | jffs2_complete_reservation(c); | 645 | jffs2_complete_reservation(c); |
@@ -666,7 +666,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint | |||
666 | return ret; | 666 | return ret; |
667 | } | 667 | } |
668 | 668 | ||
669 | down(&dir_f->sem); | 669 | mutex_lock(&dir_f->sem); |
670 | 670 | ||
671 | /* Build a deletion node */ | 671 | /* Build a deletion node */ |
672 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 672 | rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -691,7 +691,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint | |||
691 | 691 | ||
692 | if (IS_ERR(fd)) { | 692 | if (IS_ERR(fd)) { |
693 | jffs2_complete_reservation(c); | 693 | jffs2_complete_reservation(c); |
694 | up(&dir_f->sem); | 694 | mutex_unlock(&dir_f->sem); |
695 | return PTR_ERR(fd); | 695 | return PTR_ERR(fd); |
696 | } | 696 | } |
697 | 697 | ||
@@ -699,7 +699,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint | |||
699 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); | 699 | jffs2_add_fd_to_list(c, fd, &dir_f->dents); |
700 | 700 | ||
701 | jffs2_complete_reservation(c); | 701 | jffs2_complete_reservation(c); |
702 | up(&dir_f->sem); | 702 | mutex_unlock(&dir_f->sem); |
703 | 703 | ||
704 | return 0; | 704 | return 0; |
705 | } | 705 | } |