Whamcloud - gitweb
- landing of b_hd_cleanup_merge to 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
68         ll_gns_umount_all(sbi, 0);
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 #if 0
84         /* should be fixed first */
85         .delete_inode   = ll_delete_inode,
86 #endif
87         .put_super      = lustre_put_super,
88         .statfs         = ll_statfs,
89         .umount_begin   = ll_umount_begin,
90         .umount_lustre  = ll_umount_lustre,
91         .fh_to_dentry   = ll_fh_to_dentry,
92         .dentry_to_fh   = ll_dentry_to_fh
93 };
94
95 static struct file_system_type lustre_fs_type = {
96         .owner          = THIS_MODULE,
97         .name           = "lustre",
98         .fs_flags       = FS_NFSEXP_FSID,
99         .read_super     = lustre_read_super,
100 };
101
102 static int __init init_lustre_lite(void)
103 {
104         int rc, cleanup = 0;
105
106         printk(KERN_INFO "Lustre: Lustre Lite Client File System; "
107                "info@clusterfs.com\n");
108         ll_file_data_slab = kmem_cache_create("ll_file_data",
109                                               sizeof(struct ll_file_data), 0,
110                                               SLAB_HWCACHE_ALIGN, NULL, NULL);
111         if (ll_file_data_slab == NULL)
112                 return -ENOMEM;
113
114         proc_lustre_fs_root = proc_lustre_root ? proc_mkdir("llite", proc_lustre_root) : NULL;
115
116         rc = register_filesystem(&lustre_lite_fs_type);
117         if (rc)
118                 goto out;
119         cleanup = 1;
120
121         rc = register_filesystem(&lustre_fs_type);
122         if (rc)
123                 goto out;
124         cleanup = 2;
125
126         rc = ll_gns_start_thread();
127         if (rc)
128                 goto out;
129         return 0;
130
131  out:
132         switch (cleanup) {
133         case 2:
134                 unregister_filesystem(&lustre_fs_type);
135         case 1:
136                 unregister_filesystem(&lustre_lite_fs_type);
137         case 0:
138                 kmem_cache_destroy(ll_file_data_slab);
139         }
140         return rc;
141 }
142
143 static void __exit exit_lustre_lite(void)
144 {
145         unregister_filesystem(&lustre_lite_fs_type);
146         unregister_filesystem(&lustre_fs_type);
147
148         ll_gns_stop_thread();
149
150         LASSERTF(kmem_cache_destroy(ll_file_data_slab) == 0,
151                  "couldn't destroy ll_file_data slab\n");
152
153         if (proc_lustre_fs_root) {
154                 lprocfs_remove(proc_lustre_fs_root);
155                 proc_lustre_fs_root = NULL;
156         }
157 }
158
159 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
160 MODULE_DESCRIPTION("Lustre Lite Client File System");
161 MODULE_LICENSE("GPL");
162
163 module_init(init_lustre_lite);
164 module_exit(exit_lustre_lite);