diff options
Diffstat (limited to 'fs/ocfs2/inode.c')
-rw-r--r-- | fs/ocfs2/inode.c | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index af189887201c..0492464916b1 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -376,6 +376,10 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
376 | 376 | ||
377 | OCFS2_I(inode)->ip_last_used_slot = 0; | 377 | OCFS2_I(inode)->ip_last_used_slot = 0; |
378 | OCFS2_I(inode)->ip_last_used_group = 0; | 378 | OCFS2_I(inode)->ip_last_used_group = 0; |
379 | |||
380 | if (S_ISDIR(inode->i_mode)) | ||
381 | ocfs2_resv_set_type(&OCFS2_I(inode)->ip_la_data_resv, | ||
382 | OCFS2_RESV_FLAG_DIR); | ||
379 | mlog_exit_void(); | 383 | mlog_exit_void(); |
380 | } | 384 | } |
381 | 385 | ||
@@ -539,7 +543,6 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
539 | struct buffer_head *fe_bh) | 543 | struct buffer_head *fe_bh) |
540 | { | 544 | { |
541 | int status = 0; | 545 | int status = 0; |
542 | struct ocfs2_truncate_context *tc = NULL; | ||
543 | struct ocfs2_dinode *fe; | 546 | struct ocfs2_dinode *fe; |
544 | handle_t *handle = NULL; | 547 | handle_t *handle = NULL; |
545 | 548 | ||
@@ -582,13 +585,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
582 | ocfs2_commit_trans(osb, handle); | 585 | ocfs2_commit_trans(osb, handle); |
583 | handle = NULL; | 586 | handle = NULL; |
584 | 587 | ||
585 | status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); | 588 | status = ocfs2_commit_truncate(osb, inode, fe_bh); |
586 | if (status < 0) { | ||
587 | mlog_errno(status); | ||
588 | goto out; | ||
589 | } | ||
590 | |||
591 | status = ocfs2_commit_truncate(osb, inode, fe_bh, tc); | ||
592 | if (status < 0) { | 589 | if (status < 0) { |
593 | mlog_errno(status); | 590 | mlog_errno(status); |
594 | goto out; | 591 | goto out; |
@@ -659,12 +656,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
659 | 656 | ||
660 | di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec); | 657 | di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec); |
661 | di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL)); | 658 | di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL)); |
662 | 659 | ocfs2_journal_dirty(handle, di_bh); | |
663 | status = ocfs2_journal_dirty(handle, di_bh); | ||
664 | if (status < 0) { | ||
665 | mlog_errno(status); | ||
666 | goto bail_commit; | ||
667 | } | ||
668 | 660 | ||
669 | ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh); | 661 | ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh); |
670 | dquot_free_inode(inode); | 662 | dquot_free_inode(inode); |
@@ -977,10 +969,10 @@ static void ocfs2_cleanup_delete_inode(struct inode *inode, | |||
977 | truncate_inode_pages(&inode->i_data, 0); | 969 | truncate_inode_pages(&inode->i_data, 0); |
978 | } | 970 | } |
979 | 971 | ||
980 | void ocfs2_delete_inode(struct inode *inode) | 972 | static void ocfs2_delete_inode(struct inode *inode) |
981 | { | 973 | { |
982 | int wipe, status; | 974 | int wipe, status; |
983 | sigset_t blocked, oldset; | 975 | sigset_t oldset; |
984 | struct buffer_head *di_bh = NULL; | 976 | struct buffer_head *di_bh = NULL; |
985 | 977 | ||
986 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); | 978 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); |
@@ -1007,13 +999,7 @@ void ocfs2_delete_inode(struct inode *inode) | |||
1007 | * messaging paths may return us -ERESTARTSYS. Which would | 999 | * messaging paths may return us -ERESTARTSYS. Which would |
1008 | * cause us to exit early, resulting in inodes being orphaned | 1000 | * cause us to exit early, resulting in inodes being orphaned |
1009 | * forever. */ | 1001 | * forever. */ |
1010 | sigfillset(&blocked); | 1002 | ocfs2_block_signals(&oldset); |
1011 | status = sigprocmask(SIG_BLOCK, &blocked, &oldset); | ||
1012 | if (status < 0) { | ||
1013 | mlog_errno(status); | ||
1014 | ocfs2_cleanup_delete_inode(inode, 1); | ||
1015 | goto bail; | ||
1016 | } | ||
1017 | 1003 | ||
1018 | /* | 1004 | /* |
1019 | * Synchronize us against ocfs2_get_dentry. We take this in | 1005 | * Synchronize us against ocfs2_get_dentry. We take this in |
@@ -1087,24 +1073,19 @@ bail_unlock_nfs_sync: | |||
1087 | ocfs2_nfs_sync_unlock(OCFS2_SB(inode->i_sb), 0); | 1073 | ocfs2_nfs_sync_unlock(OCFS2_SB(inode->i_sb), 0); |
1088 | 1074 | ||
1089 | bail_unblock: | 1075 | bail_unblock: |
1090 | status = sigprocmask(SIG_SETMASK, &oldset, NULL); | 1076 | ocfs2_unblock_signals(&oldset); |
1091 | if (status < 0) | ||
1092 | mlog_errno(status); | ||
1093 | bail: | 1077 | bail: |
1094 | clear_inode(inode); | ||
1095 | mlog_exit_void(); | 1078 | mlog_exit_void(); |
1096 | } | 1079 | } |
1097 | 1080 | ||
1098 | void ocfs2_clear_inode(struct inode *inode) | 1081 | static void ocfs2_clear_inode(struct inode *inode) |
1099 | { | 1082 | { |
1100 | int status; | 1083 | int status; |
1101 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1084 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
1102 | 1085 | ||
1103 | mlog_entry_void(); | 1086 | mlog_entry_void(); |
1104 | 1087 | ||
1105 | if (!inode) | 1088 | end_writeback(inode); |
1106 | goto bail; | ||
1107 | |||
1108 | mlog(0, "Clearing inode: %llu, nlink = %u\n", | 1089 | mlog(0, "Clearing inode: %llu, nlink = %u\n", |
1109 | (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_nlink); | 1090 | (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_nlink); |
1110 | 1091 | ||
@@ -1123,6 +1104,10 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1123 | ocfs2_mark_lockres_freeing(&oi->ip_inode_lockres); | 1104 | ocfs2_mark_lockres_freeing(&oi->ip_inode_lockres); |
1124 | ocfs2_mark_lockres_freeing(&oi->ip_open_lockres); | 1105 | ocfs2_mark_lockres_freeing(&oi->ip_open_lockres); |
1125 | 1106 | ||
1107 | ocfs2_resv_discard(&OCFS2_SB(inode->i_sb)->osb_la_resmap, | ||
1108 | &oi->ip_la_data_resv); | ||
1109 | ocfs2_resv_init_once(&oi->ip_la_data_resv); | ||
1110 | |||
1126 | /* We very well may get a clear_inode before all an inodes | 1111 | /* We very well may get a clear_inode before all an inodes |
1127 | * metadata has hit disk. Of course, we can't drop any cluster | 1112 | * metadata has hit disk. Of course, we can't drop any cluster |
1128 | * locks until the journal has finished with it. The only | 1113 | * locks until the journal has finished with it. The only |
@@ -1192,16 +1177,27 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1192 | jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal, | 1177 | jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal, |
1193 | &oi->ip_jinode); | 1178 | &oi->ip_jinode); |
1194 | 1179 | ||
1195 | bail: | ||
1196 | mlog_exit_void(); | 1180 | mlog_exit_void(); |
1197 | } | 1181 | } |
1198 | 1182 | ||
1183 | void ocfs2_evict_inode(struct inode *inode) | ||
1184 | { | ||
1185 | if (!inode->i_nlink || | ||
1186 | (OCFS2_I(inode)->ip_flags & OCFS2_INODE_MAYBE_ORPHANED)) { | ||
1187 | ocfs2_delete_inode(inode); | ||
1188 | } else { | ||
1189 | truncate_inode_pages(&inode->i_data, 0); | ||
1190 | } | ||
1191 | ocfs2_clear_inode(inode); | ||
1192 | } | ||
1193 | |||
1199 | /* Called under inode_lock, with no more references on the | 1194 | /* Called under inode_lock, with no more references on the |
1200 | * struct inode, so it's safe here to check the flags field | 1195 | * struct inode, so it's safe here to check the flags field |
1201 | * and to manipulate i_nlink without any other locks. */ | 1196 | * and to manipulate i_nlink without any other locks. */ |
1202 | void ocfs2_drop_inode(struct inode *inode) | 1197 | int ocfs2_drop_inode(struct inode *inode) |
1203 | { | 1198 | { |
1204 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1199 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
1200 | int res; | ||
1205 | 1201 | ||
1206 | mlog_entry_void(); | 1202 | mlog_entry_void(); |
1207 | 1203 | ||
@@ -1209,11 +1205,12 @@ void ocfs2_drop_inode(struct inode *inode) | |||
1209 | (unsigned long long)oi->ip_blkno, inode->i_nlink, oi->ip_flags); | 1205 | (unsigned long long)oi->ip_blkno, inode->i_nlink, oi->ip_flags); |
1210 | 1206 | ||
1211 | if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) | 1207 | if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) |
1212 | generic_delete_inode(inode); | 1208 | res = 1; |
1213 | else | 1209 | else |
1214 | generic_drop_inode(inode); | 1210 | res = generic_drop_inode(inode); |
1215 | 1211 | ||
1216 | mlog_exit_void(); | 1212 | mlog_exit_void(); |
1213 | return res; | ||
1217 | } | 1214 | } |
1218 | 1215 | ||
1219 | /* | 1216 | /* |
@@ -1298,13 +1295,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle, | |||
1298 | fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec); | 1295 | fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec); |
1299 | fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); | 1296 | fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); |
1300 | 1297 | ||
1301 | status = ocfs2_journal_dirty(handle, bh); | 1298 | ocfs2_journal_dirty(handle, bh); |
1302 | if (status < 0) | ||
1303 | mlog_errno(status); | ||
1304 | |||
1305 | status = 0; | ||
1306 | leave: | 1299 | leave: |
1307 | |||
1308 | mlog_exit(status); | 1300 | mlog_exit(status); |
1309 | return status; | 1301 | return status; |
1310 | } | 1302 | } |