diff options
Diffstat (limited to 'fs/ocfs2/inode.c')
-rw-r--r-- | fs/ocfs2/inode.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 1d5e0cb0fda1..7e9e4c79aec7 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include "symlink.h" | 49 | #include "symlink.h" |
50 | #include "sysfile.h" | 50 | #include "sysfile.h" |
51 | #include "uptodate.h" | 51 | #include "uptodate.h" |
52 | #include "vote.h" | ||
53 | 52 | ||
54 | #include "buffer_head_io.h" | 53 | #include "buffer_head_io.h" |
55 | 54 | ||
@@ -58,8 +57,11 @@ struct ocfs2_find_inode_args | |||
58 | u64 fi_blkno; | 57 | u64 fi_blkno; |
59 | unsigned long fi_ino; | 58 | unsigned long fi_ino; |
60 | unsigned int fi_flags; | 59 | unsigned int fi_flags; |
60 | unsigned int fi_sysfile_type; | ||
61 | }; | 61 | }; |
62 | 62 | ||
63 | static struct lock_class_key ocfs2_sysfile_lock_key[NUM_SYSTEM_INODES]; | ||
64 | |||
63 | static int ocfs2_read_locked_inode(struct inode *inode, | 65 | static int ocfs2_read_locked_inode(struct inode *inode, |
64 | struct ocfs2_find_inode_args *args); | 66 | struct ocfs2_find_inode_args *args); |
65 | static int ocfs2_init_locked_inode(struct inode *inode, void *opaque); | 67 | static int ocfs2_init_locked_inode(struct inode *inode, void *opaque); |
@@ -107,7 +109,8 @@ void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi) | |||
107 | oi->ip_attr |= OCFS2_DIRSYNC_FL; | 109 | oi->ip_attr |= OCFS2_DIRSYNC_FL; |
108 | } | 110 | } |
109 | 111 | ||
110 | struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags) | 112 | struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags, |
113 | int sysfile_type) | ||
111 | { | 114 | { |
112 | struct inode *inode = NULL; | 115 | struct inode *inode = NULL; |
113 | struct super_block *sb = osb->sb; | 116 | struct super_block *sb = osb->sb; |
@@ -127,6 +130,7 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags) | |||
127 | args.fi_blkno = blkno; | 130 | args.fi_blkno = blkno; |
128 | args.fi_flags = flags; | 131 | args.fi_flags = flags; |
129 | args.fi_ino = ino_from_blkno(sb, blkno); | 132 | args.fi_ino = ino_from_blkno(sb, blkno); |
133 | args.fi_sysfile_type = sysfile_type; | ||
130 | 134 | ||
131 | inode = iget5_locked(sb, args.fi_ino, ocfs2_find_actor, | 135 | inode = iget5_locked(sb, args.fi_ino, ocfs2_find_actor, |
132 | ocfs2_init_locked_inode, &args); | 136 | ocfs2_init_locked_inode, &args); |
@@ -201,6 +205,9 @@ static int ocfs2_init_locked_inode(struct inode *inode, void *opaque) | |||
201 | 205 | ||
202 | inode->i_ino = args->fi_ino; | 206 | inode->i_ino = args->fi_ino; |
203 | OCFS2_I(inode)->ip_blkno = args->fi_blkno; | 207 | OCFS2_I(inode)->ip_blkno = args->fi_blkno; |
208 | if (args->fi_sysfile_type != 0) | ||
209 | lockdep_set_class(&inode->i_mutex, | ||
210 | &ocfs2_sysfile_lock_key[args->fi_sysfile_type]); | ||
204 | 211 | ||
205 | mlog_exit(0); | 212 | mlog_exit(0); |
206 | return 0; | 213 | return 0; |
@@ -322,7 +329,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
322 | */ | 329 | */ |
323 | BUG_ON(le32_to_cpu(fe->i_flags) & OCFS2_SYSTEM_FL); | 330 | BUG_ON(le32_to_cpu(fe->i_flags) & OCFS2_SYSTEM_FL); |
324 | 331 | ||
325 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres, | 332 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_inode_lockres, |
326 | OCFS2_LOCK_TYPE_META, 0, inode); | 333 | OCFS2_LOCK_TYPE_META, 0, inode); |
327 | 334 | ||
328 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_open_lockres, | 335 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_open_lockres, |
@@ -333,10 +340,6 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
333 | OCFS2_LOCK_TYPE_RW, inode->i_generation, | 340 | OCFS2_LOCK_TYPE_RW, inode->i_generation, |
334 | inode); | 341 | inode); |
335 | 342 | ||
336 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_data_lockres, | ||
337 | OCFS2_LOCK_TYPE_DATA, inode->i_generation, | ||
338 | inode); | ||
339 | |||
340 | ocfs2_set_inode_flags(inode); | 343 | ocfs2_set_inode_flags(inode); |
341 | 344 | ||
342 | status = 0; | 345 | status = 0; |
@@ -414,7 +417,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
414 | if (args->fi_flags & OCFS2_FI_FLAG_SYSFILE) | 417 | if (args->fi_flags & OCFS2_FI_FLAG_SYSFILE) |
415 | generation = osb->fs_generation; | 418 | generation = osb->fs_generation; |
416 | 419 | ||
417 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres, | 420 | ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_inode_lockres, |
418 | OCFS2_LOCK_TYPE_META, | 421 | OCFS2_LOCK_TYPE_META, |
419 | generation, inode); | 422 | generation, inode); |
420 | 423 | ||
@@ -429,7 +432,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
429 | mlog_errno(status); | 432 | mlog_errno(status); |
430 | return status; | 433 | return status; |
431 | } | 434 | } |
432 | status = ocfs2_meta_lock(inode, NULL, 0); | 435 | status = ocfs2_inode_lock(inode, NULL, 0); |
433 | if (status) { | 436 | if (status) { |
434 | make_bad_inode(inode); | 437 | make_bad_inode(inode); |
435 | mlog_errno(status); | 438 | mlog_errno(status); |
@@ -455,8 +458,8 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
455 | status = -EINVAL; | 458 | status = -EINVAL; |
456 | fe = (struct ocfs2_dinode *) bh->b_data; | 459 | fe = (struct ocfs2_dinode *) bh->b_data; |
457 | if (!OCFS2_IS_VALID_DINODE(fe)) { | 460 | if (!OCFS2_IS_VALID_DINODE(fe)) { |
458 | mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n", | 461 | mlog(0, "Invalid dinode #%llu: signature = %.*s\n", |
459 | (unsigned long long)le64_to_cpu(fe->i_blkno), 7, | 462 | (unsigned long long)args->fi_blkno, 7, |
460 | fe->i_signature); | 463 | fe->i_signature); |
461 | goto bail; | 464 | goto bail; |
462 | } | 465 | } |
@@ -484,7 +487,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
484 | 487 | ||
485 | bail: | 488 | bail: |
486 | if (can_lock) | 489 | if (can_lock) |
487 | ocfs2_meta_unlock(inode, 0); | 490 | ocfs2_inode_unlock(inode, 0); |
488 | 491 | ||
489 | if (status < 0) | 492 | if (status < 0) |
490 | make_bad_inode(inode); | 493 | make_bad_inode(inode); |
@@ -586,7 +589,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
586 | } | 589 | } |
587 | 590 | ||
588 | mutex_lock(&inode_alloc_inode->i_mutex); | 591 | mutex_lock(&inode_alloc_inode->i_mutex); |
589 | status = ocfs2_meta_lock(inode_alloc_inode, &inode_alloc_bh, 1); | 592 | status = ocfs2_inode_lock(inode_alloc_inode, &inode_alloc_bh, 1); |
590 | if (status < 0) { | 593 | if (status < 0) { |
591 | mutex_unlock(&inode_alloc_inode->i_mutex); | 594 | mutex_unlock(&inode_alloc_inode->i_mutex); |
592 | 595 | ||
@@ -617,7 +620,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
617 | } | 620 | } |
618 | 621 | ||
619 | di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec); | 622 | di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec); |
620 | le32_and_cpu(&di->i_flags, ~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL)); | 623 | di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL)); |
621 | 624 | ||
622 | status = ocfs2_journal_dirty(handle, di_bh); | 625 | status = ocfs2_journal_dirty(handle, di_bh); |
623 | if (status < 0) { | 626 | if (status < 0) { |
@@ -635,7 +638,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
635 | bail_commit: | 638 | bail_commit: |
636 | ocfs2_commit_trans(osb, handle); | 639 | ocfs2_commit_trans(osb, handle); |
637 | bail_unlock: | 640 | bail_unlock: |
638 | ocfs2_meta_unlock(inode_alloc_inode, 1); | 641 | ocfs2_inode_unlock(inode_alloc_inode, 1); |
639 | mutex_unlock(&inode_alloc_inode->i_mutex); | 642 | mutex_unlock(&inode_alloc_inode->i_mutex); |
640 | brelse(inode_alloc_bh); | 643 | brelse(inode_alloc_bh); |
641 | bail: | 644 | bail: |
@@ -709,7 +712,7 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
709 | * delete_inode operation. We do this now to avoid races with | 712 | * delete_inode operation. We do this now to avoid races with |
710 | * recovery completion on other nodes. */ | 713 | * recovery completion on other nodes. */ |
711 | mutex_lock(&orphan_dir_inode->i_mutex); | 714 | mutex_lock(&orphan_dir_inode->i_mutex); |
712 | status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1); | 715 | status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1); |
713 | if (status < 0) { | 716 | if (status < 0) { |
714 | mutex_unlock(&orphan_dir_inode->i_mutex); | 717 | mutex_unlock(&orphan_dir_inode->i_mutex); |
715 | 718 | ||
@@ -718,8 +721,8 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
718 | } | 721 | } |
719 | 722 | ||
720 | /* we do this while holding the orphan dir lock because we | 723 | /* we do this while holding the orphan dir lock because we |
721 | * don't want recovery being run from another node to vote for | 724 | * don't want recovery being run from another node to try an |
722 | * an inode delete on us -- this will result in two nodes | 725 | * inode delete underneath us -- this will result in two nodes |
723 | * truncating the same file! */ | 726 | * truncating the same file! */ |
724 | status = ocfs2_truncate_for_delete(osb, inode, di_bh); | 727 | status = ocfs2_truncate_for_delete(osb, inode, di_bh); |
725 | if (status < 0) { | 728 | if (status < 0) { |
@@ -733,7 +736,7 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
733 | mlog_errno(status); | 736 | mlog_errno(status); |
734 | 737 | ||
735 | bail_unlock_dir: | 738 | bail_unlock_dir: |
736 | ocfs2_meta_unlock(orphan_dir_inode, 1); | 739 | ocfs2_inode_unlock(orphan_dir_inode, 1); |
737 | mutex_unlock(&orphan_dir_inode->i_mutex); | 740 | mutex_unlock(&orphan_dir_inode->i_mutex); |
738 | brelse(orphan_dir_bh); | 741 | brelse(orphan_dir_bh); |
739 | bail: | 742 | bail: |
@@ -744,7 +747,7 @@ bail: | |||
744 | } | 747 | } |
745 | 748 | ||
746 | /* There is a series of simple checks that should be done before a | 749 | /* There is a series of simple checks that should be done before a |
747 | * vote is even considered. Encapsulate those in this function. */ | 750 | * trylock is even considered. Encapsulate those in this function. */ |
748 | static int ocfs2_inode_is_valid_to_delete(struct inode *inode) | 751 | static int ocfs2_inode_is_valid_to_delete(struct inode *inode) |
749 | { | 752 | { |
750 | int ret = 0; | 753 | int ret = 0; |
@@ -758,14 +761,14 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode) | |||
758 | goto bail; | 761 | goto bail; |
759 | } | 762 | } |
760 | 763 | ||
761 | /* If we're coming from process_vote we can't go into our own | 764 | /* If we're coming from downconvert_thread we can't go into our own |
762 | * voting [hello, deadlock city!], so unforuntately we just | 765 | * voting [hello, deadlock city!], so unforuntately we just |
763 | * have to skip deleting this guy. That's OK though because | 766 | * have to skip deleting this guy. That's OK though because |
764 | * the node who's doing the actual deleting should handle it | 767 | * the node who's doing the actual deleting should handle it |
765 | * anyway. */ | 768 | * anyway. */ |
766 | if (current == osb->vote_task) { | 769 | if (current == osb->dc_task) { |
767 | mlog(0, "Skipping delete of %lu because we're currently " | 770 | mlog(0, "Skipping delete of %lu because we're currently " |
768 | "in process_vote\n", inode->i_ino); | 771 | "in downconvert\n", inode->i_ino); |
769 | goto bail; | 772 | goto bail; |
770 | } | 773 | } |
771 | 774 | ||
@@ -779,10 +782,9 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode) | |||
779 | goto bail_unlock; | 782 | goto bail_unlock; |
780 | } | 783 | } |
781 | 784 | ||
782 | /* If we have voted "yes" on the wipe of this inode for | 785 | /* If we have allowd wipe of this inode for another node, it |
783 | * another node, it will be marked here so we can safely skip | 786 | * will be marked here so we can safely skip it. Recovery will |
784 | * it. Recovery will cleanup any inodes we might inadvertantly | 787 | * cleanup any inodes we might inadvertantly skip here. */ |
785 | * skip here. */ | ||
786 | if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE) { | 788 | if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE) { |
787 | mlog(0, "Skipping delete of %lu because another node " | 789 | mlog(0, "Skipping delete of %lu because another node " |
788 | "has done this for us.\n", inode->i_ino); | 790 | "has done this for us.\n", inode->i_ino); |
@@ -863,7 +865,7 @@ static int ocfs2_query_inode_wipe(struct inode *inode, | |||
863 | status = ocfs2_try_open_lock(inode, 1); | 865 | status = ocfs2_try_open_lock(inode, 1); |
864 | if (status == -EAGAIN) { | 866 | if (status == -EAGAIN) { |
865 | status = 0; | 867 | status = 0; |
866 | mlog(0, "Skipping delete of %llu because it is in use on" | 868 | mlog(0, "Skipping delete of %llu because it is in use on " |
867 | "other nodes\n", (unsigned long long)oi->ip_blkno); | 869 | "other nodes\n", (unsigned long long)oi->ip_blkno); |
868 | goto bail; | 870 | goto bail; |
869 | } | 871 | } |
@@ -929,13 +931,13 @@ void ocfs2_delete_inode(struct inode *inode) | |||
929 | 931 | ||
930 | /* Lock down the inode. This gives us an up to date view of | 932 | /* Lock down the inode. This gives us an up to date view of |
931 | * it's metadata (for verification), and allows us to | 933 | * it's metadata (for verification), and allows us to |
932 | * serialize delete_inode votes. | 934 | * serialize delete_inode on multiple nodes. |
933 | * | 935 | * |
934 | * Even though we might be doing a truncate, we don't take the | 936 | * Even though we might be doing a truncate, we don't take the |
935 | * allocation lock here as it won't be needed - nobody will | 937 | * allocation lock here as it won't be needed - nobody will |
936 | * have the file open. | 938 | * have the file open. |
937 | */ | 939 | */ |
938 | status = ocfs2_meta_lock(inode, &di_bh, 1); | 940 | status = ocfs2_inode_lock(inode, &di_bh, 1); |
939 | if (status < 0) { | 941 | if (status < 0) { |
940 | if (status != -ENOENT) | 942 | if (status != -ENOENT) |
941 | mlog_errno(status); | 943 | mlog_errno(status); |
@@ -947,15 +949,15 @@ void ocfs2_delete_inode(struct inode *inode) | |||
947 | * before we go ahead and wipe the inode. */ | 949 | * before we go ahead and wipe the inode. */ |
948 | status = ocfs2_query_inode_wipe(inode, di_bh, &wipe); | 950 | status = ocfs2_query_inode_wipe(inode, di_bh, &wipe); |
949 | if (!wipe || status < 0) { | 951 | if (!wipe || status < 0) { |
950 | /* Error and inode busy vote both mean we won't be | 952 | /* Error and remote inode busy both mean we won't be |
951 | * removing the inode, so they take almost the same | 953 | * removing the inode, so they take almost the same |
952 | * path. */ | 954 | * path. */ |
953 | if (status < 0) | 955 | if (status < 0) |
954 | mlog_errno(status); | 956 | mlog_errno(status); |
955 | 957 | ||
956 | /* Someone in the cluster has voted to not wipe this | 958 | /* Someone in the cluster has disallowed a wipe of |
957 | * inode, or it was never completely orphaned. Write | 959 | * this inode, or it was never completely |
958 | * out the pages and exit now. */ | 960 | * orphaned. Write out the pages and exit now. */ |
959 | ocfs2_cleanup_delete_inode(inode, 1); | 961 | ocfs2_cleanup_delete_inode(inode, 1); |
960 | goto bail_unlock_inode; | 962 | goto bail_unlock_inode; |
961 | } | 963 | } |
@@ -981,7 +983,7 @@ void ocfs2_delete_inode(struct inode *inode) | |||
981 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_DELETED; | 983 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_DELETED; |
982 | 984 | ||
983 | bail_unlock_inode: | 985 | bail_unlock_inode: |
984 | ocfs2_meta_unlock(inode, 1); | 986 | ocfs2_inode_unlock(inode, 1); |
985 | brelse(di_bh); | 987 | brelse(di_bh); |
986 | bail_unblock: | 988 | bail_unblock: |
987 | status = sigprocmask(SIG_SETMASK, &oldset, NULL); | 989 | status = sigprocmask(SIG_SETMASK, &oldset, NULL); |
@@ -1008,15 +1010,14 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1008 | mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, | 1010 | mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, |
1009 | "Inode=%lu\n", inode->i_ino); | 1011 | "Inode=%lu\n", inode->i_ino); |
1010 | 1012 | ||
1011 | /* For remove delete_inode vote, we hold open lock before, | 1013 | /* To preven remote deletes we hold open lock before, now it |
1012 | * now it is time to unlock PR and EX open locks. */ | 1014 | * is time to unlock PR and EX open locks. */ |
1013 | ocfs2_open_unlock(inode); | 1015 | ocfs2_open_unlock(inode); |
1014 | 1016 | ||
1015 | /* Do these before all the other work so that we don't bounce | 1017 | /* Do these before all the other work so that we don't bounce |
1016 | * the vote thread while waiting to destroy the locks. */ | 1018 | * the downconvert thread while waiting to destroy the locks. */ |
1017 | ocfs2_mark_lockres_freeing(&oi->ip_rw_lockres); | 1019 | ocfs2_mark_lockres_freeing(&oi->ip_rw_lockres); |
1018 | ocfs2_mark_lockres_freeing(&oi->ip_meta_lockres); | 1020 | ocfs2_mark_lockres_freeing(&oi->ip_inode_lockres); |
1019 | ocfs2_mark_lockres_freeing(&oi->ip_data_lockres); | ||
1020 | ocfs2_mark_lockres_freeing(&oi->ip_open_lockres); | 1021 | ocfs2_mark_lockres_freeing(&oi->ip_open_lockres); |
1021 | 1022 | ||
1022 | /* We very well may get a clear_inode before all an inodes | 1023 | /* We very well may get a clear_inode before all an inodes |
@@ -1039,8 +1040,7 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1039 | mlog_errno(status); | 1040 | mlog_errno(status); |
1040 | 1041 | ||
1041 | ocfs2_lock_res_free(&oi->ip_rw_lockres); | 1042 | ocfs2_lock_res_free(&oi->ip_rw_lockres); |
1042 | ocfs2_lock_res_free(&oi->ip_meta_lockres); | 1043 | ocfs2_lock_res_free(&oi->ip_inode_lockres); |
1043 | ocfs2_lock_res_free(&oi->ip_data_lockres); | ||
1044 | ocfs2_lock_res_free(&oi->ip_open_lockres); | 1044 | ocfs2_lock_res_free(&oi->ip_open_lockres); |
1045 | 1045 | ||
1046 | ocfs2_metadata_cache_purge(inode); | 1046 | ocfs2_metadata_cache_purge(inode); |
@@ -1184,15 +1184,15 @@ int ocfs2_inode_revalidate(struct dentry *dentry) | |||
1184 | } | 1184 | } |
1185 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 1185 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
1186 | 1186 | ||
1187 | /* Let ocfs2_meta_lock do the work of updating our struct | 1187 | /* Let ocfs2_inode_lock do the work of updating our struct |
1188 | * inode for us. */ | 1188 | * inode for us. */ |
1189 | status = ocfs2_meta_lock(inode, NULL, 0); | 1189 | status = ocfs2_inode_lock(inode, NULL, 0); |
1190 | if (status < 0) { | 1190 | if (status < 0) { |
1191 | if (status != -ENOENT) | 1191 | if (status != -ENOENT) |
1192 | mlog_errno(status); | 1192 | mlog_errno(status); |
1193 | goto bail; | 1193 | goto bail; |
1194 | } | 1194 | } |
1195 | ocfs2_meta_unlock(inode, 0); | 1195 | ocfs2_inode_unlock(inode, 0); |
1196 | bail: | 1196 | bail: |
1197 | mlog_exit(status); | 1197 | mlog_exit(status); |
1198 | 1198 | ||