Whamcloud - gitweb
drop truncate capa after ll_truncate.
[fs/lustre-release.git] / lustre / llite / super.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Lustre Light Super operations
5  *
6  *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
7  *
8  *   This file is part of Lustre, http://www.lustre.org.
9  *
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.
13  *
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.
18  *
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.
22  */
23
24 #define DEBUG_SUBSYSTEM S_LLITE
25
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>
34 #include <linux/fs.h>
35 #include <linux/lprocfs_status.h>
36 #include "llite_internal.h"
37 #include <lustre/lustre_user.h>
38
39 extern struct address_space_operations ll_aops;
40 extern struct address_space_operations ll_dir_aops;
41 extern struct timer_list ll_capa_timer;
42
43 static struct super_block *ll_read_super(struct super_block *sb,
44                                          void *data, int silent)
45 {
46         int err;
47         ENTRY;
48         err = ll_fill_super(sb, data, silent);
49         if (err)
50                 RETURN(NULL);
51         RETURN(sb);
52 }
53
54 static struct super_block *lustre_read_super(struct super_block *sb,
55                                          void *data, int silent)
56 {
57         int err;
58         ENTRY;
59         err = lustre_fill_super(sb, data, silent);
60         if (err)
61                 RETURN(NULL);
62         RETURN(sb);
63 }
64
65 static void ll_umount_lustre(struct super_block *sb)
66 {
67         struct ll_sb_info *sbi = ll_s2sbi(sb);
68         ll_gns_check_mounts(sbi, LL_GNS_UMOUNT);
69 }
70
71 static struct file_system_type lustre_lite_fs_type = {
72         .owner          = THIS_MODULE,
73         .name           = "lustre_lite",
74         .fs_flags       = FS_NFSEXP_FSID,
75         .read_super     = ll_read_super,
76 };
77
78 /* exported operations */
79 struct super_operations lustre_super_operations =
80 {
81         .read_inode2    = ll_read_inode2,
82         .clear_inode    = ll_clear_inode,
83         .delete_inode   = ll_delete_inode,
84         .put_super      = lustre_put_super,
85         .statfs         = ll_statfs,
86         .umount_begin   = ll_umount_begin,
87         .umount_lustre  = ll_umount_lustre,
88         .fh_to_dentry   = ll_fh_to_dentry,
89         .dentry_to_fh   = ll_dentry_to_fh
90 };
91
92 static struct file_system_type lustre_fs_type = {
93         .owner          = THIS_MODULE,
94         .name           = "lustre",
95         .fs_flags       = FS_NFSEXP_FSID,
96         .read_super     = lustre_read_super,
97 };
98
99 static int __init init_lustre_lite(void)
100 {
101         int rc, cleanup = 0;
102
103         printk(KERN_INFO "Lustre: Lustre Lite Client File System; "
104                "info@clusterfs.com\n");
105         ll_file_data_slab = kmem_cache_create("ll_file_data",
106                                               sizeof(struct ll_file_data), 0,
107                                               SLAB_HWCACHE_ALIGN, NULL, NULL);
108         if (ll_file_data_slab == NULL)
109                 return -ENOMEM;
110
111         ll_intent_slab = kmem_cache_create("lustre_intent_data",
112                                               sizeof(struct lustre_intent_data),
113                                               0, SLAB_HWCACHE_ALIGN, NULL,
114                                               NULL);
115         if (ll_intent_slab == NULL) {
116                 kmem_cache_destroy(ll_file_data_slab);
117                 return -ENOMEM;
118         }
119
120         proc_lustre_fs_root = proc_lustre_root ? proc_mkdir("llite", proc_lustre_root) : NULL;
121
122         rc = register_filesystem(&lustre_lite_fs_type);
123         if (rc)
124                 goto out;
125         cleanup = 1;
126
127         rc = register_filesystem(&lustre_fs_type);
128         if (rc)
129                 goto out;
130         cleanup = 2;
131
132         rc = ll_gns_thread_start();
133         if (rc)
134                 goto out;
135
136         ll_capa_timer.function = ll_capa_timer_callback;
137         ll_capa_timer.data = 0;
138         init_timer(&ll_capa_timer);        
139
140         rc = ll_capa_thread_start();
141         if (rc)
142                 goto out;
143
144         return 0;
145
146  out:
147         switch (cleanup) {
148         case 2:
149                 unregister_filesystem(&lustre_fs_type);
150         case 1:
151                 unregister_filesystem(&lustre_lite_fs_type);
152         case 0:
153                 kmem_cache_destroy(ll_intent_slab);
154                 kmem_cache_destroy(ll_file_data_slab);
155         }
156         return rc;
157 }
158
159 static void __exit exit_lustre_lite(void)
160 {
161         unregister_filesystem(&lustre_lite_fs_type);
162         unregister_filesystem(&lustre_fs_type);
163
164         del_timer(&ll_capa_timer);
165         ll_capa_thread_stop();
166         ll_gns_thread_stop();
167
168         LASSERTF(kmem_cache_destroy(ll_file_data_slab) == 0,
169                  "couldn't destroy ll_file_data slab\n");
170         LASSERTF(kmem_cache_destroy(ll_intent_slab) == 0,
171                  "couldn't destroy ll_intent_slab slab\n");
172
173         if (proc_lustre_fs_root) {
174                 lprocfs_remove(proc_lustre_fs_root);
175                 proc_lustre_fs_root = NULL;
176         }
177 }
178
179 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
180 MODULE_DESCRIPTION("Lustre Lite Client File System");
181 MODULE_LICENSE("GPL");
182
183 module_init(init_lustre_lite);
184 module_exit(exit_lustre_lite);