Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / obdclass / class_obd.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Object Devices Class Driver
5  *
6  *  Copyright (C) 2001-2003 Cluster File Systems, Inc.
7  *
8  *   This file is part of the Lustre file system, http://www.lustre.org
9  *   Lustre is a trademark of Cluster File Systems, Inc.
10  *
11  *   You may have signed or agreed to another license before downloading
12  *   this software.  If so, you are bound by the terms and conditions
13  *   of that agreement, and the following does not apply to you.  See the
14  *   LICENSE file included with this distribution for more information.
15  *
16  *   If you did not agree to a different license, then this copy of Lustre
17  *   is open source software; you can redistribute it and/or modify it
18  *   under the terms of version 2 of the GNU General Public License as
19  *   published by the Free Software Foundation.
20  *
21  *   In either case, Lustre is distributed in the hope that it will be
22  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
23  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  *   license text for more details.
25  *
26  * These are the only exported functions, they provide some generic
27  * infrastructure for managing object devices
28  */
29
30 #define DEBUG_SUBSYSTEM S_CLASS
31 #ifndef EXPORT_SYMTAB
32 # define EXPORT_SYMTAB
33 #endif
34 #ifndef __KERNEL__
35 # include <liblustre.h>
36 #endif
37
38 #include <obd_support.h>
39 #include <obd_class.h>
40 #include <lustre_debug.h>
41 #include <lprocfs_status.h>
42 #include <lustre/lustre_build_version.h>
43 #include <libcfs/list.h>
44 #include "llog_internal.h"
45
46 #ifndef __KERNEL__
47 /* liblustre workaround */
48 atomic_t libcfs_kmemory = {0};
49 #endif
50
51 struct obd_device *obd_devs[MAX_OBD_DEVICES];
52 struct list_head obd_types;
53 spinlock_t obd_dev_lock = SPIN_LOCK_UNLOCKED;
54
55 #ifndef __KERNEL__
56 __u64 obd_max_pages = 0;
57 __u64 obd_max_alloc = 0;
58 __u64 obd_alloc;
59 __u64 obd_pages;
60 #endif
61
62 /* The following are visible and mutable through /proc/sys/lustre/. */
63 unsigned int obd_fail_loc;
64 unsigned int obd_fail_val;
65 unsigned int obd_debug_peer_on_timeout;
66 unsigned int obd_dump_on_timeout;
67 unsigned int obd_dump_on_eviction;
68 unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT; /* seconds */
69 unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
70 unsigned int obd_health_check_timeout = HEALTH_CHECK_TIMEOUT_DEFAULT; /* seconds */
71 unsigned int obd_max_dirty_pages = 256;
72 atomic_t obd_dirty_pages;
73
74 cfs_waitq_t obd_race_waitq;
75 int obd_race_state;
76
77 #ifdef __KERNEL__
78 unsigned int obd_print_fail_loc(void)
79 {
80         CWARN("obd_fail_loc = %x\n", obd_fail_loc);
81         return obd_fail_loc;
82 }
83
84 void obd_set_fail_loc(unsigned int fl)
85 {
86         obd_fail_loc = fl;
87 }
88
89 /*  opening /dev/obd */
90 static int obd_class_open(unsigned long flags, void *args)
91 {
92         ENTRY;
93
94         PORTAL_MODULE_USE;
95         RETURN(0);
96 }
97
98 /*  closing /dev/obd */
99 static int obd_class_release(unsigned long flags, void *args)
100 {
101         ENTRY;
102
103         PORTAL_MODULE_UNUSE;
104         RETURN(0);
105 }
106 #endif
107
108 static inline void obd_data2conn(struct lustre_handle *conn,
109                                  struct obd_ioctl_data *data)
110 {
111         memset(conn, 0, sizeof *conn);
112         conn->cookie = data->ioc_cookie;
113 }
114
115 static inline void obd_conn2data(struct obd_ioctl_data *data,
116                                  struct lustre_handle *conn)
117 {
118         data->ioc_cookie = conn->cookie;
119 }
120
121 int class_resolve_dev_name(__u32 len, const char *name)
122 {
123         int rc;
124         int dev;
125
126         ENTRY;
127         if (!len || !name) {
128                 CERROR("No name passed,!\n");
129                 GOTO(out, rc = -EINVAL);
130         }
131         if (name[len - 1] != 0) {
132                 CERROR("Name not nul terminated!\n");
133                 GOTO(out, rc = -EINVAL);
134         }
135
136         CDEBUG(D_IOCTL, "device name %s\n", name);
137         dev = class_name2dev(name);
138         if (dev == -1) {
139                 CDEBUG(D_IOCTL, "No device for name %s!\n", name);
140                 GOTO(out, rc = -EINVAL);
141         }
142
143         CDEBUG(D_IOCTL, "device name %s, dev %d\n", name, dev);
144         rc = dev;
145
146 out:
147         RETURN(rc);
148 }
149
150 int class_handle_ioctl(unsigned int cmd, unsigned long arg)
151 {
152         char *buf = NULL;
153         struct obd_ioctl_data *data;
154         struct libcfs_debug_ioctl_data *debug_data;
155         struct obd_device *obd = NULL;
156         int err = 0, len = 0;
157         ENTRY;
158
159         /* only for debugging */
160         if (cmd == LIBCFS_IOC_DEBUG_MASK) {
161                 debug_data = (struct libcfs_debug_ioctl_data*)arg;
162                 libcfs_subsystem_debug = debug_data->subs;
163                 libcfs_debug = debug_data->debug;
164                 return 0;
165         }
166
167         CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
168         if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
169                 CERROR("OBD ioctl: data error\n");
170                 GOTO(out, err = -EINVAL);
171         }
172         data = (struct obd_ioctl_data *)buf;
173
174         switch (cmd) {
175         case OBD_IOC_PROCESS_CFG: {
176                 struct lustre_cfg *lcfg;
177
178                 if (!data->ioc_plen1 || !data->ioc_pbuf1) {
179                         CERROR("No config buffer passed!\n");
180                         GOTO(out, err = -EINVAL);
181                 }
182                 OBD_ALLOC(lcfg, data->ioc_plen1);
183                 if (lcfg == NULL)
184                         GOTO(out, err = -ENOMEM);
185                 err = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1);
186                 if (!err)
187                         err = lustre_cfg_sanity_check(lcfg, data->ioc_plen1);
188                 if (!err)
189                         err = class_process_config(lcfg);
190
191                 OBD_FREE(lcfg, data->ioc_plen1);
192                 GOTO(out, err);
193         }
194
195         case OBD_GET_VERSION:
196                 if (!data->ioc_inlbuf1) {
197                         CERROR("No buffer passed in ioctl\n");
198                         GOTO(out, err = -EINVAL);
199                 }
200
201                 if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
202                         CERROR("ioctl buffer too small to hold version\n");
203                         GOTO(out, err = -EINVAL);
204                 }
205
206                 memcpy(data->ioc_bulk, BUILD_VERSION,
207                        strlen(BUILD_VERSION) + 1);
208
209                 err = obd_ioctl_popdata((void *)arg, data, len);
210                 if (err)
211                         err = -EFAULT;
212                 GOTO(out, err);
213
214         case OBD_IOC_NAME2DEV: {
215                 /* Resolve a device name.  This does not change the
216                  * currently selected device.
217                  */
218                 int dev;
219
220                 dev = class_resolve_dev_name(data->ioc_inllen1,
221                                              data->ioc_inlbuf1);
222                 data->ioc_dev = dev;
223                 if (dev < 0)
224                         GOTO(out, err = -EINVAL);
225
226                 err = obd_ioctl_popdata((void *)arg, data, sizeof(*data));
227                 if (err)
228                         err = -EFAULT;
229                 GOTO(out, err);
230         }
231
232         case OBD_IOC_UUID2DEV: {
233                 /* Resolve a device uuid.  This does not change the
234                  * currently selected device.
235                  */
236                 int dev;
237                 struct obd_uuid uuid;
238
239                 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
240                         CERROR("No UUID passed!\n");
241                         GOTO(out, err = -EINVAL);
242                 }
243                 if (data->ioc_inlbuf1[data->ioc_inllen1 - 1] != 0) {
244                         CERROR("UUID not NUL terminated!\n");
245                         GOTO(out, err = -EINVAL);
246                 }
247
248                 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
249                 obd_str2uuid(&uuid, data->ioc_inlbuf1);
250                 dev = class_uuid2dev(&uuid);
251                 data->ioc_dev = dev;
252                 if (dev == -1) {
253                         CDEBUG(D_IOCTL, "No device for UUID %s!\n",
254                                data->ioc_inlbuf1);
255                         GOTO(out, err = -EINVAL);
256                 }
257
258                 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
259                        dev);
260                 err = obd_ioctl_popdata((void *)arg, data, sizeof(*data));
261                 if (err)
262                         err = -EFAULT;
263                 GOTO(out, err);
264         }
265
266         case OBD_IOC_CLOSE_UUID: {
267                 CDEBUG(D_IOCTL, "closing all connections to uuid %s (NOOP)\n",
268                        data->ioc_inlbuf1);
269                 GOTO(out, err = 0);
270         }
271
272         case OBD_IOC_GETDEVICE: {
273                 int     index = data->ioc_count;
274                 char    *status, *str;
275
276                 if (!data->ioc_inlbuf1) {
277                         CERROR("No buffer passed in ioctl\n");
278                         GOTO(out, err = -EINVAL);
279                 }
280                 if (data->ioc_inllen1 < 128) {
281                         CERROR("ioctl buffer too small to hold version\n");
282                         GOTO(out, err = -EINVAL);
283                 }
284                                 
285                 obd = class_num2obd(index);
286                 if (!obd)
287                         GOTO(out, err = -ENOENT);
288
289                 if (obd->obd_stopping)
290                         status = "ST";
291                 else if (obd->obd_set_up)
292                         status = "UP";
293                 else if (obd->obd_attached)
294                         status = "AT";
295                 else
296                         status = "--";
297                 str = (char *)data->ioc_bulk;
298                 snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d",
299                          (int)index, status, obd->obd_type->typ_name,
300                          obd->obd_name, obd->obd_uuid.uuid,
301                          atomic_read(&obd->obd_refcount));
302                 err = obd_ioctl_popdata((void *)arg, data, len);
303
304                 GOTO(out, err = 0);
305         }
306
307         }
308
309         if (data->ioc_dev >= class_devno_max()) {
310                 CERROR("OBD ioctl: No device\n");
311                 GOTO(out, err = -EINVAL);
312         }
313
314         obd = class_num2obd(data->ioc_dev);
315         if (obd == NULL) {
316                 CERROR("OBD ioctl : No Device %d\n", data->ioc_dev);
317                 GOTO(out, err = -EINVAL);
318         }
319         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
320
321         if (!obd->obd_set_up || obd->obd_stopping) {
322                 CERROR("OBD ioctl: device not setup %d \n", data->ioc_dev);
323                 GOTO(out, err = -EINVAL);
324         }
325
326         switch(cmd) {
327         case OBD_IOC_NO_TRANSNO: {
328                 if (!obd->obd_attached) {
329                         CERROR("Device %d not attached\n", obd->obd_minor);
330                         GOTO(out, err = -ENODEV);
331                 }
332                 CDEBUG(D_HA, "%s: disabling committed-transno notification\n",
333                        obd->obd_name);
334                 obd->obd_no_transno = 1;
335                 GOTO(out, err = 0);
336         }
337
338         default: {
339                 err = obd_iocontrol(cmd, obd->obd_self_export, len, data, NULL);
340                 if (err)
341                         GOTO(out, err);
342
343                 err = obd_ioctl_popdata((void *)arg, data, len);
344                 if (err)
345                         err = -EFAULT;
346                 GOTO(out, err);
347         }
348         }
349
350  out:
351         if (buf)
352                 obd_ioctl_freedata(buf, len);
353         RETURN(err);
354 } /* class_handle_ioctl */
355
356
357
358 #define OBD_MINOR 241
359 #ifdef __KERNEL__
360 /* to control /dev/obd */
361 static int obd_class_ioctl (struct cfs_psdev_file *pfile, unsigned long cmd,
362                             void *arg)
363 {
364         return class_handle_ioctl(cmd, (unsigned long)arg);
365 }
366
367 /* declare character device */
368 struct cfs_psdev_ops obd_psdev_ops = {
369         /* .p_open    = */ obd_class_open,      /* open */
370         /* .p_close   = */ obd_class_release,   /* release */
371         /* .p_read    = */ NULL,
372         /* .p_write   = */ NULL,
373         /* .p_ioctl   = */ obd_class_ioctl     /* ioctl */
374 };
375
376 extern cfs_psdev_t obd_psdev;
377 #else
378 void *obd_psdev = NULL;
379 #endif
380
381 EXPORT_SYMBOL(obd_devs);
382 EXPORT_SYMBOL(obd_fail_loc);
383 EXPORT_SYMBOL(obd_fail_val);
384 EXPORT_SYMBOL(obd_print_fail_loc);
385 EXPORT_SYMBOL(obd_race_waitq);
386 EXPORT_SYMBOL(obd_race_state);
387 EXPORT_SYMBOL(obd_debug_peer_on_timeout);
388 EXPORT_SYMBOL(obd_dump_on_timeout);
389 EXPORT_SYMBOL(obd_dump_on_eviction);
390 EXPORT_SYMBOL(obd_timeout);
391 EXPORT_SYMBOL(ldlm_timeout);
392 EXPORT_SYMBOL(obd_health_check_timeout);
393 EXPORT_SYMBOL(obd_max_dirty_pages);
394 EXPORT_SYMBOL(obd_dirty_pages);
395 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
396
397 EXPORT_SYMBOL(proc_lustre_root);
398
399 EXPORT_SYMBOL(class_register_type);
400 EXPORT_SYMBOL(class_unregister_type);
401 EXPORT_SYMBOL(class_get_type);
402 EXPORT_SYMBOL(class_put_type);
403 EXPORT_SYMBOL(class_name2dev);
404 EXPORT_SYMBOL(class_name2obd);
405 EXPORT_SYMBOL(class_uuid2dev);
406 EXPORT_SYMBOL(class_uuid2obd);
407 EXPORT_SYMBOL(class_find_client_obd);
408 EXPORT_SYMBOL(class_find_client_notype);
409 EXPORT_SYMBOL(class_devices_in_group);
410 EXPORT_SYMBOL(class_conn2export);
411 EXPORT_SYMBOL(class_exp2obd);
412 EXPORT_SYMBOL(class_conn2obd);
413 EXPORT_SYMBOL(class_exp2cliimp);
414 EXPORT_SYMBOL(class_conn2cliimp);
415 EXPORT_SYMBOL(class_disconnect);
416 EXPORT_SYMBOL(class_num2obd);
417
418 /* uuid.c */
419 EXPORT_SYMBOL(class_uuid_unparse);
420 EXPORT_SYMBOL(lustre_uuid_to_peer);
421
422 EXPORT_SYMBOL(class_handle_hash);
423 EXPORT_SYMBOL(class_handle_unhash);
424 EXPORT_SYMBOL(class_handle_hash_back);
425 EXPORT_SYMBOL(class_handle2object);
426 EXPORT_SYMBOL(class_handle_free_cb);
427
428 /* obd_config.c */
429 EXPORT_SYMBOL(class_incref);
430 EXPORT_SYMBOL(class_decref);
431 EXPORT_SYMBOL(class_get_profile);
432 EXPORT_SYMBOL(class_del_profile);
433 EXPORT_SYMBOL(class_del_profiles);
434 EXPORT_SYMBOL(class_process_config);
435 EXPORT_SYMBOL(class_process_proc_param);
436 EXPORT_SYMBOL(class_config_parse_llog);
437 EXPORT_SYMBOL(class_config_dump_llog);
438 EXPORT_SYMBOL(class_attach);
439 EXPORT_SYMBOL(class_setup);
440 EXPORT_SYMBOL(class_cleanup);
441 EXPORT_SYMBOL(class_detach);
442 EXPORT_SYMBOL(class_manual_cleanup);
443
444 /* mea.c */
445 EXPORT_SYMBOL(mea_name2idx);
446 EXPORT_SYMBOL(raw_name2idx);
447
448 #define OBD_INIT_CHECK
449 #ifdef OBD_INIT_CHECK
450 int obd_init_checks(void)
451 {
452         __u64 u64val, div64val;
453         char buf[64];
454         int len, ret = 0;
455
456         CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s, LPSZ=%s, LPSSZ=%s\n",
457                LPU64, LPD64, LPX64, LPSZ, LPSSZ);
458
459         CDEBUG(D_INFO, "OBD_OBJECT_EOF = "LPX64"\n", (__u64)OBD_OBJECT_EOF);
460
461         u64val = OBD_OBJECT_EOF;
462         CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val);
463         if (u64val != OBD_OBJECT_EOF) {
464                 CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n",
465                        u64val, (int)sizeof(u64val));
466                 ret = -EINVAL;
467         }
468         len = snprintf(buf, sizeof(buf), LPX64, u64val);
469         if (len != 18) {
470                 CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
471                 ret = -EINVAL;
472         }
473
474         div64val = OBD_OBJECT_EOF;
475         CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val);
476         if (u64val != OBD_OBJECT_EOF) {
477                 CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n",
478                        u64val, (int)sizeof(u64val));
479                 ret = -EOVERFLOW;
480         }
481         if (u64val >> 8 != OBD_OBJECT_EOF >> 8) {
482                 CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n",
483                        u64val, (int)sizeof(u64val));
484                 return -EOVERFLOW;
485         }
486         if (do_div(div64val, 256) != (u64val & 255)) {
487                 CERROR("do_div("LPX64",256) != "LPU64"\n", u64val, u64val &255);
488                 return -EOVERFLOW;
489         }
490         if (u64val >> 8 != div64val) {
491                 CERROR("do_div("LPX64",256) "LPU64" != "LPU64"\n",
492                        u64val, div64val, u64val >> 8);
493                 return -EOVERFLOW;
494         }
495         len = snprintf(buf, sizeof(buf), LPX64, u64val);
496         if (len != 18) {
497                 CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
498                 ret = -EINVAL;
499         }
500         len = snprintf(buf, sizeof(buf), LPU64, u64val);
501         if (len != 20) {
502                 CWARN("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len);
503                 ret = -EINVAL;
504         }
505         len = snprintf(buf, sizeof(buf), LPD64, u64val);
506         if (len != 2) {
507                 CWARN("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len);
508                 ret = -EINVAL;
509         }
510         if ((u64val & ~CFS_PAGE_MASK) >= CFS_PAGE_SIZE) {
511                 CWARN("mask failed: u64val "LPU64" >= %lu\n", u64val,
512                       CFS_PAGE_SIZE);
513                 ret = -EINVAL;
514         }
515
516         return ret;
517 }
518 #else
519 #define obd_init_checks() do {} while(0)
520 #endif
521
522 extern spinlock_t obd_types_lock;
523 extern int class_procfs_init(void);
524 extern int class_procfs_clean(void);
525
526 #ifdef __KERNEL__
527 static int __init init_obdclass(void)
528 #else
529 int init_obdclass(void)
530 #endif
531 {
532         int i, err;
533 #ifdef __KERNEL__
534         int lustre_register_fs(void);
535
536         printk(KERN_INFO "Lustre: OBD class driver, info@clusterfs.com\n");
537         printk(KERN_INFO "        Lustre Version: "LUSTRE_VERSION_STRING"\n");
538         printk(KERN_INFO "        Build Version: "BUILD_VERSION"\n");
539
540         for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
541                 INIT_LIST_HEAD(&capa_list[i]);
542 #else
543         CDEBUG(D_INFO, "Lustre: OBD class driver, info@clusterfs.com\n");
544         CDEBUG(D_INFO, "        Lustre Version: "LUSTRE_VERSION_STRING"\n");
545         CDEBUG(D_INFO, "        Build Version: "BUILD_VERSION"\n");
546 #endif
547
548         spin_lock_init(&obd_types_lock);
549         cfs_waitq_init(&obd_race_waitq);
550         obd_zombie_impexp_init();
551 #ifdef LPROCFS
552         obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, 
553                                          LPROCFS_STATS_FLAG_PERCPU);
554         if (obd_memory == NULL) {
555                 CERROR("kmalloc of 'obd_memory' failed\n");
556                 RETURN(-ENOMEM);
557         }
558  
559         lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
560                              LPROCFS_CNTR_AVGMINMAX, 
561                              "memused", "bytes");
562         lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
563                              LPROCFS_CNTR_AVGMINMAX, 
564                              "pagesused", "pages");
565 #endif
566         err = obd_init_checks();
567         if (err == -EOVERFLOW)
568                 return err;
569
570         class_init_uuidlist();
571         err = class_handle_init();
572         if (err)
573                 return err;
574
575         spin_lock_init(&obd_dev_lock);
576         INIT_LIST_HEAD(&obd_types);
577
578         err = cfs_psdev_register(&obd_psdev);
579         if (err) {
580                 CERROR("cannot register %d err %d\n", OBD_MINOR, err);
581                 return err;
582         }
583
584         /* This struct is already zerod for us (static global) */
585         for (i = 0; i < class_devno_max(); i++)
586                 obd_devs[i] = NULL;
587
588         /* Default the dirty page cache cap to 1/2 of system memory */
589         obd_max_dirty_pages = num_physpages / 2;
590
591         err = obd_init_caches();
592         if (err)
593                 return err;
594 #ifdef __KERNEL__
595         err = lu_global_init();
596         if (err)
597                 return err;
598         err = class_procfs_init();
599         if (err)
600                 return err;
601         err = lustre_register_fs();
602 #endif
603
604         return err;
605 }
606
607 /* liblustre doesn't call cleanup_obdclass, apparently.  we carry on in this
608  * ifdef to the end of the file to cover module and versioning goo.*/
609 #ifdef __KERNEL__
610 static void cleanup_obdclass(void)
611 {
612         int i;
613         int lustre_unregister_fs(void);
614         __u64 memory_leaked, pages_leaked;
615         __u64 memory_max, pages_max;
616         ENTRY;
617
618         lustre_unregister_fs();
619
620         cfs_psdev_deregister(&obd_psdev);
621         for (i = 0; i < class_devno_max(); i++) {
622                 struct obd_device *obd = class_num2obd(i);
623                 if (obd && obd->obd_set_up &&
624                     OBT(obd) && OBP(obd, detach)) {
625                         /* XXX should this call generic detach otherwise? */
626                         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
627                         OBP(obd, detach)(obd);
628                 }
629         }
630         lu_global_fini();
631
632         obd_cleanup_caches();
633         obd_sysctl_clean();
634
635         class_procfs_clean();
636
637         class_handle_cleanup();
638         class_exit_uuidlist();
639
640         memory_leaked = obd_memory_sum();
641         pages_leaked = obd_pages_sum();
642         
643         memory_max = obd_memory_max();
644         pages_max = obd_pages_max();
645
646         lprocfs_free_stats(&obd_memory);
647         if (memory_leaked > 0) {
648                 CWARN("Memory leaks detected (max "LPU64", leaked "LPD64")\n",
649                       memory_max, memory_leaked);
650         }
651         if (pages_leaked > 0) {
652                 CWARN("Page leaks detected (max "LPU64", leaked "LPU64")\n",
653                       pages_max, pages_leaked);
654         }
655  
656         EXIT;
657 }
658
659 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
660 MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
661 MODULE_LICENSE("GPL");
662
663 cfs_module(obdclass, LUSTRE_VERSION_STRING, init_obdclass, cleanup_obdclass);
664 #endif