Whamcloud - gitweb
land lustre part of b_hd_sec on HEAD.
[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
42 static struct super_block *ll_read_super(struct super_block *sb,
43                                          void *data, int silent)
44 {
45         int err;
46         ENTRY;
47         err = ll_fill_super(sb, data, silent);
48         if (err)
49                 RETURN(NULL);
50         RETURN(sb);
51 }
52
53 static struct super_block *lustre_read_super(struct super_block *sb,
54                                          void *data, int silent)
55 {
56         int err;
57         ENTRY;
58         err = lustre_fill_super(sb, data, silent);
59         if (err)
60                 RETURN(NULL);
61         RETURN(sb);
62 }
63
64 static void ll_umount_lustre(struct super_block *sb)
65 {
66         struct ll_sb_info *sbi = ll_s2sbi(sb);
67         ll_gns_check_all(sbi, LL_GNS_UMOUNT);
68 }
69
70 static struct file_system_type lustre_lite_fs_type = {
71         .owner          = THIS_MODULE,
72         .name           = "lustre_lite",
73         .fs_flags       = FS_NFSEXP_FSID,
74         .read_super     = ll_read_super,
75 };
76
77 /* exported operations */
78 struct super_operations lustre_super_operations =
79 {
80         .read_inode2    = ll_read_inode2,
81         .clear_inode    = ll_clear_inode,
82         .delete_inode   = ll_delete_inode,
83         .put_super      = lustre_put_super,
84         .statfs         = ll_statfs,
85         .umount_begin   = ll_umount_begin,
86         .umount_lustre  = ll_umount_lustre,
87         .fh_to_dentry   = ll_fh_to_dentry,
88         .dentry_to_fh   = ll_dentry_to_fh
89 };
90
91 static struct file_system_type lustre_fs_type = {
92         .owner          = THIS_MODULE,
93         .name           = "lustre",
94         .fs_flags       = FS_NFSEXP_FSID,
95         .read_super     = lustre_read_super,
96 };
97
98 static int __init init_lustre_lite(void)
99 {
100         int rc, cleanup = 0;
101
102         printk(KERN_INFO "Lustre: Lustre Lite Client File System; "
103                "info@clusterfs.com\n");
104         ll_file_data_slab = kmem_cache_create("ll_file_data",
105                                               sizeof(struct ll_file_data), 0,
106                                               SLAB_HWCACHE_ALIGN, NULL, NULL);
107         if (ll_file_data_slab == NULL)
108                 return -ENOMEM;
109
110         ll_intent_slab = kmem_cache_create("lustre_intent_data",
111                                               sizeof(struct lustre_intent_data),
112                                               0, SLAB_HWCACHE_ALIGN, NULL,
113                                               NULL);
114         if (ll_intent_slab == NULL) {
115                 kmem_cache_destroy(ll_file_data_slab);
116                 return -ENOMEM;
117         }
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_start_thread();
133         if (rc)
134                 goto out;
135         return 0;
136
137  out:
138         switch (cleanup) {
139         case 2:
140                 unregister_filesystem(&lustre_fs_type);
141         case 1:
142                 unregister_filesystem(&lustre_lite_fs_type);
143         case 0:
144                 kmem_cache_destroy(ll_file_data_slab);
145         }
146         return rc;
147 }
148
149 static void __exit exit_lustre_lite(void)
150 {
151         unregister_filesystem(&lustre_lite_fs_type);
152         unregister_filesystem(&lustre_fs_type);
153
154         ll_gns_stop_thread();
155
156         LASSERTF(kmem_cache_destroy(ll_file_data_slab) == 0,
157                  "couldn't destroy ll_file_data slab\n");
158         LASSERTF(kmem_cache_destroy(ll_intent_slab) == 0,
159                  "couldn't destroy ll_intent_slab slab\n");
160
161         if (proc_lustre_fs_root) {
162                 lprocfs_remove(proc_lustre_fs_root);
163                 proc_lustre_fs_root = NULL;
164         }
165 }
166
167 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
168 MODULE_DESCRIPTION("Lustre Lite Client File System");
169 MODULE_LICENSE("GPL");
170
171 module_init(init_lustre_lite);
172 module_exit(exit_lustre_lite);