diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-04-22 10:13:40 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-04-22 10:13:40 -0400 |
commit | ced22070363ef50e4a47aadd003a81ebeaa3f917 (patch) | |
tree | 66f094dce47a5a0f8f9936308fffe57e2c50255a /fs/jffs2/dir.c | |
parent | 52f8301437a0ba744265e0549ee7239eb85426fc (diff) |
[JFFS2] semaphore->mutex conversion
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/dir.c')
-rw-r--r-- | fs/jffs2/dir.c | 58 |
1 files changed, 29 insertions, 29 deletions
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 */ |