aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2006-10-05 19:48:23 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2006-12-01 21:27:14 -0500
commit123a9643408882620347cc2c82f24e57dab05f44 (patch)
treea36e56e89eb966c5edf213cdc8cc59e78163d903
parente3a821385984e57d5dd1b0e7292761abb0ea4dd9 (diff)
ocfs2: don't pass handle to ocfs2_meta_lock() in ocfs2_link()
Take and drop the locks directly. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
-rw-r--r--fs/ocfs2/namei.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 702f0c30cda4..79f513001a6d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -655,7 +655,7 @@ static int ocfs2_link(struct dentry *old_dentry,
655 struct inode *dir, 655 struct inode *dir,
656 struct dentry *dentry) 656 struct dentry *dentry)
657{ 657{
658 struct ocfs2_journal_handle *handle = NULL; 658 struct ocfs2_journal_handle *handle;
659 struct inode *inode = old_dentry->d_inode; 659 struct inode *inode = old_dentry->d_inode;
660 int err; 660 int err;
661 struct buffer_head *fe_bh = NULL; 661 struct buffer_head *fe_bh = NULL;
@@ -668,68 +668,60 @@ static int ocfs2_link(struct dentry *old_dentry,
668 old_dentry->d_name.len, old_dentry->d_name.name, 668 old_dentry->d_name.len, old_dentry->d_name.name,
669 dentry->d_name.len, dentry->d_name.name); 669 dentry->d_name.len, dentry->d_name.name);
670 670
671 if (S_ISDIR(inode->i_mode)) { 671 if (S_ISDIR(inode->i_mode))
672 err = -EPERM; 672 return -EPERM;
673 goto bail;
674 }
675
676 handle = ocfs2_alloc_handle(osb);
677 if (handle == NULL) {
678 err = -ENOMEM;
679 goto bail;
680 }
681 673
682 err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); 674 err = ocfs2_meta_lock(dir, NULL, &parent_fe_bh, 1);
683 if (err < 0) { 675 if (err < 0) {
684 if (err != -ENOENT) 676 if (err != -ENOENT)
685 mlog_errno(err); 677 mlog_errno(err);
686 goto bail; 678 return err;
687 } 679 }
688 680
689 if (!dir->i_nlink) { 681 if (!dir->i_nlink) {
690 err = -ENOENT; 682 err = -ENOENT;
691 goto bail; 683 goto out;
692 } 684 }
693 685
694 err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, 686 err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
695 dentry->d_name.len); 687 dentry->d_name.len);
696 if (err) 688 if (err)
697 goto bail; 689 goto out;
698 690
699 err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, 691 err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
700 dentry->d_name.name, 692 dentry->d_name.name,
701 dentry->d_name.len, &de_bh); 693 dentry->d_name.len, &de_bh);
702 if (err < 0) { 694 if (err < 0) {
703 mlog_errno(err); 695 mlog_errno(err);
704 goto bail; 696 goto out;
705 } 697 }
706 698
707 err = ocfs2_meta_lock(inode, handle, &fe_bh, 1); 699 err = ocfs2_meta_lock(inode, NULL, &fe_bh, 1);
708 if (err < 0) { 700 if (err < 0) {
709 if (err != -ENOENT) 701 if (err != -ENOENT)
710 mlog_errno(err); 702 mlog_errno(err);
711 goto bail; 703 goto out;
712 } 704 }
713 705
714 fe = (struct ocfs2_dinode *) fe_bh->b_data; 706 fe = (struct ocfs2_dinode *) fe_bh->b_data;
715 if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { 707 if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) {
716 err = -EMLINK; 708 err = -EMLINK;
717 goto bail; 709 goto out_unlock_inode;
718 } 710 }
719 711
720 handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS); 712 handle = ocfs2_start_trans(osb, NULL, OCFS2_LINK_CREDITS);
721 if (IS_ERR(handle)) { 713 if (IS_ERR(handle)) {
722 err = PTR_ERR(handle); 714 err = PTR_ERR(handle);
723 handle = NULL; 715 handle = NULL;
724 mlog_errno(err); 716 mlog_errno(err);
725 goto bail; 717 goto out_unlock_inode;
726 } 718 }
727 719
728 err = ocfs2_journal_access(handle, inode, fe_bh, 720 err = ocfs2_journal_access(handle, inode, fe_bh,
729 OCFS2_JOURNAL_ACCESS_WRITE); 721 OCFS2_JOURNAL_ACCESS_WRITE);
730 if (err < 0) { 722 if (err < 0) {
731 mlog_errno(err); 723 mlog_errno(err);
732 goto bail; 724 goto out_commit;
733 } 725 }
734 726
735 inc_nlink(inode); 727 inc_nlink(inode);
@@ -743,7 +735,7 @@ static int ocfs2_link(struct dentry *old_dentry,
743 le16_add_cpu(&fe->i_links_count, -1); 735 le16_add_cpu(&fe->i_links_count, -1);
744 drop_nlink(inode); 736 drop_nlink(inode);
745 mlog_errno(err); 737 mlog_errno(err);
746 goto bail; 738 goto out_commit;
747 } 739 }
748 740
749 err = ocfs2_add_entry(handle, dentry, inode, 741 err = ocfs2_add_entry(handle, dentry, inode,
@@ -753,21 +745,27 @@ static int ocfs2_link(struct dentry *old_dentry,
753 le16_add_cpu(&fe->i_links_count, -1); 745 le16_add_cpu(&fe->i_links_count, -1);
754 drop_nlink(inode); 746 drop_nlink(inode);
755 mlog_errno(err); 747 mlog_errno(err);
756 goto bail; 748 goto out_commit;
757 } 749 }
758 750
759 err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); 751 err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
760 if (err) { 752 if (err) {
761 mlog_errno(err); 753 mlog_errno(err);
762 goto bail; 754 goto out_commit;
763 } 755 }
764 756
765 atomic_inc(&inode->i_count); 757 atomic_inc(&inode->i_count);
766 dentry->d_op = &ocfs2_dentry_ops; 758 dentry->d_op = &ocfs2_dentry_ops;
767 d_instantiate(dentry, inode); 759 d_instantiate(dentry, inode);
768bail: 760
769 if (handle) 761out_commit:
770 ocfs2_commit_trans(handle); 762 ocfs2_commit_trans(handle);
763out_unlock_inode:
764 ocfs2_meta_unlock(inode, 1);
765
766out:
767 ocfs2_meta_unlock(dir, 1);
768
771 if (de_bh) 769 if (de_bh)
772 brelse(de_bh); 770 brelse(de_bh);
773 if (fe_bh) 771 if (fe_bh)