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