Whamcloud - gitweb
land b1_5 onto 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 Client 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 <lustre_lite.h>
31 #include <lustre_ha.h>
32 #include <lustre_dlm.h>
33 #include <linux/init.h>
34 #include <linux/fs.h>
35 #include <linux/random.h>
36 #include <linux/cache_def.h>
37 #include <lprocfs_status.h>
38 #include "llite_internal.h"
39 #include <lustre/lustre_user.h>
40
41 extern struct address_space_operations ll_aops;
42 extern struct address_space_operations ll_dir_aops;
43
44
45 /* exported operations */
46 struct super_operations lustre_super_operations =
47 {
48         .read_inode2    = ll_read_inode2,
49         .clear_inode    = ll_clear_inode,
50         .put_super      = ll_put_super,
51         .statfs         = ll_statfs,
52         .umount_begin   = ll_umount_begin,
53         .fh_to_dentry   = ll_fh_to_dentry,
54         .dentry_to_fh   = ll_dentry_to_fh,
55         .remount_fs     = ll_remount_fs,
56 };
57
58
59 void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
60
61 static int __init init_lustre_lite(void)
62 {
63         int i, rc, seed[2];
64         struct timeval tv;
65         lnet_process_id_t lnet_id;
66
67         printk(KERN_INFO "Lustre: Lustre Client File System; "
68                "info@clusterfs.com\n");
69         ll_file_data_slab = kmem_cache_create("ll_file_data",
70                                               sizeof(struct ll_file_data), 0,
71                                               SLAB_HWCACHE_ALIGN, NULL, NULL);
72         if (ll_file_data_slab == NULL)
73                 return -ENOMEM;
74
75         if (proc_lustre_root)
76                 proc_lustre_fs_root = proc_mkdir("llite", proc_lustre_root);
77
78         ll_register_cache(&ll_cache_definition);
79
80         lustre_register_client_fill_super(ll_fill_super);
81         lustre_register_client_process_config(ll_process_config);
82
83         get_random_bytes(seed, sizeof(seed));
84
85         /* Nodes with small feet have little entropy
86          * the NID for this node gives the most entropy in the low bits */
87         for (i=0; ; i++) {
88                 if (LNetGetId(i, &lnet_id) == -ENOENT) {
89                         break;
90                 }
91                 if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
92                         seed[0] ^= LNET_NIDADDR(lnet_id.nid);
93                 }
94         }
95
96         do_gettimeofday(&tv);
97         ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
98
99         return 0;
100 }
101
102 static void __exit exit_lustre_lite(void)
103 {
104         int rc;
105
106         lustre_register_client_fill_super(NULL);
107         lustre_register_client_process_config(NULL);
108
109         ll_unregister_cache(&ll_cache_definition);
110
111         rc = kmem_cache_destroy(ll_file_data_slab);
112         LASSERTF(rc == 0, "couldn't destroy ll_file_data slab\n");
113         if (ll_async_page_slab) {
114                 rc = kmem_cache_destroy(ll_async_page_slab);
115                 LASSERTF(rc == 0, "couldn't destroy ll_async_page slab\n");
116         }
117
118         if (proc_lustre_fs_root)
119                 lprocfs_remove(&proc_lustre_fs_root);
120 }
121
122 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
123 MODULE_DESCRIPTION("Lustre Lite Client File System");
124 MODULE_LICENSE("GPL");
125
126 module_init(init_lustre_lite);
127 module_exit(exit_lustre_lite);