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 <linux/lustre_lite.h>
31 #include <linux/lustre_ha.h>
32 #include <linux/lustre_dlm.h>
33 #include <linux/init.h>
35 #include <linux/lprocfs_status.h>
36 #include <linux/obd_support.h>
37 #include "llite_internal.h"
39 struct super_block * ll_get_sb(struct file_system_type *fs_type,
40 int flags, const char *devname, void * data)
42 /* calls back in fill super */
43 return get_sb_nodev(fs_type, flags, data, ll_fill_super);
46 struct super_block * lustre_get_sb(struct file_system_type *fs_type,
47 int flags, const char *devname, void * data)
49 /* calls back in fill super */
50 return get_sb_nodev(fs_type, flags, data, lustre_fill_super);
53 static kmem_cache_t *ll_inode_cachep;
55 static struct inode *ll_alloc_inode(struct super_block *sb)
57 struct ll_inode_info *lli;
58 lprocfs_counter_incr((ll_s2sbi(sb))->ll_stats, LPROC_LL_ALLOC_INODE);
59 OBD_SLAB_ALLOC(lli, ll_inode_cachep, SLAB_KERNEL, sizeof *lli);
63 inode_init_once(&lli->lli_vfs_inode);
66 return &lli->lli_vfs_inode;
69 static void ll_destroy_inode(struct inode *inode)
71 struct ll_inode_info *ptr = ll_i2info(inode);
72 OBD_SLAB_FREE(ptr, ll_inode_cachep, sizeof(*ptr));
75 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
77 struct ll_inode_info *lli = foo;
79 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
80 SLAB_CTOR_CONSTRUCTOR)
81 inode_init_once(&lli->lli_vfs_inode);
84 int ll_init_inodecache(void)
86 ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
87 sizeof(struct ll_inode_info),
88 0, SLAB_HWCACHE_ALIGN,
90 if (ll_inode_cachep == NULL)
95 void ll_destroy_inodecache(void)
97 LASSERTF(kmem_cache_destroy(ll_inode_cachep) == 0,
98 "ll_inode_cache: not all structures were freed\n");
101 static void ll_umount_lustre(struct super_block *sb)
103 struct ll_sb_info *sbi = ll_s2sbi(sb);
104 LASSERT((sbi->ll_flags & LL_SBI_UMOUNT) == 0);
105 sbi->ll_flags |= LL_SBI_UMOUNT;
106 ll_gns_check_mounts(sbi, LL_GNS_UMOUNT);
109 /* exported operations */
110 struct super_operations lustre_super_operations =
112 .alloc_inode = ll_alloc_inode,
113 .destroy_inode = ll_destroy_inode,
114 .clear_inode = ll_clear_inode,
115 .put_super = lustre_put_super,
117 .umount_begin = ll_umount_begin,
118 .umount_lustre = ll_umount_lustre,
119 .show_options = ll_show_options,
122 struct file_system_type lustre_lite_fs_type = {
123 .owner = THIS_MODULE,
124 .name = "lustre_lite",
126 .kill_sb = kill_anon_super,
127 .fs_flags = FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
130 struct file_system_type lustre_fs_type = {
131 .owner = THIS_MODULE,
133 .get_sb = lustre_get_sb,
134 .kill_sb = kill_anon_super,
135 .fs_flags = FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
138 static int __init init_lustre_lite(void)
142 printk(KERN_INFO "Lustre: Lustre Lite Client File System; "
143 "info@clusterfs.com\n");
145 rc = ll_init_inodecache();
149 ll_file_data_slab = kmem_cache_create("ll_file_data",
150 sizeof(struct ll_file_data), 0,
151 SLAB_HWCACHE_ALIGN, NULL, NULL);
152 if (ll_file_data_slab == NULL) {
156 ll_intent_slab = kmem_cache_create("lustre_intent_data",
157 sizeof(struct lustre_intent_data),
158 0, SLAB_HWCACHE_ALIGN, NULL,
160 if (ll_intent_slab == NULL) {
161 kmem_cache_destroy(ll_file_data_slab);
162 ll_destroy_inodecache();
167 proc_lustre_fs_root = proc_lustre_root ?
168 proc_mkdir("llite", proc_lustre_root) : NULL;
170 rc = register_filesystem(&lustre_lite_fs_type);
175 rc = register_filesystem(&lustre_fs_type);
180 rc = ll_gns_thread_start();
184 ll_capa_timer.function = ll_capa_timer_callback;
185 ll_capa_timer.data = 0;
186 init_timer(&ll_capa_timer);
188 rc = ll_capa_thread_start();
196 unregister_filesystem(&lustre_fs_type);
198 unregister_filesystem(&lustre_lite_fs_type);
200 ll_destroy_inodecache();
205 static void __exit exit_lustre_lite(void)
207 unregister_filesystem(&lustre_fs_type);
208 unregister_filesystem(&lustre_lite_fs_type);
210 del_timer(&ll_capa_timer);
211 ll_capa_thread_stop();
212 ll_gns_thread_stop();
213 ll_destroy_inodecache();
215 LASSERTF(kmem_cache_destroy(ll_file_data_slab) == 0,
216 "couldn't destroy ll_file_data slab\n");
217 LASSERTF(kmem_cache_destroy(ll_intent_slab) == 0,
218 "couldn't destroy ll_intent_slab slab\n");
219 if (proc_lustre_fs_root) {
220 lprocfs_remove(proc_lustre_fs_root);
221 proc_lustre_fs_root = NULL;
225 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
226 MODULE_DESCRIPTION("Lustre Lite Client File System");
227 MODULE_LICENSE("GPL");
229 module_init(init_lustre_lite);
230 module_exit(exit_lustre_lite);