Whamcloud - gitweb
- landing of b_fid after merge with b_hd_cleanup_merge.
[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_sb(struct file_system_type *fs_type, int flags, 
68                                 const char *dev_name, void *data)
69 {
70         return get_sb_nodev(fs_type, flags, data, smfs_fill_super);
71 }
72 void smfs_kill_super(struct super_block *sb)
73 {
74         smfs_cleanup_hooks(S2SMI(sb));
75         kill_anon_super(sb);
76 }
77 static struct file_system_type smfs_type = {
78         .owner       = THIS_MODULE,
79         .name        = "smfs",
80         .get_sb      = smfs_get_sb,
81         .kill_sb     = smfs_kill_super,
82 };
83 #endif
84
85 static int cleanup_smfs(void)
86 {
87         int err = 0;
88
89         err = unregister_filesystem(&smfs_type);
90         if (err)
91                 CERROR("unregister_filesystem() failed, rc = %d\n", err);
92         return 0;
93 }
94 static int init_smfs(void)
95 {
96         int err;
97         
98         err = register_filesystem(&smfs_type);
99         if (err)
100                 CERROR("register_filesystem() failed, rc = %d\n", err);
101         return err;
102 }
103 static int __init smfs_init(void)
104 {
105         int err;
106
107         if ( (err = init_smfs_psdev()) ) {
108                 printk("Error initializing smfs_psdev, %d\n", err);
109                 return -EINVAL;
110         }
111
112         if ( (err = init_smfs()) ) {
113                 printk("Error initializing smfs, %d\n", err);
114                 return -EINVAL;
115         }
116
117         if ( (err = init_smfs_proc_sys()) ) {
118                 printk("Error initializing smfs proc sys, %d\n", err);
119                 return -EINVAL;
120         }
121
122         return 0;
123 }
124
125 static void __exit smfs_cleanup(void)
126 {
127         cleanup_smfs();
128         smfs_cleanup_psdev();
129 }
130
131 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
132 MODULE_DESCRIPTION("Smfs file system filters v0.01");
133 MODULE_LICENSE("GPL");
134
135 module_init(smfs_init);
136 module_exit(smfs_cleanup);