diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-07-18 03:11:46 -0400 |
---|---|---|
committer | Niv Sardi <xaiki@debian.org> | 2008-07-28 02:59:25 -0400 |
commit | 9f8868ffb39c2f80ba69df4552cb530b6634f646 (patch) | |
tree | fba09366faf55ee039cdbd91dff78b7d87a86d0b /fs/xfs/xfs_vfsops.c | |
parent | 136f8f21b6d564f553abe6130127d16fb50432d3 (diff) |
[XFS] streamline init/exit path
Currently the xfs module init/exit code is a mess. It's farmed out over a
lot of function with very little error checking. This patch makes sure we
propagate all initialization failures properly and clean up after them.
Various runtime initializations are replaced with compile-time
initializations where possible to make this easier. The exit path is
similarly consolidated.
There's now split out function to create/destroy the kmem zones and
alloc/free the trace buffers. I've also changed the ktrace allocations to
KM_MAYFAIL and handled errors resulting from that.
And yes, we really should replace the XFS_*_TRACE ifdefs with a single
XFS_TRACE..
SGI-PV: 976035
SGI-Modid: xfs-linux-melb:xfs-kern:31354a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Niv Sardi <xaiki@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_vfsops.c')
-rw-r--r-- | fs/xfs/xfs_vfsops.c | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c index 8b5a3376c2f7..4a9a43315a86 100644 --- a/fs/xfs/xfs_vfsops.c +++ b/fs/xfs/xfs_vfsops.c | |||
@@ -58,137 +58,6 @@ | |||
58 | #include "xfs_utils.h" | 58 | #include "xfs_utils.h" |
59 | 59 | ||
60 | 60 | ||
61 | int __init | ||
62 | xfs_init(void) | ||
63 | { | ||
64 | #ifdef XFS_DABUF_DEBUG | ||
65 | extern spinlock_t xfs_dabuf_global_lock; | ||
66 | spin_lock_init(&xfs_dabuf_global_lock); | ||
67 | #endif | ||
68 | |||
69 | /* | ||
70 | * Initialize all of the zone allocators we use. | ||
71 | */ | ||
72 | xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t), | ||
73 | "xfs_log_ticket"); | ||
74 | xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t), | ||
75 | "xfs_bmap_free_item"); | ||
76 | xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t), | ||
77 | "xfs_btree_cur"); | ||
78 | xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t), | ||
79 | "xfs_da_state"); | ||
80 | xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf"); | ||
81 | xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); | ||
82 | xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); | ||
83 | xfs_acl_zone_init(xfs_acl_zone, "xfs_acl"); | ||
84 | xfs_mru_cache_init(); | ||
85 | xfs_filestream_init(); | ||
86 | |||
87 | /* | ||
88 | * The size of the zone allocated buf log item is the maximum | ||
89 | * size possible under XFS. This wastes a little bit of memory, | ||
90 | * but it is much faster. | ||
91 | */ | ||
92 | xfs_buf_item_zone = | ||
93 | kmem_zone_init((sizeof(xfs_buf_log_item_t) + | ||
94 | (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) / | ||
95 | NBWORD) * sizeof(int))), | ||
96 | "xfs_buf_item"); | ||
97 | xfs_efd_zone = | ||
98 | kmem_zone_init((sizeof(xfs_efd_log_item_t) + | ||
99 | ((XFS_EFD_MAX_FAST_EXTENTS - 1) * | ||
100 | sizeof(xfs_extent_t))), | ||
101 | "xfs_efd_item"); | ||
102 | xfs_efi_zone = | ||
103 | kmem_zone_init((sizeof(xfs_efi_log_item_t) + | ||
104 | ((XFS_EFI_MAX_FAST_EXTENTS - 1) * | ||
105 | sizeof(xfs_extent_t))), | ||
106 | "xfs_efi_item"); | ||
107 | |||
108 | /* | ||
109 | * These zones warrant special memory allocator hints | ||
110 | */ | ||
111 | xfs_inode_zone = | ||
112 | kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode", | ||
113 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | | ||
114 | KM_ZONE_SPREAD, NULL); | ||
115 | xfs_ili_zone = | ||
116 | kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili", | ||
117 | KM_ZONE_SPREAD, NULL); | ||
118 | |||
119 | /* | ||
120 | * Allocate global trace buffers. | ||
121 | */ | ||
122 | #ifdef XFS_ALLOC_TRACE | ||
123 | xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_SLEEP); | ||
124 | #endif | ||
125 | #ifdef XFS_BMAP_TRACE | ||
126 | xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_SLEEP); | ||
127 | #endif | ||
128 | #ifdef XFS_BMBT_TRACE | ||
129 | xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_SLEEP); | ||
130 | #endif | ||
131 | #ifdef XFS_ATTR_TRACE | ||
132 | xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_SLEEP); | ||
133 | #endif | ||
134 | #ifdef XFS_DIR2_TRACE | ||
135 | xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_SLEEP); | ||
136 | #endif | ||
137 | |||
138 | xfs_dir_startup(); | ||
139 | |||
140 | #if (defined(DEBUG) || defined(INDUCE_IO_ERROR)) | ||
141 | xfs_error_test_init(); | ||
142 | #endif /* DEBUG || INDUCE_IO_ERROR */ | ||
143 | |||
144 | xfs_init_procfs(); | ||
145 | xfs_sysctl_register(); | ||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | void __exit | ||
150 | xfs_cleanup(void) | ||
151 | { | ||
152 | extern kmem_zone_t *xfs_inode_zone; | ||
153 | extern kmem_zone_t *xfs_efd_zone; | ||
154 | extern kmem_zone_t *xfs_efi_zone; | ||
155 | |||
156 | xfs_cleanup_procfs(); | ||
157 | xfs_sysctl_unregister(); | ||
158 | xfs_filestream_uninit(); | ||
159 | xfs_mru_cache_uninit(); | ||
160 | xfs_acl_zone_destroy(xfs_acl_zone); | ||
161 | |||
162 | #ifdef XFS_DIR2_TRACE | ||
163 | ktrace_free(xfs_dir2_trace_buf); | ||
164 | #endif | ||
165 | #ifdef XFS_ATTR_TRACE | ||
166 | ktrace_free(xfs_attr_trace_buf); | ||
167 | #endif | ||
168 | #ifdef XFS_BMBT_TRACE | ||
169 | ktrace_free(xfs_bmbt_trace_buf); | ||
170 | #endif | ||
171 | #ifdef XFS_BMAP_TRACE | ||
172 | ktrace_free(xfs_bmap_trace_buf); | ||
173 | #endif | ||
174 | #ifdef XFS_ALLOC_TRACE | ||
175 | ktrace_free(xfs_alloc_trace_buf); | ||
176 | #endif | ||
177 | |||
178 | kmem_zone_destroy(xfs_bmap_free_item_zone); | ||
179 | kmem_zone_destroy(xfs_btree_cur_zone); | ||
180 | kmem_zone_destroy(xfs_inode_zone); | ||
181 | kmem_zone_destroy(xfs_trans_zone); | ||
182 | kmem_zone_destroy(xfs_da_state_zone); | ||
183 | kmem_zone_destroy(xfs_dabuf_zone); | ||
184 | kmem_zone_destroy(xfs_buf_item_zone); | ||
185 | kmem_zone_destroy(xfs_efd_zone); | ||
186 | kmem_zone_destroy(xfs_efi_zone); | ||
187 | kmem_zone_destroy(xfs_ifork_zone); | ||
188 | kmem_zone_destroy(xfs_ili_zone); | ||
189 | kmem_zone_destroy(xfs_log_ticket_zone); | ||
190 | } | ||
191 | |||
192 | STATIC void | 61 | STATIC void |
193 | xfs_quiesce_fs( | 62 | xfs_quiesce_fs( |
194 | xfs_mount_t *mp) | 63 | xfs_mount_t *mp) |