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