diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_super.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 348 |
1 files changed, 184 insertions, 164 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 18a4b8e11df2..71345a370d9f 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * along with this program; if not, write the Free Software Foundation, | 15 | * along with this program; if not, write the Free Software Foundation, |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ | 17 | */ |
18 | |||
18 | #include "xfs.h" | 19 | #include "xfs.h" |
19 | #include "xfs_bit.h" | 20 | #include "xfs_bit.h" |
20 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
@@ -52,11 +53,11 @@ | |||
52 | #include "xfs_trans_priv.h" | 53 | #include "xfs_trans_priv.h" |
53 | #include "xfs_filestream.h" | 54 | #include "xfs_filestream.h" |
54 | #include "xfs_da_btree.h" | 55 | #include "xfs_da_btree.h" |
55 | #include "xfs_dir2_trace.h" | ||
56 | #include "xfs_extfree_item.h" | 56 | #include "xfs_extfree_item.h" |
57 | #include "xfs_mru_cache.h" | 57 | #include "xfs_mru_cache.h" |
58 | #include "xfs_inode_item.h" | 58 | #include "xfs_inode_item.h" |
59 | #include "xfs_sync.h" | 59 | #include "xfs_sync.h" |
60 | #include "xfs_trace.h" | ||
60 | 61 | ||
61 | #include <linux/namei.h> | 62 | #include <linux/namei.h> |
62 | #include <linux/init.h> | 63 | #include <linux/init.h> |
@@ -876,12 +877,11 @@ xfsaild( | |||
876 | { | 877 | { |
877 | struct xfs_ail *ailp = data; | 878 | struct xfs_ail *ailp = data; |
878 | xfs_lsn_t last_pushed_lsn = 0; | 879 | xfs_lsn_t last_pushed_lsn = 0; |
879 | long tout = 0; | 880 | long tout = 0; /* milliseconds */ |
880 | 881 | ||
881 | while (!kthread_should_stop()) { | 882 | while (!kthread_should_stop()) { |
882 | if (tout) | 883 | schedule_timeout_interruptible(tout ? |
883 | schedule_timeout_interruptible(msecs_to_jiffies(tout)); | 884 | msecs_to_jiffies(tout) : MAX_SCHEDULE_TIMEOUT); |
884 | tout = 1000; | ||
885 | 885 | ||
886 | /* swsusp */ | 886 | /* swsusp */ |
887 | try_to_freeze(); | 887 | try_to_freeze(); |
@@ -930,13 +930,37 @@ xfs_fs_alloc_inode( | |||
930 | */ | 930 | */ |
931 | STATIC void | 931 | STATIC void |
932 | xfs_fs_destroy_inode( | 932 | xfs_fs_destroy_inode( |
933 | struct inode *inode) | 933 | struct inode *inode) |
934 | { | 934 | { |
935 | xfs_inode_t *ip = XFS_I(inode); | 935 | struct xfs_inode *ip = XFS_I(inode); |
936 | |||
937 | xfs_itrace_entry(ip); | ||
936 | 938 | ||
937 | XFS_STATS_INC(vn_reclaim); | 939 | XFS_STATS_INC(vn_reclaim); |
938 | if (xfs_reclaim(ip)) | 940 | |
939 | panic("%s: cannot reclaim 0x%p\n", __func__, inode); | 941 | /* bad inode, get out here ASAP */ |
942 | if (is_bad_inode(inode)) | ||
943 | goto out_reclaim; | ||
944 | |||
945 | xfs_ioend_wait(ip); | ||
946 | |||
947 | ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0); | ||
948 | |||
949 | /* | ||
950 | * We should never get here with one of the reclaim flags already set. | ||
951 | */ | ||
952 | ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIMABLE)); | ||
953 | ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIM)); | ||
954 | |||
955 | /* | ||
956 | * We always use background reclaim here because even if the | ||
957 | * inode is clean, it still may be under IO and hence we have | ||
958 | * to take the flush lock. The background reclaim path handles | ||
959 | * this more efficiently than we can here, so simply let background | ||
960 | * reclaim tear down all inodes. | ||
961 | */ | ||
962 | out_reclaim: | ||
963 | xfs_inode_set_reclaim_tag(ip); | ||
940 | } | 964 | } |
941 | 965 | ||
942 | /* | 966 | /* |
@@ -973,7 +997,6 @@ xfs_fs_inode_init_once( | |||
973 | 997 | ||
974 | mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, | 998 | mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, |
975 | "xfsino", ip->i_ino); | 999 | "xfsino", ip->i_ino); |
976 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); | ||
977 | } | 1000 | } |
978 | 1001 | ||
979 | /* | 1002 | /* |
@@ -998,59 +1021,108 @@ xfs_fs_dirty_inode( | |||
998 | XFS_I(inode)->i_update_core = 1; | 1021 | XFS_I(inode)->i_update_core = 1; |
999 | } | 1022 | } |
1000 | 1023 | ||
1001 | /* | 1024 | STATIC int |
1002 | * Attempt to flush the inode, this will actually fail | 1025 | xfs_log_inode( |
1003 | * if the inode is pinned, but we dirty the inode again | 1026 | struct xfs_inode *ip) |
1004 | * at the point when it is unpinned after a log write, | 1027 | { |
1005 | * since this is when the inode itself becomes flushable. | 1028 | struct xfs_mount *mp = ip->i_mount; |
1006 | */ | 1029 | struct xfs_trans *tp; |
1030 | int error; | ||
1031 | |||
1032 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
1033 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); | ||
1034 | error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); | ||
1035 | |||
1036 | if (error) { | ||
1037 | xfs_trans_cancel(tp, 0); | ||
1038 | /* we need to return with the lock hold shared */ | ||
1039 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
1040 | return error; | ||
1041 | } | ||
1042 | |||
1043 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
1044 | |||
1045 | /* | ||
1046 | * Note - it's possible that we might have pushed ourselves out of the | ||
1047 | * way during trans_reserve which would flush the inode. But there's | ||
1048 | * no guarantee that the inode buffer has actually gone out yet (it's | ||
1049 | * delwri). Plus the buffer could be pinned anyway if it's part of | ||
1050 | * an inode in another recent transaction. So we play it safe and | ||
1051 | * fire off the transaction anyway. | ||
1052 | */ | ||
1053 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | ||
1054 | xfs_trans_ihold(tp, ip); | ||
1055 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
1056 | xfs_trans_set_sync(tp); | ||
1057 | error = xfs_trans_commit(tp, 0); | ||
1058 | xfs_ilock_demote(ip, XFS_ILOCK_EXCL); | ||
1059 | |||
1060 | return error; | ||
1061 | } | ||
1062 | |||
1007 | STATIC int | 1063 | STATIC int |
1008 | xfs_fs_write_inode( | 1064 | xfs_fs_write_inode( |
1009 | struct inode *inode, | 1065 | struct inode *inode, |
1010 | int sync) | 1066 | struct writeback_control *wbc) |
1011 | { | 1067 | { |
1012 | struct xfs_inode *ip = XFS_I(inode); | 1068 | struct xfs_inode *ip = XFS_I(inode); |
1013 | struct xfs_mount *mp = ip->i_mount; | 1069 | struct xfs_mount *mp = ip->i_mount; |
1014 | int error = 0; | 1070 | int error = EAGAIN; |
1015 | 1071 | ||
1016 | xfs_itrace_entry(ip); | 1072 | xfs_itrace_entry(ip); |
1017 | 1073 | ||
1018 | if (XFS_FORCED_SHUTDOWN(mp)) | 1074 | if (XFS_FORCED_SHUTDOWN(mp)) |
1019 | return XFS_ERROR(EIO); | 1075 | return XFS_ERROR(EIO); |
1020 | 1076 | ||
1021 | if (sync) { | 1077 | if (wbc->sync_mode == WB_SYNC_ALL) { |
1022 | error = xfs_wait_on_pages(ip, 0, -1); | 1078 | /* |
1023 | if (error) | 1079 | * Make sure the inode has hit stable storage. By using the |
1080 | * log and the fsync transactions we reduce the IOs we have | ||
1081 | * to do here from two (log and inode) to just the log. | ||
1082 | * | ||
1083 | * Note: We still need to do a delwri write of the inode after | ||
1084 | * this to flush it to the backing buffer so that bulkstat | ||
1085 | * works properly if this is the first time the inode has been | ||
1086 | * written. Because we hold the ilock atomically over the | ||
1087 | * transaction commit and the inode flush we are guaranteed | ||
1088 | * that the inode is not pinned when it returns. If the flush | ||
1089 | * lock is already held, then the inode has already been | ||
1090 | * flushed once and we don't need to flush it again. Hence | ||
1091 | * the code will only flush the inode if it isn't already | ||
1092 | * being flushed. | ||
1093 | */ | ||
1094 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
1095 | if (ip->i_update_core) { | ||
1096 | error = xfs_log_inode(ip); | ||
1097 | if (error) | ||
1098 | goto out_unlock; | ||
1099 | } | ||
1100 | } else { | ||
1101 | /* | ||
1102 | * We make this non-blocking if the inode is contended, return | ||
1103 | * EAGAIN to indicate to the caller that they did not succeed. | ||
1104 | * This prevents the flush path from blocking on inodes inside | ||
1105 | * another operation right now, they get caught later by xfs_sync. | ||
1106 | */ | ||
1107 | if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) | ||
1024 | goto out; | 1108 | goto out; |
1025 | } | 1109 | } |
1026 | 1110 | ||
1027 | /* | 1111 | if (xfs_ipincount(ip) || !xfs_iflock_nowait(ip)) |
1028 | * Bypass inodes which have already been cleaned by | 1112 | goto out_unlock; |
1029 | * the inode flush clustering code inside xfs_iflush | ||
1030 | */ | ||
1031 | if (xfs_inode_clean(ip)) | ||
1032 | goto out; | ||
1033 | 1113 | ||
1034 | /* | 1114 | /* |
1035 | * We make this non-blocking if the inode is contended, return | 1115 | * Now we have the flush lock and the inode is not pinned, we can check |
1036 | * EAGAIN to indicate to the caller that they did not succeed. | 1116 | * if the inode is really clean as we know that there are no pending |
1037 | * This prevents the flush path from blocking on inodes inside | 1117 | * transaction completions, it is not waiting on the delayed write |
1038 | * another operation right now, they get caught later by xfs_sync. | 1118 | * queue and there is no IO in progress. |
1039 | */ | 1119 | */ |
1040 | if (sync) { | 1120 | if (xfs_inode_clean(ip)) { |
1041 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 1121 | xfs_ifunlock(ip); |
1042 | xfs_iflock(ip); | 1122 | error = 0; |
1043 | 1123 | goto out_unlock; | |
1044 | error = xfs_iflush(ip, XFS_IFLUSH_SYNC); | ||
1045 | } else { | ||
1046 | error = EAGAIN; | ||
1047 | if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) | ||
1048 | goto out; | ||
1049 | if (xfs_ipincount(ip) || !xfs_iflock_nowait(ip)) | ||
1050 | goto out_unlock; | ||
1051 | |||
1052 | error = xfs_iflush(ip, XFS_IFLUSH_ASYNC_NOBLOCK); | ||
1053 | } | 1124 | } |
1125 | error = xfs_iflush(ip, 0); | ||
1054 | 1126 | ||
1055 | out_unlock: | 1127 | out_unlock: |
1056 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 1128 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
@@ -1075,6 +1147,20 @@ xfs_fs_clear_inode( | |||
1075 | XFS_STATS_INC(vn_remove); | 1147 | XFS_STATS_INC(vn_remove); |
1076 | XFS_STATS_DEC(vn_active); | 1148 | XFS_STATS_DEC(vn_active); |
1077 | 1149 | ||
1150 | /* | ||
1151 | * The iolock is used by the file system to coordinate reads, | ||
1152 | * writes, and block truncates. Up to this point the lock | ||
1153 | * protected concurrent accesses by users of the inode. But | ||
1154 | * from here forward we're doing some final processing of the | ||
1155 | * inode because we're done with it, and although we reuse the | ||
1156 | * iolock for protection it is really a distinct lock class | ||
1157 | * (in the lockdep sense) from before. To keep lockdep happy | ||
1158 | * (and basically indicate what we are doing), we explicitly | ||
1159 | * re-init the iolock here. | ||
1160 | */ | ||
1161 | ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock)); | ||
1162 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); | ||
1163 | |||
1078 | xfs_inactive(ip); | 1164 | xfs_inactive(ip); |
1079 | } | 1165 | } |
1080 | 1166 | ||
@@ -1092,8 +1178,6 @@ xfs_fs_put_super( | |||
1092 | struct super_block *sb) | 1178 | struct super_block *sb) |
1093 | { | 1179 | { |
1094 | struct xfs_mount *mp = XFS_M(sb); | 1180 | struct xfs_mount *mp = XFS_M(sb); |
1095 | struct xfs_inode *rip = mp->m_rootip; | ||
1096 | int unmount_event_flags = 0; | ||
1097 | 1181 | ||
1098 | xfs_syncd_stop(mp); | 1182 | xfs_syncd_stop(mp); |
1099 | 1183 | ||
@@ -1109,20 +1193,7 @@ xfs_fs_put_super( | |||
1109 | xfs_sync_attr(mp, 0); | 1193 | xfs_sync_attr(mp, 0); |
1110 | } | 1194 | } |
1111 | 1195 | ||
1112 | #ifdef HAVE_DMAPI | 1196 | XFS_SEND_PREUNMOUNT(mp); |
1113 | if (mp->m_flags & XFS_MOUNT_DMAPI) { | ||
1114 | unmount_event_flags = | ||
1115 | (mp->m_dmevmask & (1 << DM_EVENT_UNMOUNT)) ? | ||
1116 | 0 : DM_FLAGS_UNWANTED; | ||
1117 | /* | ||
1118 | * Ignore error from dmapi here, first unmount is not allowed | ||
1119 | * to fail anyway, and second we wouldn't want to fail a | ||
1120 | * unmount because of dmapi. | ||
1121 | */ | ||
1122 | XFS_SEND_PREUNMOUNT(mp, rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL, | ||
1123 | NULL, NULL, 0, 0, unmount_event_flags); | ||
1124 | } | ||
1125 | #endif | ||
1126 | 1197 | ||
1127 | /* | 1198 | /* |
1128 | * Blow away any referenced inode in the filestreams cache. | 1199 | * Blow away any referenced inode in the filestreams cache. |
@@ -1133,10 +1204,7 @@ xfs_fs_put_super( | |||
1133 | 1204 | ||
1134 | XFS_bflush(mp->m_ddev_targp); | 1205 | XFS_bflush(mp->m_ddev_targp); |
1135 | 1206 | ||
1136 | if (mp->m_flags & XFS_MOUNT_DMAPI) { | 1207 | XFS_SEND_UNMOUNT(mp); |
1137 | XFS_SEND_UNMOUNT(mp, rip, DM_RIGHT_NULL, 0, 0, | ||
1138 | unmount_event_flags); | ||
1139 | } | ||
1140 | 1208 | ||
1141 | xfs_unmountfs(mp); | 1209 | xfs_unmountfs(mp); |
1142 | xfs_freesb(mp); | 1210 | xfs_freesb(mp); |
@@ -1237,6 +1305,29 @@ xfs_fs_statfs( | |||
1237 | return 0; | 1305 | return 0; |
1238 | } | 1306 | } |
1239 | 1307 | ||
1308 | STATIC void | ||
1309 | xfs_save_resvblks(struct xfs_mount *mp) | ||
1310 | { | ||
1311 | __uint64_t resblks = 0; | ||
1312 | |||
1313 | mp->m_resblks_save = mp->m_resblks; | ||
1314 | xfs_reserve_blocks(mp, &resblks, NULL); | ||
1315 | } | ||
1316 | |||
1317 | STATIC void | ||
1318 | xfs_restore_resvblks(struct xfs_mount *mp) | ||
1319 | { | ||
1320 | __uint64_t resblks; | ||
1321 | |||
1322 | if (mp->m_resblks_save) { | ||
1323 | resblks = mp->m_resblks_save; | ||
1324 | mp->m_resblks_save = 0; | ||
1325 | } else | ||
1326 | resblks = xfs_default_resblks(mp); | ||
1327 | |||
1328 | xfs_reserve_blocks(mp, &resblks, NULL); | ||
1329 | } | ||
1330 | |||
1240 | STATIC int | 1331 | STATIC int |
1241 | xfs_fs_remount( | 1332 | xfs_fs_remount( |
1242 | struct super_block *sb, | 1333 | struct super_block *sb, |
@@ -1316,11 +1407,27 @@ xfs_fs_remount( | |||
1316 | } | 1407 | } |
1317 | mp->m_update_flags = 0; | 1408 | mp->m_update_flags = 0; |
1318 | } | 1409 | } |
1410 | |||
1411 | /* | ||
1412 | * Fill out the reserve pool if it is empty. Use the stashed | ||
1413 | * value if it is non-zero, otherwise go with the default. | ||
1414 | */ | ||
1415 | xfs_restore_resvblks(mp); | ||
1319 | } | 1416 | } |
1320 | 1417 | ||
1321 | /* rw -> ro */ | 1418 | /* rw -> ro */ |
1322 | if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { | 1419 | if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { |
1420 | /* | ||
1421 | * After we have synced the data but before we sync the | ||
1422 | * metadata, we need to free up the reserve block pool so that | ||
1423 | * the used block count in the superblock on disk is correct at | ||
1424 | * the end of the remount. Stash the current reserve pool size | ||
1425 | * so that if we get remounted rw, we can return it to the same | ||
1426 | * size. | ||
1427 | */ | ||
1428 | |||
1323 | xfs_quiesce_data(mp); | 1429 | xfs_quiesce_data(mp); |
1430 | xfs_save_resvblks(mp); | ||
1324 | xfs_quiesce_attr(mp); | 1431 | xfs_quiesce_attr(mp); |
1325 | mp->m_flags |= XFS_MOUNT_RDONLY; | 1432 | mp->m_flags |= XFS_MOUNT_RDONLY; |
1326 | } | 1433 | } |
@@ -1339,11 +1446,22 @@ xfs_fs_freeze( | |||
1339 | { | 1446 | { |
1340 | struct xfs_mount *mp = XFS_M(sb); | 1447 | struct xfs_mount *mp = XFS_M(sb); |
1341 | 1448 | ||
1449 | xfs_save_resvblks(mp); | ||
1342 | xfs_quiesce_attr(mp); | 1450 | xfs_quiesce_attr(mp); |
1343 | return -xfs_fs_log_dummy(mp); | 1451 | return -xfs_fs_log_dummy(mp); |
1344 | } | 1452 | } |
1345 | 1453 | ||
1346 | STATIC int | 1454 | STATIC int |
1455 | xfs_fs_unfreeze( | ||
1456 | struct super_block *sb) | ||
1457 | { | ||
1458 | struct xfs_mount *mp = XFS_M(sb); | ||
1459 | |||
1460 | xfs_restore_resvblks(mp); | ||
1461 | return 0; | ||
1462 | } | ||
1463 | |||
1464 | STATIC int | ||
1347 | xfs_fs_show_options( | 1465 | xfs_fs_show_options( |
1348 | struct seq_file *m, | 1466 | struct seq_file *m, |
1349 | struct vfsmount *mnt) | 1467 | struct vfsmount *mnt) |
@@ -1504,8 +1622,6 @@ xfs_fs_fill_super( | |||
1504 | goto fail_vnrele; | 1622 | goto fail_vnrele; |
1505 | 1623 | ||
1506 | kfree(mtpt); | 1624 | kfree(mtpt); |
1507 | |||
1508 | xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); | ||
1509 | return 0; | 1625 | return 0; |
1510 | 1626 | ||
1511 | out_filestream_unmount: | 1627 | out_filestream_unmount: |
@@ -1567,6 +1683,7 @@ static const struct super_operations xfs_super_operations = { | |||
1567 | .put_super = xfs_fs_put_super, | 1683 | .put_super = xfs_fs_put_super, |
1568 | .sync_fs = xfs_fs_sync_fs, | 1684 | .sync_fs = xfs_fs_sync_fs, |
1569 | .freeze_fs = xfs_fs_freeze, | 1685 | .freeze_fs = xfs_fs_freeze, |
1686 | .unfreeze_fs = xfs_fs_unfreeze, | ||
1570 | .statfs = xfs_fs_statfs, | 1687 | .statfs = xfs_fs_statfs, |
1571 | .remount_fs = xfs_fs_remount, | 1688 | .remount_fs = xfs_fs_remount, |
1572 | .show_options = xfs_fs_show_options, | 1689 | .show_options = xfs_fs_show_options, |
@@ -1581,94 +1698,6 @@ static struct file_system_type xfs_fs_type = { | |||
1581 | }; | 1698 | }; |
1582 | 1699 | ||
1583 | STATIC int __init | 1700 | STATIC int __init |
1584 | xfs_alloc_trace_bufs(void) | ||
1585 | { | ||
1586 | #ifdef XFS_ALLOC_TRACE | ||
1587 | xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL); | ||
1588 | if (!xfs_alloc_trace_buf) | ||
1589 | goto out; | ||
1590 | #endif | ||
1591 | #ifdef XFS_BMAP_TRACE | ||
1592 | xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL); | ||
1593 | if (!xfs_bmap_trace_buf) | ||
1594 | goto out_free_alloc_trace; | ||
1595 | #endif | ||
1596 | #ifdef XFS_BTREE_TRACE | ||
1597 | xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE, | ||
1598 | KM_MAYFAIL); | ||
1599 | if (!xfs_allocbt_trace_buf) | ||
1600 | goto out_free_bmap_trace; | ||
1601 | |||
1602 | xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL); | ||
1603 | if (!xfs_inobt_trace_buf) | ||
1604 | goto out_free_allocbt_trace; | ||
1605 | |||
1606 | xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL); | ||
1607 | if (!xfs_bmbt_trace_buf) | ||
1608 | goto out_free_inobt_trace; | ||
1609 | #endif | ||
1610 | #ifdef XFS_ATTR_TRACE | ||
1611 | xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL); | ||
1612 | if (!xfs_attr_trace_buf) | ||
1613 | goto out_free_bmbt_trace; | ||
1614 | #endif | ||
1615 | #ifdef XFS_DIR2_TRACE | ||
1616 | xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL); | ||
1617 | if (!xfs_dir2_trace_buf) | ||
1618 | goto out_free_attr_trace; | ||
1619 | #endif | ||
1620 | |||
1621 | return 0; | ||
1622 | |||
1623 | #ifdef XFS_DIR2_TRACE | ||
1624 | out_free_attr_trace: | ||
1625 | #endif | ||
1626 | #ifdef XFS_ATTR_TRACE | ||
1627 | ktrace_free(xfs_attr_trace_buf); | ||
1628 | out_free_bmbt_trace: | ||
1629 | #endif | ||
1630 | #ifdef XFS_BTREE_TRACE | ||
1631 | ktrace_free(xfs_bmbt_trace_buf); | ||
1632 | out_free_inobt_trace: | ||
1633 | ktrace_free(xfs_inobt_trace_buf); | ||
1634 | out_free_allocbt_trace: | ||
1635 | ktrace_free(xfs_allocbt_trace_buf); | ||
1636 | out_free_bmap_trace: | ||
1637 | #endif | ||
1638 | #ifdef XFS_BMAP_TRACE | ||
1639 | ktrace_free(xfs_bmap_trace_buf); | ||
1640 | out_free_alloc_trace: | ||
1641 | #endif | ||
1642 | #ifdef XFS_ALLOC_TRACE | ||
1643 | ktrace_free(xfs_alloc_trace_buf); | ||
1644 | out: | ||
1645 | #endif | ||
1646 | return -ENOMEM; | ||
1647 | } | ||
1648 | |||
1649 | STATIC void | ||
1650 | xfs_free_trace_bufs(void) | ||
1651 | { | ||
1652 | #ifdef XFS_DIR2_TRACE | ||
1653 | ktrace_free(xfs_dir2_trace_buf); | ||
1654 | #endif | ||
1655 | #ifdef XFS_ATTR_TRACE | ||
1656 | ktrace_free(xfs_attr_trace_buf); | ||
1657 | #endif | ||
1658 | #ifdef XFS_BTREE_TRACE | ||
1659 | ktrace_free(xfs_bmbt_trace_buf); | ||
1660 | ktrace_free(xfs_inobt_trace_buf); | ||
1661 | ktrace_free(xfs_allocbt_trace_buf); | ||
1662 | #endif | ||
1663 | #ifdef XFS_BMAP_TRACE | ||
1664 | ktrace_free(xfs_bmap_trace_buf); | ||
1665 | #endif | ||
1666 | #ifdef XFS_ALLOC_TRACE | ||
1667 | ktrace_free(xfs_alloc_trace_buf); | ||
1668 | #endif | ||
1669 | } | ||
1670 | |||
1671 | STATIC int __init | ||
1672 | xfs_init_zones(void) | 1701 | xfs_init_zones(void) |
1673 | { | 1702 | { |
1674 | 1703 | ||
@@ -1809,7 +1838,6 @@ init_xfs_fs(void) | |||
1809 | printk(KERN_INFO XFS_VERSION_STRING " with " | 1838 | printk(KERN_INFO XFS_VERSION_STRING " with " |
1810 | XFS_BUILD_OPTIONS " enabled\n"); | 1839 | XFS_BUILD_OPTIONS " enabled\n"); |
1811 | 1840 | ||
1812 | ktrace_init(64); | ||
1813 | xfs_ioend_init(); | 1841 | xfs_ioend_init(); |
1814 | xfs_dir_startup(); | 1842 | xfs_dir_startup(); |
1815 | 1843 | ||
@@ -1817,13 +1845,9 @@ init_xfs_fs(void) | |||
1817 | if (error) | 1845 | if (error) |
1818 | goto out; | 1846 | goto out; |
1819 | 1847 | ||
1820 | error = xfs_alloc_trace_bufs(); | ||
1821 | if (error) | ||
1822 | goto out_destroy_zones; | ||
1823 | |||
1824 | error = xfs_mru_cache_init(); | 1848 | error = xfs_mru_cache_init(); |
1825 | if (error) | 1849 | if (error) |
1826 | goto out_free_trace_buffers; | 1850 | goto out_destroy_zones; |
1827 | 1851 | ||
1828 | error = xfs_filestream_init(); | 1852 | error = xfs_filestream_init(); |
1829 | if (error) | 1853 | if (error) |
@@ -1858,8 +1882,6 @@ init_xfs_fs(void) | |||
1858 | xfs_filestream_uninit(); | 1882 | xfs_filestream_uninit(); |
1859 | out_mru_cache_uninit: | 1883 | out_mru_cache_uninit: |
1860 | xfs_mru_cache_uninit(); | 1884 | xfs_mru_cache_uninit(); |
1861 | out_free_trace_buffers: | ||
1862 | xfs_free_trace_bufs(); | ||
1863 | out_destroy_zones: | 1885 | out_destroy_zones: |
1864 | xfs_destroy_zones(); | 1886 | xfs_destroy_zones(); |
1865 | out: | 1887 | out: |
@@ -1876,9 +1898,7 @@ exit_xfs_fs(void) | |||
1876 | xfs_buf_terminate(); | 1898 | xfs_buf_terminate(); |
1877 | xfs_filestream_uninit(); | 1899 | xfs_filestream_uninit(); |
1878 | xfs_mru_cache_uninit(); | 1900 | xfs_mru_cache_uninit(); |
1879 | xfs_free_trace_bufs(); | ||
1880 | xfs_destroy_zones(); | 1901 | xfs_destroy_zones(); |
1881 | ktrace_uninit(); | ||
1882 | } | 1902 | } |
1883 | 1903 | ||
1884 | module_init(init_xfs_fs); | 1904 | module_init(init_xfs_fs); |