Whamcloud - gitweb
current branches now use lnet from HEAD
[fs/lustre-release.git] / lustre / smfs / super.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/smfs/super.c
5  *  Lustre filesystem abstraction routines
6  *
7  *  Copyright (C) 2004 Cluster File Systems, Inc.
8  *
9  *   This file is part of Lustre, http://www.lustre.org.
10  *
11  *   Lustre is free software; you can redistribute it and/or
12  *   modify it under the terms of version 2 of the GNU General Public
13  *   License as published by the Free Software Foundation.
14  *
15  *   Lustre is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with Lustre; if not, write to the Free Software
22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25 #define DEBUG_SUBSYSTEM S_SM
26
27 #include <linux/config.h>
28 #include <linux/module.h>
29 #include <linux/kmod.h>
30 #include <linux/init.h>
31 #include <linux/fs.h>
32 #include <linux/string.h>
33 #include <linux/mm.h>
34 #include <linux/utime.h>
35 #include <linux/file.h>
36 #include <linux/slab.h>
37 #include <linux/dcache.h>
38 #include <linux/loop.h>
39 #include <linux/errno.h>
40 #include <linux/obd_class.h>
41 #include <linux/obd_support.h>
42 #include <linux/lustre_lib.h>
43 #include <linux/lustre_idl.h>
44 #include <linux/lustre_fsfilt.h>
45 #include <linux/lustre_smfs.h>
46 #include "smfs_internal.h"
47
48 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
49 static struct super_block *smfs_read_super(struct super_block *sb, 
50                                            void *data, int silent)
51 {
52         int err;
53
54         err = smfs_fill_super(sb, data, silent);
55         if (err)
56                 return NULL;
57
58         return sb;
59 }
60
61 static struct file_system_type smfs_type = {
62         .owner       = THIS_MODULE,
63         .name        = "smfs",
64         .read_super  = smfs_read_super,
65 };
66 #else
67 struct super_block *smfs_get_super(struct file_system_type *fs_type,
68                                    int flags, const char *dev_name,
69                                    void *data)
70 {
71         return get_sb_nodev(fs_type, flags, data, smfs_fill_super);
72 }
73
74 void smfs_kill_super(struct super_block *sb)
75 {
76         kill_anon_super(sb);
77 }
78
79 static struct file_system_type smfs_type = {
80         .owner       = THIS_MODULE,
81         .name        = "smfs",
82         .get_sb      = smfs_get_super,
83         .kill_sb     = smfs_kill_super,
84 };
85 #endif
86
87 static int cleanup_smfs(void)
88 {
89         int err = 0;
90
91         err = unregister_filesystem(&smfs_type);
92         if (err)
93                 CERROR("unregister_filesystem() failed, rc = %d\n", err);
94         return 0;
95 }
96
97 static int init_smfs(void)
98 {
99         int err;
100         
101         err = register_filesystem(&smfs_type);
102         if (err)
103                 CERROR("register_filesystem() failed, rc = %d\n", err);
104         return err;
105 }
106
107 static int __init smfs_init(void)
108 {
109         int err;
110
111         if ( (err = init_smfs_psdev()) ) {
112                 printk("Error initializing smfs_psdev, %d\n", err);
113                 return -EINVAL;
114         }
115
116         if ( (err = init_smfs()) ) {
117                 printk("Error initializing smfs, %d\n", err);
118                 return -EINVAL;
119         }
120
121         if ( (err = init_smfs_proc_sys()) ) {
122                 printk("Error initializing smfs proc sys, %d\n", err);
123                 return -EINVAL;
124         }
125
126         return 0;
127 }
128
129 static void __exit smfs_cleanup(void)
130 {
131         cleanup_smfs();
132         smfs_cleanup_psdev();
133 }
134
135 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
136 MODULE_DESCRIPTION("Smfs file system filters v0.01");
137 MODULE_LICENSE("GPL");
138
139 module_init(smfs_init);
140 module_exit(smfs_cleanup);