diff options
Diffstat (limited to 'fs/ocfs2/inode.c')
-rw-r--r-- | fs/ocfs2/inode.c | 94 |
1 files changed, 60 insertions, 34 deletions
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 0297fb8982b8..af189887201c 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -25,7 +25,6 @@ | |||
25 | 25 | ||
26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/slab.h> | ||
29 | #include <linux/highmem.h> | 28 | #include <linux/highmem.h> |
30 | #include <linux/pagemap.h> | 29 | #include <linux/pagemap.h> |
31 | #include <linux/quotaops.h> | 30 | #include <linux/quotaops.h> |
@@ -475,7 +474,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
475 | if (args->fi_flags & OCFS2_FI_FLAG_ORPHAN_RECOVERY) { | 474 | if (args->fi_flags & OCFS2_FI_FLAG_ORPHAN_RECOVERY) { |
476 | status = ocfs2_try_open_lock(inode, 0); | 475 | status = ocfs2_try_open_lock(inode, 0); |
477 | if (status) { | 476 | if (status) { |
478 | make_bad_inode(inode); | 477 | make_bad_inode(inode); |
479 | return status; | 478 | return status; |
480 | } | 479 | } |
481 | } | 480 | } |
@@ -559,6 +558,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
559 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | 558 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
560 | if (IS_ERR(handle)) { | 559 | if (IS_ERR(handle)) { |
561 | status = PTR_ERR(handle); | 560 | status = PTR_ERR(handle); |
561 | handle = NULL; | ||
562 | mlog_errno(status); | 562 | mlog_errno(status); |
563 | goto out; | 563 | goto out; |
564 | } | 564 | } |
@@ -640,11 +640,13 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
640 | goto bail_unlock; | 640 | goto bail_unlock; |
641 | } | 641 | } |
642 | 642 | ||
643 | status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode, | 643 | if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) { |
644 | orphan_dir_bh); | 644 | status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode, |
645 | if (status < 0) { | 645 | orphan_dir_bh); |
646 | mlog_errno(status); | 646 | if (status < 0) { |
647 | goto bail_commit; | 647 | mlog_errno(status); |
648 | goto bail_commit; | ||
649 | } | ||
648 | } | 650 | } |
649 | 651 | ||
650 | /* set the inodes dtime */ | 652 | /* set the inodes dtime */ |
@@ -665,7 +667,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
665 | } | 667 | } |
666 | 668 | ||
667 | ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh); | 669 | ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh); |
668 | vfs_dq_free_inode(inode); | 670 | dquot_free_inode(inode); |
669 | 671 | ||
670 | status = ocfs2_free_dinode(handle, inode_alloc_inode, | 672 | status = ocfs2_free_dinode(handle, inode_alloc_inode, |
671 | inode_alloc_bh, di); | 673 | inode_alloc_bh, di); |
@@ -684,7 +686,7 @@ bail: | |||
684 | return status; | 686 | return status; |
685 | } | 687 | } |
686 | 688 | ||
687 | /* | 689 | /* |
688 | * Serialize with orphan dir recovery. If the process doing | 690 | * Serialize with orphan dir recovery. If the process doing |
689 | * recovery on this orphan dir does an iget() with the dir | 691 | * recovery on this orphan dir does an iget() with the dir |
690 | * i_mutex held, we'll deadlock here. Instead we detect this | 692 | * i_mutex held, we'll deadlock here. Instead we detect this |
@@ -723,38 +725,39 @@ static void ocfs2_signal_wipe_completion(struct ocfs2_super *osb, | |||
723 | static int ocfs2_wipe_inode(struct inode *inode, | 725 | static int ocfs2_wipe_inode(struct inode *inode, |
724 | struct buffer_head *di_bh) | 726 | struct buffer_head *di_bh) |
725 | { | 727 | { |
726 | int status, orphaned_slot; | 728 | int status, orphaned_slot = -1; |
727 | struct inode *orphan_dir_inode = NULL; | 729 | struct inode *orphan_dir_inode = NULL; |
728 | struct buffer_head *orphan_dir_bh = NULL; | 730 | struct buffer_head *orphan_dir_bh = NULL; |
729 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 731 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
730 | struct ocfs2_dinode *di; | 732 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; |
731 | 733 | ||
732 | di = (struct ocfs2_dinode *) di_bh->b_data; | 734 | if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) { |
733 | orphaned_slot = le16_to_cpu(di->i_orphaned_slot); | 735 | orphaned_slot = le16_to_cpu(di->i_orphaned_slot); |
734 | 736 | ||
735 | status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot); | 737 | status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot); |
736 | if (status) | 738 | if (status) |
737 | return status; | 739 | return status; |
738 | 740 | ||
739 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, | 741 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, |
740 | ORPHAN_DIR_SYSTEM_INODE, | 742 | ORPHAN_DIR_SYSTEM_INODE, |
741 | orphaned_slot); | 743 | orphaned_slot); |
742 | if (!orphan_dir_inode) { | 744 | if (!orphan_dir_inode) { |
743 | status = -EEXIST; | 745 | status = -EEXIST; |
744 | mlog_errno(status); | 746 | mlog_errno(status); |
745 | goto bail; | 747 | goto bail; |
746 | } | 748 | } |
747 | 749 | ||
748 | /* Lock the orphan dir. The lock will be held for the entire | 750 | /* Lock the orphan dir. The lock will be held for the entire |
749 | * delete_inode operation. We do this now to avoid races with | 751 | * delete_inode operation. We do this now to avoid races with |
750 | * recovery completion on other nodes. */ | 752 | * recovery completion on other nodes. */ |
751 | mutex_lock(&orphan_dir_inode->i_mutex); | 753 | mutex_lock(&orphan_dir_inode->i_mutex); |
752 | status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1); | 754 | status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1); |
753 | if (status < 0) { | 755 | if (status < 0) { |
754 | mutex_unlock(&orphan_dir_inode->i_mutex); | 756 | mutex_unlock(&orphan_dir_inode->i_mutex); |
755 | 757 | ||
756 | mlog_errno(status); | 758 | mlog_errno(status); |
757 | goto bail; | 759 | goto bail; |
760 | } | ||
758 | } | 761 | } |
759 | 762 | ||
760 | /* we do this while holding the orphan dir lock because we | 763 | /* we do this while holding the orphan dir lock because we |
@@ -795,6 +798,9 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
795 | mlog_errno(status); | 798 | mlog_errno(status); |
796 | 799 | ||
797 | bail_unlock_dir: | 800 | bail_unlock_dir: |
801 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR) | ||
802 | return status; | ||
803 | |||
798 | ocfs2_inode_unlock(orphan_dir_inode, 1); | 804 | ocfs2_inode_unlock(orphan_dir_inode, 1); |
799 | mutex_unlock(&orphan_dir_inode->i_mutex); | 805 | mutex_unlock(&orphan_dir_inode->i_mutex); |
800 | brelse(orphan_dir_bh); | 806 | brelse(orphan_dir_bh); |
@@ -890,7 +896,23 @@ static int ocfs2_query_inode_wipe(struct inode *inode, | |||
890 | 896 | ||
891 | /* Do some basic inode verification... */ | 897 | /* Do some basic inode verification... */ |
892 | di = (struct ocfs2_dinode *) di_bh->b_data; | 898 | di = (struct ocfs2_dinode *) di_bh->b_data; |
893 | if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL))) { | 899 | if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL)) && |
900 | !(oi->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) { | ||
901 | /* | ||
902 | * Inodes in the orphan dir must have ORPHANED_FL. The only | ||
903 | * inodes that come back out of the orphan dir are reflink | ||
904 | * targets. A reflink target may be moved out of the orphan | ||
905 | * dir between the time we scan the directory and the time we | ||
906 | * process it. This would lead to HAS_REFCOUNT_FL being set but | ||
907 | * ORPHANED_FL not. | ||
908 | */ | ||
909 | if (di->i_dyn_features & cpu_to_le16(OCFS2_HAS_REFCOUNT_FL)) { | ||
910 | mlog(0, "Reflinked inode %llu is no longer orphaned. " | ||
911 | "it shouldn't be deleted\n", | ||
912 | (unsigned long long)oi->ip_blkno); | ||
913 | goto bail; | ||
914 | } | ||
915 | |||
894 | /* for lack of a better error? */ | 916 | /* for lack of a better error? */ |
895 | status = -EEXIST; | 917 | status = -EEXIST; |
896 | mlog(ML_ERROR, | 918 | mlog(ML_ERROR, |
@@ -971,6 +993,8 @@ void ocfs2_delete_inode(struct inode *inode) | |||
971 | goto bail; | 993 | goto bail; |
972 | } | 994 | } |
973 | 995 | ||
996 | dquot_initialize(inode); | ||
997 | |||
974 | if (!ocfs2_inode_is_valid_to_delete(inode)) { | 998 | if (!ocfs2_inode_is_valid_to_delete(inode)) { |
975 | /* It's probably not necessary to truncate_inode_pages | 999 | /* It's probably not necessary to truncate_inode_pages |
976 | * here but we do it for safety anyway (it will most | 1000 | * here but we do it for safety anyway (it will most |
@@ -1087,6 +1111,8 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1087 | mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, | 1111 | mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, |
1088 | "Inode=%lu\n", inode->i_ino); | 1112 | "Inode=%lu\n", inode->i_ino); |
1089 | 1113 | ||
1114 | dquot_drop(inode); | ||
1115 | |||
1090 | /* To preven remote deletes we hold open lock before, now it | 1116 | /* To preven remote deletes we hold open lock before, now it |
1091 | * is time to unlock PR and EX open locks. */ | 1117 | * is time to unlock PR and EX open locks. */ |
1092 | ocfs2_open_unlock(inode); | 1118 | ocfs2_open_unlock(inode); |