aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/inode.c')
-rw-r--r--fs/ocfs2/inode.c61
1 files changed, 43 insertions, 18 deletions
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index f29a90fde619..437de7f768c6 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -130,6 +130,7 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
130 struct inode *inode = NULL; 130 struct inode *inode = NULL;
131 struct super_block *sb = osb->sb; 131 struct super_block *sb = osb->sb;
132 struct ocfs2_find_inode_args args; 132 struct ocfs2_find_inode_args args;
133 journal_t *journal = OCFS2_SB(sb)->journal->j_journal;
133 134
134 trace_ocfs2_iget_begin((unsigned long long)blkno, flags, 135 trace_ocfs2_iget_begin((unsigned long long)blkno, flags,
135 sysfile_type); 136 sysfile_type);
@@ -169,6 +170,32 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
169 goto bail; 170 goto bail;
170 } 171 }
171 172
173 /*
174 * Set transaction id's of transactions that have to be committed
175 * to finish f[data]sync. We set them to currently running transaction
176 * as we cannot be sure that the inode or some of its metadata isn't
177 * part of the transaction - the inode could have been reclaimed and
178 * now it is reread from disk.
179 */
180 if (journal) {
181 transaction_t *transaction;
182 tid_t tid;
183 struct ocfs2_inode_info *oi = OCFS2_I(inode);
184
185 read_lock(&journal->j_state_lock);
186 if (journal->j_running_transaction)
187 transaction = journal->j_running_transaction;
188 else
189 transaction = journal->j_committing_transaction;
190 if (transaction)
191 tid = transaction->t_tid;
192 else
193 tid = journal->j_commit_sequence;
194 read_unlock(&journal->j_state_lock);
195 oi->i_sync_tid = tid;
196 oi->i_datasync_tid = tid;
197 }
198
172bail: 199bail:
173 if (!IS_ERR(inode)) { 200 if (!IS_ERR(inode)) {
174 trace_ocfs2_iget_end(inode, 201 trace_ocfs2_iget_end(inode,
@@ -804,11 +831,13 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode)
804 goto bail; 831 goto bail;
805 } 832 }
806 833
807 /* If we're coming from downconvert_thread we can't go into our own 834 /*
808 * voting [hello, deadlock city!], so unforuntately we just 835 * If we're coming from downconvert_thread we can't go into our own
809 * have to skip deleting this guy. That's OK though because 836 * voting [hello, deadlock city!] so we cannot delete the inode. But
810 * the node who's doing the actual deleting should handle it 837 * since we dropped last inode ref when downconverting dentry lock,
811 * anyway. */ 838 * we cannot have the file open and thus the node doing unlink will
839 * take care of deleting the inode.
840 */
812 if (current == osb->dc_task) 841 if (current == osb->dc_task)
813 goto bail; 842 goto bail;
814 843
@@ -822,12 +851,6 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode)
822 goto bail_unlock; 851 goto bail_unlock;
823 } 852 }
824 853
825 /* If we have allowd wipe of this inode for another node, it
826 * will be marked here so we can safely skip it. Recovery will
827 * cleanup any inodes we might inadvertently skip here. */
828 if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE)
829 goto bail_unlock;
830
831 ret = 1; 854 ret = 1;
832bail_unlock: 855bail_unlock:
833 spin_unlock(&oi->ip_lock); 856 spin_unlock(&oi->ip_lock);
@@ -941,7 +964,7 @@ static void ocfs2_cleanup_delete_inode(struct inode *inode,
941 (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data); 964 (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data);
942 if (sync_data) 965 if (sync_data)
943 filemap_write_and_wait(inode->i_mapping); 966 filemap_write_and_wait(inode->i_mapping);
944 truncate_inode_pages(&inode->i_data, 0); 967 truncate_inode_pages_final(&inode->i_data);
945} 968}
946 969
947static void ocfs2_delete_inode(struct inode *inode) 970static void ocfs2_delete_inode(struct inode *inode)
@@ -960,8 +983,6 @@ static void ocfs2_delete_inode(struct inode *inode)
960 if (is_bad_inode(inode) || !OCFS2_I(inode)->ip_blkno) 983 if (is_bad_inode(inode) || !OCFS2_I(inode)->ip_blkno)
961 goto bail; 984 goto bail;
962 985
963 dquot_initialize(inode);
964
965 if (!ocfs2_inode_is_valid_to_delete(inode)) { 986 if (!ocfs2_inode_is_valid_to_delete(inode)) {
966 /* It's probably not necessary to truncate_inode_pages 987 /* It's probably not necessary to truncate_inode_pages
967 * here but we do it for safety anyway (it will most 988 * here but we do it for safety anyway (it will most
@@ -970,6 +991,8 @@ static void ocfs2_delete_inode(struct inode *inode)
970 goto bail; 991 goto bail;
971 } 992 }
972 993
994 dquot_initialize(inode);
995
973 /* We want to block signals in delete_inode as the lock and 996 /* We want to block signals in delete_inode as the lock and
974 * messaging paths may return us -ERESTARTSYS. Which would 997 * messaging paths may return us -ERESTARTSYS. Which would
975 * cause us to exit early, resulting in inodes being orphaned 998 * cause us to exit early, resulting in inodes being orphaned
@@ -1057,6 +1080,7 @@ static void ocfs2_clear_inode(struct inode *inode)
1057{ 1080{
1058 int status; 1081 int status;
1059 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1082 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1083 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1060 1084
1061 clear_inode(inode); 1085 clear_inode(inode);
1062 trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno, 1086 trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno,
@@ -1073,9 +1097,9 @@ static void ocfs2_clear_inode(struct inode *inode)
1073 1097
1074 /* Do these before all the other work so that we don't bounce 1098 /* Do these before all the other work so that we don't bounce
1075 * the downconvert thread while waiting to destroy the locks. */ 1099 * the downconvert thread while waiting to destroy the locks. */
1076 ocfs2_mark_lockres_freeing(&oi->ip_rw_lockres); 1100 ocfs2_mark_lockres_freeing(osb, &oi->ip_rw_lockres);
1077 ocfs2_mark_lockres_freeing(&oi->ip_inode_lockres); 1101 ocfs2_mark_lockres_freeing(osb, &oi->ip_inode_lockres);
1078 ocfs2_mark_lockres_freeing(&oi->ip_open_lockres); 1102 ocfs2_mark_lockres_freeing(osb, &oi->ip_open_lockres);
1079 1103
1080 ocfs2_resv_discard(&OCFS2_SB(inode->i_sb)->osb_la_resmap, 1104 ocfs2_resv_discard(&OCFS2_SB(inode->i_sb)->osb_la_resmap,
1081 &oi->ip_la_data_resv); 1105 &oi->ip_la_data_resv);
@@ -1157,7 +1181,7 @@ void ocfs2_evict_inode(struct inode *inode)
1157 (OCFS2_I(inode)->ip_flags & OCFS2_INODE_MAYBE_ORPHANED)) { 1181 (OCFS2_I(inode)->ip_flags & OCFS2_INODE_MAYBE_ORPHANED)) {
1158 ocfs2_delete_inode(inode); 1182 ocfs2_delete_inode(inode);
1159 } else { 1183 } else {
1160 truncate_inode_pages(&inode->i_data, 0); 1184 truncate_inode_pages_final(&inode->i_data);
1161 } 1185 }
1162 ocfs2_clear_inode(inode); 1186 ocfs2_clear_inode(inode);
1163} 1187}
@@ -1260,6 +1284,7 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
1260 fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); 1284 fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
1261 1285
1262 ocfs2_journal_dirty(handle, bh); 1286 ocfs2_journal_dirty(handle, bh);
1287 ocfs2_update_inode_fsync_trans(handle, inode, 1);
1263leave: 1288leave:
1264 return status; 1289 return status;
1265} 1290}