1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light Super operations
6 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DEBUG_SUBSYSTEM S_LLITE
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/random.h>
29 #include <linux/version.h>
30 #include <lustre_lite.h>
31 #include <lustre_ha.h>
32 #include <lustre_dlm.h>
33 #include <linux/init.h>
35 #include <lprocfs_status.h>
36 #include "llite_internal.h"
38 static cfs_mem_cache_t *ll_inode_cachep;
40 static struct inode *ll_alloc_inode(struct super_block *sb)
42 struct ll_inode_info *lli;
43 ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1);
44 OBD_SLAB_ALLOC_PTR(lli, ll_inode_cachep);
48 inode_init_once(&lli->lli_vfs_inode);
51 return &lli->lli_vfs_inode;
54 static void ll_destroy_inode(struct inode *inode)
56 struct ll_inode_info *ptr = ll_i2info(inode);
57 OBD_SLAB_FREE_PTR(ptr, ll_inode_cachep);
60 int ll_init_inodecache(void)
62 ll_inode_cachep = cfs_mem_cache_create("lustre_inode_cache",
63 sizeof(struct ll_inode_info),
64 0, SLAB_HWCACHE_ALIGN);
65 if (ll_inode_cachep == NULL)
70 void ll_destroy_inodecache(void)
74 rc = cfs_mem_cache_destroy(ll_inode_cachep);
75 LASSERTF(rc == 0, "ll_inode_cache: not all structures were freed\n");
78 /* exported operations */
79 struct super_operations lustre_super_operations =
81 .alloc_inode = ll_alloc_inode,
82 .destroy_inode = ll_destroy_inode,
83 .clear_inode = ll_clear_inode,
84 .put_super = ll_put_super,
86 .umount_begin = ll_umount_begin,
87 .remount_fs = ll_remount_fs,
91 void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
93 static int __init init_lustre_lite(void)
97 lnet_process_id_t lnet_id;
99 printk(KERN_INFO "Lustre: Lustre Client File System; "
100 "info@clusterfs.com\n");
101 rc = ll_init_inodecache();
104 ll_file_data_slab = cfs_mem_cache_create("ll_file_data",
105 sizeof(struct ll_file_data), 0,
107 if (ll_file_data_slab == NULL) {
108 ll_destroy_inodecache();
112 proc_lustre_fs_root = proc_lustre_root ?
113 proc_mkdir("llite", proc_lustre_root) : NULL;
115 ll_register_cache(&ll_cache_definition);
117 lustre_register_client_fill_super(ll_fill_super);
118 lustre_register_client_process_config(ll_process_config);
120 ll_get_random_bytes(seed, sizeof(seed));
122 /* Nodes with small feet have little entropy
123 * the NID for this node gives the most entropy in the low bits */
125 if (LNetGetId(i, &lnet_id) == -ENOENT) {
128 if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
129 seed[0] ^= LNET_NIDADDR(lnet_id.nid);
133 do_gettimeofday(&tv);
134 ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
139 static void __exit exit_lustre_lite(void)
143 lustre_register_client_fill_super(NULL);
144 lustre_register_client_process_config(NULL);
146 ll_unregister_cache(&ll_cache_definition);
148 ll_destroy_inodecache();
149 rc = cfs_mem_cache_destroy(ll_file_data_slab);
150 LASSERTF(rc == 0, "couldn't destroy ll_file_data slab\n");
152 if (ll_async_page_slab) {
153 rc = cfs_mem_cache_destroy(ll_async_page_slab);
154 LASSERTF(rc == 0, "couldn't destroy ll_async_page slab\n");
157 if (proc_lustre_fs_root)
158 lprocfs_remove(&proc_lustre_fs_root);
161 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
162 MODULE_DESCRIPTION("Lustre Lite Client File System");
163 MODULE_LICENSE("GPL");
165 module_init(init_lustre_lite);
166 module_exit(exit_lustre_lite);