aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/write.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-04-22 10:13:40 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2008-04-22 10:13:40 -0400
commitced22070363ef50e4a47aadd003a81ebeaa3f917 (patch)
tree66f094dce47a5a0f8f9936308fffe57e2c50255a /fs/jffs2/write.c
parent52f8301437a0ba744265e0549ee7239eb85426fc (diff)
[JFFS2] semaphore->mutex conversion
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/write.c')
-rw-r--r--fs/jffs2/write.c50
1 files changed, 25 insertions, 25 deletions
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}