[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>
This commit is contained in:
committed by
Niv Sardi
parent
136f8f21b6
commit
9f8868ffb3
@@ -98,12 +98,21 @@ xfs_read_xfsstats(
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
xfs_init_procfs(void)
|
xfs_init_procfs(void)
|
||||||
{
|
{
|
||||||
if (!proc_mkdir("fs/xfs", NULL))
|
if (!proc_mkdir("fs/xfs", NULL))
|
||||||
return;
|
goto out;
|
||||||
create_proc_read_entry("fs/xfs/stat", 0, NULL, xfs_read_xfsstats, NULL);
|
|
||||||
|
if (!create_proc_read_entry("fs/xfs/stat", 0, NULL,
|
||||||
|
xfs_read_xfsstats, NULL))
|
||||||
|
goto out_remove_entry;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
out_remove_entry:
|
||||||
|
remove_proc_entry("fs/xfs", NULL);
|
||||||
|
out:
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -134,7 +134,7 @@ DECLARE_PER_CPU(struct xfsstats, xfsstats);
|
|||||||
#define XFS_STATS_DEC(v) (per_cpu(xfsstats, current_cpu()).v--)
|
#define XFS_STATS_DEC(v) (per_cpu(xfsstats, current_cpu()).v--)
|
||||||
#define XFS_STATS_ADD(v, inc) (per_cpu(xfsstats, current_cpu()).v += (inc))
|
#define XFS_STATS_ADD(v, inc) (per_cpu(xfsstats, current_cpu()).v += (inc))
|
||||||
|
|
||||||
extern void xfs_init_procfs(void);
|
extern int xfs_init_procfs(void);
|
||||||
extern void xfs_cleanup_procfs(void);
|
extern void xfs_cleanup_procfs(void);
|
||||||
|
|
||||||
|
|
||||||
@@ -144,8 +144,13 @@ extern void xfs_cleanup_procfs(void);
|
|||||||
# define XFS_STATS_DEC(count)
|
# define XFS_STATS_DEC(count)
|
||||||
# define XFS_STATS_ADD(count, inc)
|
# define XFS_STATS_ADD(count, inc)
|
||||||
|
|
||||||
static inline void xfs_init_procfs(void) { };
|
static inline int xfs_init_procfs(void)
|
||||||
static inline void xfs_cleanup_procfs(void) { };
|
{
|
||||||
|
return 0
|
||||||
|
};
|
||||||
|
static inline void xfs_cleanup_procfs(void)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* !CONFIG_PROC_FS */
|
#endif /* !CONFIG_PROC_FS */
|
||||||
|
|
||||||
|
@@ -53,6 +53,11 @@
|
|||||||
#include "xfs_log_priv.h"
|
#include "xfs_log_priv.h"
|
||||||
#include "xfs_trans_priv.h"
|
#include "xfs_trans_priv.h"
|
||||||
#include "xfs_filestream.h"
|
#include "xfs_filestream.h"
|
||||||
|
#include "xfs_da_btree.h"
|
||||||
|
#include "xfs_dir2_trace.h"
|
||||||
|
#include "xfs_extfree_item.h"
|
||||||
|
#include "xfs_mru_cache.h"
|
||||||
|
#include "xfs_inode_item.h"
|
||||||
|
|
||||||
#include <linux/namei.h>
|
#include <linux/namei.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
@@ -987,42 +992,6 @@ xfs_fs_inode_init_once(
|
|||||||
inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
|
inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int __init
|
|
||||||
xfs_init_zones(void)
|
|
||||||
{
|
|
||||||
xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode",
|
|
||||||
KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
|
|
||||||
KM_ZONE_SPREAD,
|
|
||||||
xfs_fs_inode_init_once);
|
|
||||||
if (!xfs_vnode_zone)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
|
|
||||||
if (!xfs_ioend_zone)
|
|
||||||
goto out_destroy_vnode_zone;
|
|
||||||
|
|
||||||
xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
|
|
||||||
xfs_ioend_zone);
|
|
||||||
if (!xfs_ioend_pool)
|
|
||||||
goto out_free_ioend_zone;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
out_free_ioend_zone:
|
|
||||||
kmem_zone_destroy(xfs_ioend_zone);
|
|
||||||
out_destroy_vnode_zone:
|
|
||||||
kmem_zone_destroy(xfs_vnode_zone);
|
|
||||||
out:
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC void
|
|
||||||
xfs_destroy_zones(void)
|
|
||||||
{
|
|
||||||
mempool_destroy(xfs_ioend_pool);
|
|
||||||
kmem_zone_destroy(xfs_vnode_zone);
|
|
||||||
kmem_zone_destroy(xfs_ioend_zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to flush the inode, this will actually fail
|
* Attempt to flush the inode, this will actually fail
|
||||||
* if the inode is pinned, but we dirty the inode again
|
* if the inode is pinned, but we dirty the inode again
|
||||||
@@ -1939,9 +1908,235 @@ static struct file_system_type xfs_fs_type = {
|
|||||||
.fs_flags = FS_REQUIRES_DEV,
|
.fs_flags = FS_REQUIRES_DEV,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
STATIC int __init
|
||||||
|
xfs_alloc_trace_bufs(void)
|
||||||
|
{
|
||||||
|
#ifdef XFS_ALLOC_TRACE
|
||||||
|
xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL);
|
||||||
|
if (!xfs_alloc_trace_buf)
|
||||||
|
goto out;
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_BMAP_TRACE
|
||||||
|
xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL);
|
||||||
|
if (!xfs_bmap_trace_buf)
|
||||||
|
goto out_free_alloc_trace;
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_BMBT_TRACE
|
||||||
|
xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
|
||||||
|
if (!xfs_bmbt_trace_buf)
|
||||||
|
goto out_free_bmap_trace;
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_ATTR_TRACE
|
||||||
|
xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
|
||||||
|
if (!xfs_attr_trace_buf)
|
||||||
|
goto out_free_bmbt_trace;
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_DIR2_TRACE
|
||||||
|
xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL);
|
||||||
|
if (!xfs_dir2_trace_buf)
|
||||||
|
goto out_free_attr_trace;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#ifdef XFS_DIR2_TRACE
|
||||||
|
out_free_attr_trace:
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_ATTR_TRACE
|
||||||
|
ktrace_free(xfs_attr_trace_buf);
|
||||||
|
out_free_bmbt_trace:
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_BMBT_TRACE
|
||||||
|
ktrace_free(xfs_bmbt_trace_buf);
|
||||||
|
out_free_bmap_trace:
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_BMAP_TRACE
|
||||||
|
ktrace_free(xfs_bmap_trace_buf);
|
||||||
|
out_free_alloc_trace:
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_ALLOC_TRACE
|
||||||
|
ktrace_free(xfs_alloc_trace_buf);
|
||||||
|
out:
|
||||||
|
#endif
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC void
|
||||||
|
xfs_free_trace_bufs(void)
|
||||||
|
{
|
||||||
|
#ifdef XFS_DIR2_TRACE
|
||||||
|
ktrace_free(xfs_dir2_trace_buf);
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_ATTR_TRACE
|
||||||
|
ktrace_free(xfs_attr_trace_buf);
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_BMBT_TRACE
|
||||||
|
ktrace_free(xfs_bmbt_trace_buf);
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_BMAP_TRACE
|
||||||
|
ktrace_free(xfs_bmap_trace_buf);
|
||||||
|
#endif
|
||||||
|
#ifdef XFS_ALLOC_TRACE
|
||||||
|
ktrace_free(xfs_alloc_trace_buf);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
STATIC int __init
|
STATIC int __init
|
||||||
init_xfs_fs( void )
|
xfs_init_zones(void)
|
||||||
|
{
|
||||||
|
xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode",
|
||||||
|
KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
|
||||||
|
KM_ZONE_SPREAD,
|
||||||
|
xfs_fs_inode_init_once);
|
||||||
|
if (!xfs_vnode_zone)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
|
||||||
|
if (!xfs_ioend_zone)
|
||||||
|
goto out_destroy_vnode_zone;
|
||||||
|
|
||||||
|
xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
|
||||||
|
xfs_ioend_zone);
|
||||||
|
if (!xfs_ioend_pool)
|
||||||
|
goto out_destroy_ioend_zone;
|
||||||
|
|
||||||
|
xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
|
||||||
|
"xfs_log_ticket");
|
||||||
|
if (!xfs_log_ticket_zone)
|
||||||
|
goto out_destroy_ioend_pool;
|
||||||
|
|
||||||
|
xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
|
||||||
|
"xfs_bmap_free_item");
|
||||||
|
if (!xfs_bmap_free_item_zone)
|
||||||
|
goto out_destroy_log_ticket_zone;
|
||||||
|
xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
|
||||||
|
"xfs_btree_cur");
|
||||||
|
if (!xfs_btree_cur_zone)
|
||||||
|
goto out_destroy_bmap_free_item_zone;
|
||||||
|
|
||||||
|
xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
|
||||||
|
"xfs_da_state");
|
||||||
|
if (!xfs_da_state_zone)
|
||||||
|
goto out_destroy_btree_cur_zone;
|
||||||
|
|
||||||
|
xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
|
||||||
|
if (!xfs_dabuf_zone)
|
||||||
|
goto out_destroy_da_state_zone;
|
||||||
|
|
||||||
|
xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
|
||||||
|
if (!xfs_ifork_zone)
|
||||||
|
goto out_destroy_dabuf_zone;
|
||||||
|
|
||||||
|
xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
|
||||||
|
if (!xfs_trans_zone)
|
||||||
|
goto out_destroy_ifork_zone;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of the zone allocated buf log item is the maximum
|
||||||
|
* size possible under XFS. This wastes a little bit of memory,
|
||||||
|
* but it is much faster.
|
||||||
|
*/
|
||||||
|
xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) +
|
||||||
|
(((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
|
||||||
|
NBWORD) * sizeof(int))), "xfs_buf_item");
|
||||||
|
if (!xfs_buf_item_zone)
|
||||||
|
goto out_destroy_trans_zone;
|
||||||
|
|
||||||
|
xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
|
||||||
|
((XFS_EFD_MAX_FAST_EXTENTS - 1) *
|
||||||
|
sizeof(xfs_extent_t))), "xfs_efd_item");
|
||||||
|
if (!xfs_efd_zone)
|
||||||
|
goto out_destroy_buf_item_zone;
|
||||||
|
|
||||||
|
xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
|
||||||
|
((XFS_EFI_MAX_FAST_EXTENTS - 1) *
|
||||||
|
sizeof(xfs_extent_t))), "xfs_efi_item");
|
||||||
|
if (!xfs_efi_zone)
|
||||||
|
goto out_destroy_efd_zone;
|
||||||
|
|
||||||
|
xfs_inode_zone =
|
||||||
|
kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
|
||||||
|
KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
|
||||||
|
KM_ZONE_SPREAD, NULL);
|
||||||
|
if (!xfs_inode_zone)
|
||||||
|
goto out_destroy_efi_zone;
|
||||||
|
|
||||||
|
xfs_ili_zone =
|
||||||
|
kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
|
||||||
|
KM_ZONE_SPREAD, NULL);
|
||||||
|
if (!xfs_ili_zone)
|
||||||
|
goto out_destroy_inode_zone;
|
||||||
|
|
||||||
|
#ifdef CONFIG_XFS_POSIX_ACL
|
||||||
|
xfs_acl_zone = kmem_zone_init(sizeof(xfs_acl_t), "xfs_acl");
|
||||||
|
if (!xfs_acl_zone)
|
||||||
|
goto out_destroy_ili_zone;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#ifdef CONFIG_XFS_POSIX_ACL
|
||||||
|
out_destroy_ili_zone:
|
||||||
|
#endif
|
||||||
|
kmem_zone_destroy(xfs_ili_zone);
|
||||||
|
out_destroy_inode_zone:
|
||||||
|
kmem_zone_destroy(xfs_inode_zone);
|
||||||
|
out_destroy_efi_zone:
|
||||||
|
kmem_zone_destroy(xfs_efi_zone);
|
||||||
|
out_destroy_efd_zone:
|
||||||
|
kmem_zone_destroy(xfs_efd_zone);
|
||||||
|
out_destroy_buf_item_zone:
|
||||||
|
kmem_zone_destroy(xfs_buf_item_zone);
|
||||||
|
out_destroy_trans_zone:
|
||||||
|
kmem_zone_destroy(xfs_trans_zone);
|
||||||
|
out_destroy_ifork_zone:
|
||||||
|
kmem_zone_destroy(xfs_ifork_zone);
|
||||||
|
out_destroy_dabuf_zone:
|
||||||
|
kmem_zone_destroy(xfs_dabuf_zone);
|
||||||
|
out_destroy_da_state_zone:
|
||||||
|
kmem_zone_destroy(xfs_da_state_zone);
|
||||||
|
out_destroy_btree_cur_zone:
|
||||||
|
kmem_zone_destroy(xfs_btree_cur_zone);
|
||||||
|
out_destroy_bmap_free_item_zone:
|
||||||
|
kmem_zone_destroy(xfs_bmap_free_item_zone);
|
||||||
|
out_destroy_log_ticket_zone:
|
||||||
|
kmem_zone_destroy(xfs_log_ticket_zone);
|
||||||
|
out_destroy_ioend_pool:
|
||||||
|
mempool_destroy(xfs_ioend_pool);
|
||||||
|
out_destroy_ioend_zone:
|
||||||
|
kmem_zone_destroy(xfs_ioend_zone);
|
||||||
|
out_destroy_vnode_zone:
|
||||||
|
kmem_zone_destroy(xfs_vnode_zone);
|
||||||
|
out:
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC void
|
||||||
|
xfs_destroy_zones(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_XFS_POSIX_ACL
|
||||||
|
kmem_zone_destroy(xfs_acl_zone);
|
||||||
|
#endif
|
||||||
|
kmem_zone_destroy(xfs_ili_zone);
|
||||||
|
kmem_zone_destroy(xfs_inode_zone);
|
||||||
|
kmem_zone_destroy(xfs_efi_zone);
|
||||||
|
kmem_zone_destroy(xfs_efd_zone);
|
||||||
|
kmem_zone_destroy(xfs_buf_item_zone);
|
||||||
|
kmem_zone_destroy(xfs_trans_zone);
|
||||||
|
kmem_zone_destroy(xfs_ifork_zone);
|
||||||
|
kmem_zone_destroy(xfs_dabuf_zone);
|
||||||
|
kmem_zone_destroy(xfs_da_state_zone);
|
||||||
|
kmem_zone_destroy(xfs_btree_cur_zone);
|
||||||
|
kmem_zone_destroy(xfs_bmap_free_item_zone);
|
||||||
|
kmem_zone_destroy(xfs_log_ticket_zone);
|
||||||
|
mempool_destroy(xfs_ioend_pool);
|
||||||
|
kmem_zone_destroy(xfs_ioend_zone);
|
||||||
|
kmem_zone_destroy(xfs_vnode_zone);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC int __init
|
||||||
|
init_xfs_fs(void)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
static char message[] __initdata = KERN_INFO \
|
static char message[] __initdata = KERN_INFO \
|
||||||
@@ -1950,42 +2145,73 @@ init_xfs_fs( void )
|
|||||||
printk(message);
|
printk(message);
|
||||||
|
|
||||||
ktrace_init(64);
|
ktrace_init(64);
|
||||||
|
vn_init();
|
||||||
|
xfs_dir_startup();
|
||||||
|
|
||||||
error = xfs_init_zones();
|
error = xfs_init_zones();
|
||||||
if (error < 0)
|
if (error)
|
||||||
goto undo_zones;
|
goto out;
|
||||||
|
|
||||||
|
error = xfs_alloc_trace_bufs();
|
||||||
|
if (error)
|
||||||
|
goto out_destroy_zones;
|
||||||
|
|
||||||
|
error = xfs_mru_cache_init();
|
||||||
|
if (error)
|
||||||
|
goto out_free_trace_buffers;
|
||||||
|
|
||||||
|
error = xfs_filestream_init();
|
||||||
|
if (error)
|
||||||
|
goto out_mru_cache_uninit;
|
||||||
|
|
||||||
error = xfs_buf_init();
|
error = xfs_buf_init();
|
||||||
if (error < 0)
|
if (error)
|
||||||
goto undo_buffers;
|
goto out_filestream_uninit;
|
||||||
|
|
||||||
|
error = xfs_init_procfs();
|
||||||
|
if (error)
|
||||||
|
goto out_buf_terminate;
|
||||||
|
|
||||||
|
error = xfs_sysctl_register();
|
||||||
|
if (error)
|
||||||
|
goto out_cleanup_procfs;
|
||||||
|
|
||||||
vn_init();
|
|
||||||
xfs_init();
|
|
||||||
uuid_init();
|
|
||||||
vfs_initquota();
|
vfs_initquota();
|
||||||
|
|
||||||
error = register_filesystem(&xfs_fs_type);
|
error = register_filesystem(&xfs_fs_type);
|
||||||
if (error)
|
if (error)
|
||||||
goto undo_register;
|
goto out_sysctl_unregister;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
undo_register:
|
out_sysctl_unregister:
|
||||||
|
xfs_sysctl_unregister();
|
||||||
|
out_cleanup_procfs:
|
||||||
|
xfs_cleanup_procfs();
|
||||||
|
out_buf_terminate:
|
||||||
xfs_buf_terminate();
|
xfs_buf_terminate();
|
||||||
|
out_filestream_uninit:
|
||||||
undo_buffers:
|
xfs_filestream_uninit();
|
||||||
|
out_mru_cache_uninit:
|
||||||
|
xfs_mru_cache_uninit();
|
||||||
|
out_free_trace_buffers:
|
||||||
|
xfs_free_trace_bufs();
|
||||||
|
out_destroy_zones:
|
||||||
xfs_destroy_zones();
|
xfs_destroy_zones();
|
||||||
|
out:
|
||||||
undo_zones:
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void __exit
|
STATIC void __exit
|
||||||
exit_xfs_fs( void )
|
exit_xfs_fs(void)
|
||||||
{
|
{
|
||||||
vfs_exitquota();
|
vfs_exitquota();
|
||||||
unregister_filesystem(&xfs_fs_type);
|
unregister_filesystem(&xfs_fs_type);
|
||||||
xfs_cleanup();
|
xfs_sysctl_unregister();
|
||||||
|
xfs_cleanup_procfs();
|
||||||
xfs_buf_terminate();
|
xfs_buf_terminate();
|
||||||
|
xfs_filestream_uninit();
|
||||||
|
xfs_mru_cache_uninit();
|
||||||
|
xfs_free_trace_bufs();
|
||||||
xfs_destroy_zones();
|
xfs_destroy_zones();
|
||||||
ktrace_uninit();
|
ktrace_uninit();
|
||||||
}
|
}
|
||||||
|
@@ -259,15 +259,17 @@ static ctl_table xfs_root_table[] = {
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
int
|
||||||
xfs_sysctl_register(void)
|
xfs_sysctl_register(void)
|
||||||
{
|
{
|
||||||
xfs_table_header = register_sysctl_table(xfs_root_table);
|
xfs_table_header = register_sysctl_table(xfs_root_table);
|
||||||
|
if (!xfs_table_header)
|
||||||
|
return -ENOMEM;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xfs_sysctl_unregister(void)
|
xfs_sysctl_unregister(void)
|
||||||
{
|
{
|
||||||
if (xfs_table_header)
|
unregister_sysctl_table(xfs_table_header);
|
||||||
unregister_sysctl_table(xfs_table_header);
|
|
||||||
}
|
}
|
||||||
|
@@ -93,10 +93,10 @@ enum {
|
|||||||
extern xfs_param_t xfs_params;
|
extern xfs_param_t xfs_params;
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL
|
#ifdef CONFIG_SYSCTL
|
||||||
extern void xfs_sysctl_register(void);
|
extern int xfs_sysctl_register(void);
|
||||||
extern void xfs_sysctl_unregister(void);
|
extern void xfs_sysctl_unregister(void);
|
||||||
#else
|
#else
|
||||||
# define xfs_sysctl_register() do { } while (0)
|
# define xfs_sysctl_register() (0)
|
||||||
# define xfs_sysctl_unregister() do { } while (0)
|
# define xfs_sysctl_unregister() do { } while (0)
|
||||||
#endif /* CONFIG_SYSCTL */
|
#endif /* CONFIG_SYSCTL */
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <xfs.h>
|
#include <xfs.h>
|
||||||
|
|
||||||
static mutex_t uuid_monitor;
|
static DEFINE_MUTEX(uuid_monitor);
|
||||||
static int uuid_table_size;
|
static int uuid_table_size;
|
||||||
static uuid_t *uuid_table;
|
static uuid_t *uuid_table;
|
||||||
|
|
||||||
@@ -132,9 +132,3 @@ uuid_table_remove(uuid_t *uuid)
|
|||||||
ASSERT(i < uuid_table_size);
|
ASSERT(i < uuid_table_size);
|
||||||
mutex_unlock(&uuid_monitor);
|
mutex_unlock(&uuid_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init
|
|
||||||
uuid_init(void)
|
|
||||||
{
|
|
||||||
mutex_init(&uuid_monitor);
|
|
||||||
}
|
|
||||||
|
@@ -22,7 +22,6 @@ typedef struct {
|
|||||||
unsigned char __u_bits[16];
|
unsigned char __u_bits[16];
|
||||||
} uuid_t;
|
} uuid_t;
|
||||||
|
|
||||||
extern void uuid_init(void);
|
|
||||||
extern void uuid_create_nil(uuid_t *uuid);
|
extern void uuid_create_nil(uuid_t *uuid);
|
||||||
extern int uuid_is_nil(uuid_t *uuid);
|
extern int uuid_is_nil(uuid_t *uuid);
|
||||||
extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
|
extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
|
||||||
|
@@ -2240,7 +2240,7 @@ xfs_da_state_free(xfs_da_state_t *state)
|
|||||||
|
|
||||||
#ifdef XFS_DABUF_DEBUG
|
#ifdef XFS_DABUF_DEBUG
|
||||||
xfs_dabuf_t *xfs_dabuf_global_list;
|
xfs_dabuf_t *xfs_dabuf_global_list;
|
||||||
spinlock_t xfs_dabuf_global_lock;
|
static DEFINE_SPINLOCK(xfs_dabuf_global_lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -66,14 +66,6 @@ int xfs_etest[XFS_NUM_INJECT_ERROR];
|
|||||||
int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR];
|
int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR];
|
||||||
char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR];
|
char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR];
|
||||||
|
|
||||||
void
|
|
||||||
xfs_error_test_init(void)
|
|
||||||
{
|
|
||||||
memset(xfs_etest, 0, sizeof(xfs_etest));
|
|
||||||
memset(xfs_etest_fsid, 0, sizeof(xfs_etest_fsid));
|
|
||||||
memset(xfs_etest_fsname, 0, sizeof(xfs_etest_fsname));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xfs_error_test(int error_tag, int *fsidp, char *expression,
|
xfs_error_test(int error_tag, int *fsidp, char *expression,
|
||||||
int line, char *file, unsigned long randfactor)
|
int line, char *file, unsigned long randfactor)
|
||||||
|
@@ -127,7 +127,6 @@ extern void xfs_corruption_error(char *tag, int level, struct xfs_mount *mp,
|
|||||||
|
|
||||||
#if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
|
#if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
|
||||||
extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
|
extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
|
||||||
extern void xfs_error_test_init(void);
|
|
||||||
|
|
||||||
#define XFS_NUM_INJECT_ERROR 10
|
#define XFS_NUM_INJECT_ERROR 10
|
||||||
|
|
||||||
|
@@ -397,10 +397,12 @@ int
|
|||||||
xfs_filestream_init(void)
|
xfs_filestream_init(void)
|
||||||
{
|
{
|
||||||
item_zone = kmem_zone_init(sizeof(fstrm_item_t), "fstrm_item");
|
item_zone = kmem_zone_init(sizeof(fstrm_item_t), "fstrm_item");
|
||||||
|
if (!item_zone)
|
||||||
|
return -ENOMEM;
|
||||||
#ifdef XFS_FILESTREAMS_TRACE
|
#ifdef XFS_FILESTREAMS_TRACE
|
||||||
xfs_filestreams_trace_buf = ktrace_alloc(XFS_FSTRM_KTRACE_SIZE, KM_SLEEP);
|
xfs_filestreams_trace_buf = ktrace_alloc(XFS_FSTRM_KTRACE_SIZE, KM_SLEEP);
|
||||||
#endif
|
#endif
|
||||||
return item_zone ? 0 : -ENOMEM;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -546,9 +546,6 @@ extern void xfs_qmops_put(struct xfs_mount *);
|
|||||||
|
|
||||||
extern struct xfs_dmops xfs_dmcore_xfs;
|
extern struct xfs_dmops xfs_dmcore_xfs;
|
||||||
|
|
||||||
extern int xfs_init(void);
|
|
||||||
extern void xfs_cleanup(void);
|
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
#endif /* __XFS_MOUNT_H__ */
|
#endif /* __XFS_MOUNT_H__ */
|
||||||
|
@@ -307,15 +307,18 @@ xfs_mru_cache_init(void)
|
|||||||
xfs_mru_elem_zone = kmem_zone_init(sizeof(xfs_mru_cache_elem_t),
|
xfs_mru_elem_zone = kmem_zone_init(sizeof(xfs_mru_cache_elem_t),
|
||||||
"xfs_mru_cache_elem");
|
"xfs_mru_cache_elem");
|
||||||
if (!xfs_mru_elem_zone)
|
if (!xfs_mru_elem_zone)
|
||||||
return ENOMEM;
|
goto out;
|
||||||
|
|
||||||
xfs_mru_reap_wq = create_singlethread_workqueue("xfs_mru_cache");
|
xfs_mru_reap_wq = create_singlethread_workqueue("xfs_mru_cache");
|
||||||
if (!xfs_mru_reap_wq) {
|
if (!xfs_mru_reap_wq)
|
||||||
kmem_zone_destroy(xfs_mru_elem_zone);
|
goto out_destroy_mru_elem_zone;
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_destroy_mru_elem_zone:
|
||||||
|
kmem_zone_destroy(xfs_mru_elem_zone);
|
||||||
|
out:
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -58,137 +58,6 @@
|
|||||||
#include "xfs_utils.h"
|
#include "xfs_utils.h"
|
||||||
|
|
||||||
|
|
||||||
int __init
|
|
||||||
xfs_init(void)
|
|
||||||
{
|
|
||||||
#ifdef XFS_DABUF_DEBUG
|
|
||||||
extern spinlock_t xfs_dabuf_global_lock;
|
|
||||||
spin_lock_init(&xfs_dabuf_global_lock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize all of the zone allocators we use.
|
|
||||||
*/
|
|
||||||
xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
|
|
||||||
"xfs_log_ticket");
|
|
||||||
xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
|
|
||||||
"xfs_bmap_free_item");
|
|
||||||
xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
|
|
||||||
"xfs_btree_cur");
|
|
||||||
xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
|
|
||||||
"xfs_da_state");
|
|
||||||
xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
|
|
||||||
xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
|
|
||||||
xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
|
|
||||||
xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
|
|
||||||
xfs_mru_cache_init();
|
|
||||||
xfs_filestream_init();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The size of the zone allocated buf log item is the maximum
|
|
||||||
* size possible under XFS. This wastes a little bit of memory,
|
|
||||||
* but it is much faster.
|
|
||||||
*/
|
|
||||||
xfs_buf_item_zone =
|
|
||||||
kmem_zone_init((sizeof(xfs_buf_log_item_t) +
|
|
||||||
(((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
|
|
||||||
NBWORD) * sizeof(int))),
|
|
||||||
"xfs_buf_item");
|
|
||||||
xfs_efd_zone =
|
|
||||||
kmem_zone_init((sizeof(xfs_efd_log_item_t) +
|
|
||||||
((XFS_EFD_MAX_FAST_EXTENTS - 1) *
|
|
||||||
sizeof(xfs_extent_t))),
|
|
||||||
"xfs_efd_item");
|
|
||||||
xfs_efi_zone =
|
|
||||||
kmem_zone_init((sizeof(xfs_efi_log_item_t) +
|
|
||||||
((XFS_EFI_MAX_FAST_EXTENTS - 1) *
|
|
||||||
sizeof(xfs_extent_t))),
|
|
||||||
"xfs_efi_item");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These zones warrant special memory allocator hints
|
|
||||||
*/
|
|
||||||
xfs_inode_zone =
|
|
||||||
kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
|
|
||||||
KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
|
|
||||||
KM_ZONE_SPREAD, NULL);
|
|
||||||
xfs_ili_zone =
|
|
||||||
kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
|
|
||||||
KM_ZONE_SPREAD, NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate global trace buffers.
|
|
||||||
*/
|
|
||||||
#ifdef XFS_ALLOC_TRACE
|
|
||||||
xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_SLEEP);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_BMAP_TRACE
|
|
||||||
xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_SLEEP);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_BMBT_TRACE
|
|
||||||
xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_SLEEP);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_ATTR_TRACE
|
|
||||||
xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_SLEEP);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_DIR2_TRACE
|
|
||||||
xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_SLEEP);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
xfs_dir_startup();
|
|
||||||
|
|
||||||
#if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
|
|
||||||
xfs_error_test_init();
|
|
||||||
#endif /* DEBUG || INDUCE_IO_ERROR */
|
|
||||||
|
|
||||||
xfs_init_procfs();
|
|
||||||
xfs_sysctl_register();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __exit
|
|
||||||
xfs_cleanup(void)
|
|
||||||
{
|
|
||||||
extern kmem_zone_t *xfs_inode_zone;
|
|
||||||
extern kmem_zone_t *xfs_efd_zone;
|
|
||||||
extern kmem_zone_t *xfs_efi_zone;
|
|
||||||
|
|
||||||
xfs_cleanup_procfs();
|
|
||||||
xfs_sysctl_unregister();
|
|
||||||
xfs_filestream_uninit();
|
|
||||||
xfs_mru_cache_uninit();
|
|
||||||
xfs_acl_zone_destroy(xfs_acl_zone);
|
|
||||||
|
|
||||||
#ifdef XFS_DIR2_TRACE
|
|
||||||
ktrace_free(xfs_dir2_trace_buf);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_ATTR_TRACE
|
|
||||||
ktrace_free(xfs_attr_trace_buf);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_BMBT_TRACE
|
|
||||||
ktrace_free(xfs_bmbt_trace_buf);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_BMAP_TRACE
|
|
||||||
ktrace_free(xfs_bmap_trace_buf);
|
|
||||||
#endif
|
|
||||||
#ifdef XFS_ALLOC_TRACE
|
|
||||||
ktrace_free(xfs_alloc_trace_buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
kmem_zone_destroy(xfs_bmap_free_item_zone);
|
|
||||||
kmem_zone_destroy(xfs_btree_cur_zone);
|
|
||||||
kmem_zone_destroy(xfs_inode_zone);
|
|
||||||
kmem_zone_destroy(xfs_trans_zone);
|
|
||||||
kmem_zone_destroy(xfs_da_state_zone);
|
|
||||||
kmem_zone_destroy(xfs_dabuf_zone);
|
|
||||||
kmem_zone_destroy(xfs_buf_item_zone);
|
|
||||||
kmem_zone_destroy(xfs_efd_zone);
|
|
||||||
kmem_zone_destroy(xfs_efi_zone);
|
|
||||||
kmem_zone_destroy(xfs_ifork_zone);
|
|
||||||
kmem_zone_destroy(xfs_ili_zone);
|
|
||||||
kmem_zone_destroy(xfs_log_ticket_zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
xfs_quiesce_fs(
|
xfs_quiesce_fs(
|
||||||
xfs_mount_t *mp)
|
xfs_mount_t *mp)
|
||||||
|
Reference in New Issue
Block a user