Whamcloud - gitweb
b=22980 improve obdfilter-survey performance on multi-core system
[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  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #define DEBUG_SUBSYSTEM S_CLASS
38 #ifndef EXPORT_SYMTAB
39 # define EXPORT_SYMTAB
40 #endif
41 #ifndef __KERNEL__
42 # include <liblustre.h>
43 #else
44 # include <asm/atomic.h>
45 #endif
46
47 #include <obd_support.h>
48 #include <obd_class.h>
49 #include <lnet/lnetctl.h>
50 #include <lustre_debug.h>
51 #include <lprocfs_status.h>
52 #include <lustre/lustre_build_version.h>
53 #include <libcfs/list.h>
54 #include "llog_internal.h"
55
56 #ifndef __KERNEL__
57 /* liblustre workaround */
58 cfs_atomic_t libcfs_kmemory = {0};
59 #endif
60
61 struct obd_device *obd_devs[MAX_OBD_DEVICES];
62 cfs_list_t obd_types;
63 cfs_spinlock_t obd_dev_lock = CFS_SPIN_LOCK_UNLOCKED;
64
65 #ifndef __KERNEL__
66 __u64 obd_max_pages = 0;
67 __u64 obd_max_alloc = 0;
68 __u64 obd_alloc;
69 __u64 obd_pages;
70 #endif
71
72 /* The following are visible and mutable through /proc/sys/lustre/. */
73 unsigned int obd_debug_peer_on_timeout;
74 unsigned int obd_dump_on_timeout;
75 unsigned int obd_dump_on_eviction;
76 unsigned int obd_max_dirty_pages = 256;
77 unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT;   /* seconds */
78 unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
79 /* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */
80 unsigned int at_min = 0;
81 unsigned int at_max = 600;
82 unsigned int at_history = 600;
83 int at_early_margin = 5;
84 int at_extra = 30;
85
86 cfs_atomic_t obd_dirty_pages;
87 cfs_atomic_t obd_dirty_transit_pages;
88
89 cfs_waitq_t obd_race_waitq;
90 int obd_race_state;
91
92 #ifdef __KERNEL__
93 unsigned long obd_print_fail_loc(void)
94 {
95         CWARN("obd_fail_loc = %lx\n", obd_fail_loc);
96         return obd_fail_loc;
97 }
98 #endif
99
100 static inline void obd_data2conn(struct lustre_handle *conn,
101                                  struct obd_ioctl_data *data)
102 {
103         memset(conn, 0, sizeof *conn);
104         conn->cookie = data->ioc_cookie;
105 }
106
107 static inline void obd_conn2data(struct obd_ioctl_data *data,
108                                  struct lustre_handle *conn)
109 {
110         data->ioc_cookie = conn->cookie;
111 }
112
113 int class_resolve_dev_name(__u32 len, const char *name)
114 {
115         int rc;
116         int dev;
117
118         ENTRY;
119         if (!len || !name) {
120                 CERROR("No name passed,!\n");
121                 GOTO(out, rc = -EINVAL);
122         }
123         if (name[len - 1] != 0) {
124                 CERROR("Name not nul terminated!\n");
125                 GOTO(out, rc = -EINVAL);
126         }
127
128         CDEBUG(D_IOCTL, "device name %s\n", name);
129         dev = class_name2dev(name);
130         if (dev == -1) {
131                 CDEBUG(D_IOCTL, "No device for name %s!\n", name);
132                 GOTO(out, rc = -EINVAL);
133         }
134
135         CDEBUG(D_IOCTL, "device name %s, dev %d\n", name, dev);
136         rc = dev;
137
138 out:
139         RETURN(rc);
140 }
141
142 int class_handle_ioctl(unsigned int cmd, unsigned long arg)
143 {
144         char *buf = NULL;
145         struct obd_ioctl_data *data;
146         struct libcfs_debug_ioctl_data *debug_data;
147         struct obd_device *obd = NULL;
148         int err = 0, len = 0;
149         ENTRY;
150
151         /* only for debugging */
152         if (cmd == LIBCFS_IOC_DEBUG_MASK) {
153                 debug_data = (struct libcfs_debug_ioctl_data*)arg;
154                 libcfs_subsystem_debug = debug_data->subs;
155                 libcfs_debug = debug_data->debug;
156                 return 0;
157         }
158
159         CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
160         if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
161                 CERROR("OBD ioctl: data error\n");
162                 RETURN(-EINVAL);
163         }
164         data = (struct obd_ioctl_data *)buf;
165
166         switch (cmd) {
167         case OBD_IOC_PROCESS_CFG: {
168                 struct lustre_cfg *lcfg;
169
170                 if (!data->ioc_plen1 || !data->ioc_pbuf1) {
171                         CERROR("No config buffer passed!\n");
172                         GOTO(out, err = -EINVAL);
173                 }
174                 OBD_ALLOC(lcfg, data->ioc_plen1);
175                 if (lcfg == NULL)
176                         GOTO(out, err = -ENOMEM);
177                 err = cfs_copy_from_user(lcfg, data->ioc_pbuf1,
178                                          data->ioc_plen1);
179                 if (!err)
180                         err = lustre_cfg_sanity_check(lcfg, data->ioc_plen1);
181                 if (!err)
182                         err = class_process_config(lcfg);
183
184                 OBD_FREE(lcfg, data->ioc_plen1);
185                 GOTO(out, err);
186         }
187
188         case OBD_GET_VERSION:
189                 if (!data->ioc_inlbuf1) {
190                         CERROR("No buffer passed in ioctl\n");
191                         GOTO(out, err = -EINVAL);
192                 }
193
194                 if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
195                         CERROR("ioctl buffer too small to hold version\n");
196                         GOTO(out, err = -EINVAL);
197                 }
198
199                 memcpy(data->ioc_bulk, BUILD_VERSION,
200                        strlen(BUILD_VERSION) + 1);
201
202                 err = obd_ioctl_popdata((void *)arg, data, len);
203                 if (err)
204                         err = -EFAULT;
205                 GOTO(out, err);
206
207         case OBD_IOC_NAME2DEV: {
208                 /* Resolve a device name.  This does not change the
209                  * currently selected device.
210                  */
211                 int dev;
212
213                 dev = class_resolve_dev_name(data->ioc_inllen1,
214                                              data->ioc_inlbuf1);
215                 data->ioc_dev = dev;
216                 if (dev < 0)
217                         GOTO(out, err = -EINVAL);
218
219                 err = obd_ioctl_popdata((void *)arg, data, sizeof(*data));
220                 if (err)
221                         err = -EFAULT;
222                 GOTO(out, err);
223         }
224
225         case OBD_IOC_UUID2DEV: {
226                 /* Resolve a device uuid.  This does not change the
227                  * currently selected device.
228                  */
229                 int dev;
230                 struct obd_uuid uuid;
231
232                 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
233                         CERROR("No UUID passed!\n");
234                         GOTO(out, err = -EINVAL);
235                 }
236                 if (data->ioc_inlbuf1[data->ioc_inllen1 - 1] != 0) {
237                         CERROR("UUID not NUL terminated!\n");
238                         GOTO(out, err = -EINVAL);
239                 }
240
241                 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
242                 obd_str2uuid(&uuid, data->ioc_inlbuf1);
243                 dev = class_uuid2dev(&uuid);
244                 data->ioc_dev = dev;
245                 if (dev == -1) {
246                         CDEBUG(D_IOCTL, "No device for UUID %s!\n",
247                                data->ioc_inlbuf1);
248                         GOTO(out, err = -EINVAL);
249                 }
250
251                 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
252                        dev);
253                 err = obd_ioctl_popdata((void *)arg, data, sizeof(*data));
254                 if (err)
255                         err = -EFAULT;
256                 GOTO(out, err);
257         }
258
259         case OBD_IOC_CLOSE_UUID: {
260                 CDEBUG(D_IOCTL, "closing all connections to uuid %s (NOOP)\n",
261                        data->ioc_inlbuf1);
262                 GOTO(out, err = 0);
263         }
264
265         case OBD_IOC_GETDEVICE: {
266                 int     index = data->ioc_count;
267                 char    *status, *str;
268
269                 if (!data->ioc_inlbuf1) {
270                         CERROR("No buffer passed in ioctl\n");
271                         GOTO(out, err = -EINVAL);
272                 }
273                 if (data->ioc_inllen1 < 128) {
274                         CERROR("ioctl buffer too small to hold version\n");
275                         GOTO(out, err = -EINVAL);
276                 }
277
278                 obd = class_num2obd(index);
279                 if (!obd)
280                         GOTO(out, err = -ENOENT);
281
282                 if (obd->obd_stopping)
283                         status = "ST";
284                 else if (obd->obd_set_up)
285                         status = "UP";
286                 else if (obd->obd_attached)
287                         status = "AT";
288                 else
289                         status = "--";
290                 str = (char *)data->ioc_bulk;
291                 snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d",
292                          (int)index, status, obd->obd_type->typ_name,
293                          obd->obd_name, obd->obd_uuid.uuid,
294                          cfs_atomic_read(&obd->obd_refcount));
295                 err = obd_ioctl_popdata((void *)arg, data, len);
296
297                 GOTO(out, err = 0);
298         }
299
300         }
301
302         if (data->ioc_dev == OBD_DEV_BY_DEVNAME) {
303                 if (data->ioc_inllen4 <= 0 || data->ioc_inlbuf4 == NULL)
304                         GOTO(out, err = -EINVAL);
305                 if (strnlen(data->ioc_inlbuf4, MAX_OBD_NAME) >= MAX_OBD_NAME)
306                         GOTO(out, err = -EINVAL);
307                 obd = class_name2obd(data->ioc_inlbuf4);
308         } else if (data->ioc_dev < class_devno_max()) {
309                 obd = class_num2obd(data->ioc_dev);
310         } else {
311                 CERROR("OBD ioctl: No device\n");
312                 GOTO(out, err = -EINVAL);
313         }
314
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 #ifdef __KERNEL__
359 extern cfs_psdev_t obd_psdev;
360 #else
361 void *obd_psdev = NULL;
362 #endif
363
364 EXPORT_SYMBOL(obd_devs);
365 EXPORT_SYMBOL(obd_print_fail_loc);
366 EXPORT_SYMBOL(obd_race_waitq);
367 EXPORT_SYMBOL(obd_race_state);
368 EXPORT_SYMBOL(obd_debug_peer_on_timeout);
369 EXPORT_SYMBOL(obd_dump_on_timeout);
370 EXPORT_SYMBOL(obd_dump_on_eviction);
371 EXPORT_SYMBOL(obd_timeout);
372 EXPORT_SYMBOL(ldlm_timeout);
373 EXPORT_SYMBOL(obd_max_dirty_pages);
374 EXPORT_SYMBOL(obd_dirty_pages);
375 EXPORT_SYMBOL(obd_dirty_transit_pages);
376 EXPORT_SYMBOL(at_min);
377 EXPORT_SYMBOL(at_max);
378 EXPORT_SYMBOL(at_extra);
379 EXPORT_SYMBOL(at_early_margin);
380 EXPORT_SYMBOL(at_history);
381 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
382
383 EXPORT_SYMBOL(proc_lustre_root);
384
385 EXPORT_SYMBOL(class_register_type);
386 EXPORT_SYMBOL(class_unregister_type);
387 EXPORT_SYMBOL(class_get_type);
388 EXPORT_SYMBOL(class_put_type);
389 EXPORT_SYMBOL(class_name2dev);
390 EXPORT_SYMBOL(class_name2obd);
391 EXPORT_SYMBOL(class_uuid2dev);
392 EXPORT_SYMBOL(class_uuid2obd);
393 EXPORT_SYMBOL(class_find_client_obd);
394 EXPORT_SYMBOL(class_devices_in_group);
395 EXPORT_SYMBOL(class_conn2export);
396 EXPORT_SYMBOL(class_exp2obd);
397 EXPORT_SYMBOL(class_conn2obd);
398 EXPORT_SYMBOL(class_exp2cliimp);
399 EXPORT_SYMBOL(class_conn2cliimp);
400 EXPORT_SYMBOL(class_disconnect);
401 EXPORT_SYMBOL(class_num2obd);
402
403 /* uuid.c */
404 EXPORT_SYMBOL(class_uuid_unparse);
405 EXPORT_SYMBOL(lustre_uuid_to_peer);
406
407 EXPORT_SYMBOL(class_handle_hash);
408 EXPORT_SYMBOL(class_handle_unhash);
409 EXPORT_SYMBOL(class_handle_hash_back);
410 EXPORT_SYMBOL(class_handle2object);
411 EXPORT_SYMBOL(class_handle_free_cb);
412
413 /* obd_config.c */
414 EXPORT_SYMBOL(class_incref);
415 EXPORT_SYMBOL(class_decref);
416 EXPORT_SYMBOL(class_get_profile);
417 EXPORT_SYMBOL(class_del_profile);
418 EXPORT_SYMBOL(class_del_profiles);
419 EXPORT_SYMBOL(class_process_config);
420 EXPORT_SYMBOL(class_process_proc_param);
421 EXPORT_SYMBOL(class_config_parse_llog);
422 EXPORT_SYMBOL(class_config_dump_llog);
423 EXPORT_SYMBOL(class_attach);
424 EXPORT_SYMBOL(class_setup);
425 EXPORT_SYMBOL(class_cleanup);
426 EXPORT_SYMBOL(class_detach);
427 EXPORT_SYMBOL(class_manual_cleanup);
428
429 /* mea.c */
430 EXPORT_SYMBOL(mea_name2idx);
431 EXPORT_SYMBOL(raw_name2idx);
432
433 #define OBD_INIT_CHECK
434 #ifdef OBD_INIT_CHECK
435 int obd_init_checks(void)
436 {
437         __u64 u64val, div64val;
438         char buf[64];
439         int len, ret = 0;
440
441         CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s\n", LPU64, LPD64, LPX64);
442
443         CDEBUG(D_INFO, "OBD_OBJECT_EOF = "LPX64"\n", (__u64)OBD_OBJECT_EOF);
444
445         u64val = OBD_OBJECT_EOF;
446         CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val);
447         if (u64val != OBD_OBJECT_EOF) {
448                 CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n",
449                        u64val, (int)sizeof(u64val));
450                 ret = -EINVAL;
451         }
452         len = snprintf(buf, sizeof(buf), LPX64, u64val);
453         if (len != 18) {
454                 CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
455                 ret = -EINVAL;
456         }
457
458         div64val = OBD_OBJECT_EOF;
459         CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val);
460         if (u64val != OBD_OBJECT_EOF) {
461                 CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n",
462                        u64val, (int)sizeof(u64val));
463                 ret = -EOVERFLOW;
464         }
465         if (u64val >> 8 != OBD_OBJECT_EOF >> 8) {
466                 CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n",
467                        u64val, (int)sizeof(u64val));
468                 return -EOVERFLOW;
469         }
470         if (do_div(div64val, 256) != (u64val & 255)) {
471                 CERROR("do_div("LPX64",256) != "LPU64"\n", u64val, u64val &255);
472                 return -EOVERFLOW;
473         }
474         if (u64val >> 8 != div64val) {
475                 CERROR("do_div("LPX64",256) "LPU64" != "LPU64"\n",
476                        u64val, div64val, u64val >> 8);
477                 return -EOVERFLOW;
478         }
479         len = snprintf(buf, sizeof(buf), LPX64, u64val);
480         if (len != 18) {
481                 CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len);
482                 ret = -EINVAL;
483         }
484         len = snprintf(buf, sizeof(buf), LPU64, u64val);
485         if (len != 20) {
486                 CWARN("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len);
487                 ret = -EINVAL;
488         }
489         len = snprintf(buf, sizeof(buf), LPD64, u64val);
490         if (len != 2) {
491                 CWARN("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len);
492                 ret = -EINVAL;
493         }
494         if ((u64val & ~CFS_PAGE_MASK) >= CFS_PAGE_SIZE) {
495                 CWARN("mask failed: u64val "LPU64" >= "LPU64"\n", u64val,
496                       (__u64)CFS_PAGE_SIZE);
497                 ret = -EINVAL;
498         }
499
500         return ret;
501 }
502 #else
503 #define obd_init_checks() do {} while(0)
504 #endif
505
506 extern cfs_spinlock_t obd_types_lock;
507 extern int class_procfs_init(void);
508 extern int class_procfs_clean(void);
509
510 #ifdef __KERNEL__
511 static int __init init_obdclass(void)
512 #else
513 int init_obdclass(void)
514 #endif
515 {
516         int i, err;
517 #ifdef __KERNEL__
518         int lustre_register_fs(void);
519
520         for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
521                 CFS_INIT_LIST_HEAD(&capa_list[i]);
522 #endif
523
524         LCONSOLE_INFO("OBD class driver, http://www.lustre.org/\n");
525         LCONSOLE_INFO("        Lustre Version: "LUSTRE_VERSION_STRING"\n");
526         LCONSOLE_INFO("        Build Version: "BUILD_VERSION"\n");
527
528         cfs_spin_lock_init(&obd_types_lock);
529         cfs_waitq_init(&obd_race_waitq);
530         obd_zombie_impexp_init();
531 #ifdef LPROCFS
532         obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
533                                          LPROCFS_STATS_FLAG_NONE);
534         if (obd_memory == NULL) {
535                 CERROR("kmalloc of 'obd_memory' failed\n");
536                 RETURN(-ENOMEM);
537         }
538
539         lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
540                              LPROCFS_CNTR_AVGMINMAX,
541                              "memused", "bytes");
542         lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
543                              LPROCFS_CNTR_AVGMINMAX,
544                              "pagesused", "pages");
545 #endif
546         err = obd_init_checks();
547         if (err == -EOVERFLOW)
548                 return err;
549
550         class_init_uuidlist();
551         err = class_handle_init();
552         if (err)
553                 return err;
554
555         cfs_spin_lock_init(&obd_dev_lock);
556         CFS_INIT_LIST_HEAD(&obd_types);
557
558         err = cfs_psdev_register(&obd_psdev);
559         if (err) {
560                 CERROR("cannot register %d err %d\n", OBD_DEV_MINOR, err);
561                 return err;
562         }
563
564         /* This struct is already zeroed for us (static global) */
565         for (i = 0; i < class_devno_max(); i++)
566                 obd_devs[i] = NULL;
567
568         /* Default the dirty page cache cap to 1/2 of system memory.
569          * For clients with less memory, a larger fraction is needed
570          * for other purposes (mostly for BGL). */
571         if (cfs_num_physpages <= 512 << (20 - CFS_PAGE_SHIFT))
572                 obd_max_dirty_pages = cfs_num_physpages / 4;
573         else
574                 obd_max_dirty_pages = cfs_num_physpages / 2;
575
576         err = obd_init_caches();
577         if (err)
578                 return err;
579 #ifdef __KERNEL__
580         err = class_procfs_init();
581         if (err)
582                 return err;
583 #endif
584
585         err = lu_global_init();
586         if (err)
587                 return err;
588
589 #ifdef __KERNEL__
590         err = lustre_register_fs();
591 #endif
592
593         return err;
594 }
595
596 /* liblustre doesn't call cleanup_obdclass, apparently.  we carry on in this
597  * ifdef to the end of the file to cover module and versioning goo.*/
598 #ifdef __KERNEL__
599 static void cleanup_obdclass(void)
600 {
601         int i;
602         int lustre_unregister_fs(void);
603         __u64 memory_leaked, pages_leaked;
604         __u64 memory_max, pages_max;
605         ENTRY;
606
607         lustre_unregister_fs();
608
609         cfs_psdev_deregister(&obd_psdev);
610         for (i = 0; i < class_devno_max(); i++) {
611                 struct obd_device *obd = class_num2obd(i);
612                 if (obd && obd->obd_set_up &&
613                     OBT(obd) && OBP(obd, detach)) {
614                         /* XXX should this call generic detach otherwise? */
615                         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
616                         OBP(obd, detach)(obd);
617                 }
618         }
619         lu_global_fini();
620
621         obd_cleanup_caches();
622         obd_sysctl_clean();
623
624         class_procfs_clean();
625
626         class_handle_cleanup();
627         class_exit_uuidlist();
628         obd_zombie_impexp_stop();
629
630         memory_leaked = obd_memory_sum();
631         pages_leaked = obd_pages_sum();
632
633         memory_max = obd_memory_max();
634         pages_max = obd_pages_max();
635
636         lprocfs_free_stats(&obd_memory);
637         CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
638                "obd_memory max: "LPU64", leaked: "LPU64"\n",
639                memory_max, memory_leaked);
640         CDEBUG((pages_leaked) ? D_ERROR : D_INFO,
641                "obd_memory_pages max: "LPU64", leaked: "LPU64"\n",
642                pages_max, pages_leaked);
643
644         EXIT;
645 }
646
647 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
648 MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
649 MODULE_LICENSE("GPL");
650
651 cfs_module(obdclass, LUSTRE_VERSION_STRING, init_obdclass, cleanup_obdclass);
652 #endif