diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_super.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 175 |
1 files changed, 49 insertions, 126 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 18a4b8e11df2..09783cc444ac 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> |
@@ -930,13 +931,39 @@ xfs_fs_alloc_inode( | |||
930 | */ | 931 | */ |
931 | STATIC void | 932 | STATIC void |
932 | xfs_fs_destroy_inode( | 933 | xfs_fs_destroy_inode( |
933 | struct inode *inode) | 934 | struct inode *inode) |
934 | { | 935 | { |
935 | xfs_inode_t *ip = XFS_I(inode); | 936 | struct xfs_inode *ip = XFS_I(inode); |
937 | |||
938 | xfs_itrace_entry(ip); | ||
936 | 939 | ||
937 | XFS_STATS_INC(vn_reclaim); | 940 | XFS_STATS_INC(vn_reclaim); |
938 | if (xfs_reclaim(ip)) | 941 | |
939 | panic("%s: cannot reclaim 0x%p\n", __func__, inode); | 942 | /* bad inode, get out here ASAP */ |
943 | if (is_bad_inode(inode)) | ||
944 | goto out_reclaim; | ||
945 | |||
946 | xfs_ioend_wait(ip); | ||
947 | |||
948 | ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0); | ||
949 | |||
950 | /* | ||
951 | * We should never get here with one of the reclaim flags already set. | ||
952 | */ | ||
953 | ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIMABLE)); | ||
954 | ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIM)); | ||
955 | |||
956 | /* | ||
957 | * If we have nothing to flush with this inode then complete the | ||
958 | * teardown now, otherwise delay the flush operation. | ||
959 | */ | ||
960 | if (!xfs_inode_clean(ip)) { | ||
961 | xfs_inode_set_reclaim_tag(ip); | ||
962 | return; | ||
963 | } | ||
964 | |||
965 | out_reclaim: | ||
966 | xfs_ireclaim(ip); | ||
940 | } | 967 | } |
941 | 968 | ||
942 | /* | 969 | /* |
@@ -973,7 +1000,6 @@ xfs_fs_inode_init_once( | |||
973 | 1000 | ||
974 | mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, | 1001 | mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, |
975 | "xfsino", ip->i_ino); | 1002 | "xfsino", ip->i_ino); |
976 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); | ||
977 | } | 1003 | } |
978 | 1004 | ||
979 | /* | 1005 | /* |
@@ -1075,6 +1101,20 @@ xfs_fs_clear_inode( | |||
1075 | XFS_STATS_INC(vn_remove); | 1101 | XFS_STATS_INC(vn_remove); |
1076 | XFS_STATS_DEC(vn_active); | 1102 | XFS_STATS_DEC(vn_active); |
1077 | 1103 | ||
1104 | /* | ||
1105 | * The iolock is used by the file system to coordinate reads, | ||
1106 | * writes, and block truncates. Up to this point the lock | ||
1107 | * protected concurrent accesses by users of the inode. But | ||
1108 | * from here forward we're doing some final processing of the | ||
1109 | * inode because we're done with it, and although we reuse the | ||
1110 | * iolock for protection it is really a distinct lock class | ||
1111 | * (in the lockdep sense) from before. To keep lockdep happy | ||
1112 | * (and basically indicate what we are doing), we explicitly | ||
1113 | * re-init the iolock here. | ||
1114 | */ | ||
1115 | ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock)); | ||
1116 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); | ||
1117 | |||
1078 | xfs_inactive(ip); | 1118 | xfs_inactive(ip); |
1079 | } | 1119 | } |
1080 | 1120 | ||
@@ -1092,8 +1132,6 @@ xfs_fs_put_super( | |||
1092 | struct super_block *sb) | 1132 | struct super_block *sb) |
1093 | { | 1133 | { |
1094 | struct xfs_mount *mp = XFS_M(sb); | 1134 | struct xfs_mount *mp = XFS_M(sb); |
1095 | struct xfs_inode *rip = mp->m_rootip; | ||
1096 | int unmount_event_flags = 0; | ||
1097 | 1135 | ||
1098 | xfs_syncd_stop(mp); | 1136 | xfs_syncd_stop(mp); |
1099 | 1137 | ||
@@ -1109,20 +1147,7 @@ xfs_fs_put_super( | |||
1109 | xfs_sync_attr(mp, 0); | 1147 | xfs_sync_attr(mp, 0); |
1110 | } | 1148 | } |
1111 | 1149 | ||
1112 | #ifdef HAVE_DMAPI | 1150 | 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 | 1151 | ||
1127 | /* | 1152 | /* |
1128 | * Blow away any referenced inode in the filestreams cache. | 1153 | * Blow away any referenced inode in the filestreams cache. |
@@ -1133,10 +1158,7 @@ xfs_fs_put_super( | |||
1133 | 1158 | ||
1134 | XFS_bflush(mp->m_ddev_targp); | 1159 | XFS_bflush(mp->m_ddev_targp); |
1135 | 1160 | ||
1136 | if (mp->m_flags & XFS_MOUNT_DMAPI) { | 1161 | XFS_SEND_UNMOUNT(mp); |
1137 | XFS_SEND_UNMOUNT(mp, rip, DM_RIGHT_NULL, 0, 0, | ||
1138 | unmount_event_flags); | ||
1139 | } | ||
1140 | 1162 | ||
1141 | xfs_unmountfs(mp); | 1163 | xfs_unmountfs(mp); |
1142 | xfs_freesb(mp); | 1164 | xfs_freesb(mp); |
@@ -1504,8 +1526,6 @@ xfs_fs_fill_super( | |||
1504 | goto fail_vnrele; | 1526 | goto fail_vnrele; |
1505 | 1527 | ||
1506 | kfree(mtpt); | 1528 | kfree(mtpt); |
1507 | |||
1508 | xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); | ||
1509 | return 0; | 1529 | return 0; |
1510 | 1530 | ||
1511 | out_filestream_unmount: | 1531 | out_filestream_unmount: |
@@ -1581,94 +1601,6 @@ static struct file_system_type xfs_fs_type = { | |||
1581 | }; | 1601 | }; |
1582 | 1602 | ||
1583 | STATIC int __init | 1603 | 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) | 1604 | xfs_init_zones(void) |
1673 | { | 1605 | { |
1674 | 1606 | ||
@@ -1809,7 +1741,6 @@ init_xfs_fs(void) | |||
1809 | printk(KERN_INFO XFS_VERSION_STRING " with " | 1741 | printk(KERN_INFO XFS_VERSION_STRING " with " |
1810 | XFS_BUILD_OPTIONS " enabled\n"); | 1742 | XFS_BUILD_OPTIONS " enabled\n"); |
1811 | 1743 | ||
1812 | ktrace_init(64); | ||
1813 | xfs_ioend_init(); | 1744 | xfs_ioend_init(); |
1814 | xfs_dir_startup(); | 1745 | xfs_dir_startup(); |
1815 | 1746 | ||
@@ -1817,13 +1748,9 @@ init_xfs_fs(void) | |||
1817 | if (error) | 1748 | if (error) |
1818 | goto out; | 1749 | goto out; |
1819 | 1750 | ||
1820 | error = xfs_alloc_trace_bufs(); | ||
1821 | if (error) | ||
1822 | goto out_destroy_zones; | ||
1823 | |||
1824 | error = xfs_mru_cache_init(); | 1751 | error = xfs_mru_cache_init(); |
1825 | if (error) | 1752 | if (error) |
1826 | goto out_free_trace_buffers; | 1753 | goto out_destroy_zones; |
1827 | 1754 | ||
1828 | error = xfs_filestream_init(); | 1755 | error = xfs_filestream_init(); |
1829 | if (error) | 1756 | if (error) |
@@ -1858,8 +1785,6 @@ init_xfs_fs(void) | |||
1858 | xfs_filestream_uninit(); | 1785 | xfs_filestream_uninit(); |
1859 | out_mru_cache_uninit: | 1786 | out_mru_cache_uninit: |
1860 | xfs_mru_cache_uninit(); | 1787 | xfs_mru_cache_uninit(); |
1861 | out_free_trace_buffers: | ||
1862 | xfs_free_trace_bufs(); | ||
1863 | out_destroy_zones: | 1788 | out_destroy_zones: |
1864 | xfs_destroy_zones(); | 1789 | xfs_destroy_zones(); |
1865 | out: | 1790 | out: |
@@ -1876,9 +1801,7 @@ exit_xfs_fs(void) | |||
1876 | xfs_buf_terminate(); | 1801 | xfs_buf_terminate(); |
1877 | xfs_filestream_uninit(); | 1802 | xfs_filestream_uninit(); |
1878 | xfs_mru_cache_uninit(); | 1803 | xfs_mru_cache_uninit(); |
1879 | xfs_free_trace_bufs(); | ||
1880 | xfs_destroy_zones(); | 1804 | xfs_destroy_zones(); |
1881 | ktrace_uninit(); | ||
1882 | } | 1805 | } |
1883 | 1806 | ||
1884 | module_init(init_xfs_fs); | 1807 | module_init(init_xfs_fs); |