Whamcloud - gitweb
LU-694 ptlrpc: Job Stats
[fs/lustre-release.git] / lustre / obdclass / class_obd.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, Whamcloud, Inc.
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_rwlock_t obd_dev_lock = CFS_RW_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 char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
90 EXPORT_SYMBOL(obd_jobid_var);
91
92 /* Get jobid of current process by reading the environment variable
93  * stored in between the "env_start" & "env_end" of task struct.
94  *
95  * TODO:
96  * It's better to cache the jobid for later use if there is any
97  * efficient way, the cl_env code probably could be reused for this
98  * purpose.
99  *
100  * If some job scheduler doesn't store jobid in the "env_start/end",
101  * then an upcall could be issued here to get the jobid by utilizing
102  * the userspace tools/api. Then, the jobid must be cached.
103  */
104 int lustre_get_jobid(char *jobid)
105 {
106 #ifdef __KERNEL__
107         int jobid_len = JOBSTATS_JOBID_SIZE;
108 #endif
109         int ret = 0;
110         ENTRY;
111
112         memset(jobid, 0, JOBSTATS_JOBID_SIZE);
113         /* Jobstats isn't enabled */
114         if (!memcmp(obd_jobid_var, JOBSTATS_DISABLE,
115                     strlen(JOBSTATS_DISABLE))) {
116                 RETURN(0);
117         }
118
119         /* Use process name + fsuid as jobid */
120         if (!memcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID,
121                     strlen(JOBSTATS_PROCNAME_UID))) {
122                 snprintf(jobid, JOBSTATS_JOBID_SIZE, "%s_%u",
123                          cfs_curproc_comm(), cfs_curproc_fsuid());
124                 RETURN(0);
125         }
126
127 #ifdef __KERNEL__
128         ret = cfs_get_environ(obd_jobid_var, jobid, &jobid_len);
129         if (ret) {
130                 CDEBUG((ret != -ENOENT && ret != -EINVAL) ? D_ERROR : D_INFO,
131                        "Get jobid for (%s) failed(%d).\n", obd_jobid_var, ret);
132         }
133 #endif
134         RETURN(ret);
135 }
136 EXPORT_SYMBOL(lustre_get_jobid);
137
138 static inline void obd_data2conn(struct lustre_handle *conn,
139                                  struct obd_ioctl_data *data)
140 {
141         memset(conn, 0, sizeof *conn);
142         conn->cookie = data->ioc_cookie;
143 }
144
145 static inline void obd_conn2data(struct obd_ioctl_data *data,
146                                  struct lustre_handle *conn)
147 {
148         data->ioc_cookie = conn->cookie;
149 }
150
151 int class_resolve_dev_name(__u32 len, const char *name)
152 {
153         int rc;
154         int dev;
155
156         ENTRY;
157         if (!len || !name) {
158                 CERROR("No name passed,!\n");
159                 GOTO(out, rc = -EINVAL);
160         }
161         if (name[len - 1] != 0) {
162                 CERROR("Name not nul terminated!\n");
163                 GOTO(out, rc = -EINVAL);
164         }
165
166         CDEBUG(D_IOCTL, "device name %s\n", name);
167         dev = class_name2dev(name);
168         if (dev == -1) {
169                 CDEBUG(D_IOCTL, "No device for name %s!\n", name);
170                 GOTO(out, rc = -EINVAL);
171         }
172
173         CDEBUG(D_IOCTL, "device name %s, dev %d\n", name, dev);
174         rc = dev;
175
176 out:
177         RETURN(rc);
178 }
179
180 int class_handle_ioctl(unsigned int cmd, unsigned long arg)
181 {
182         char *buf = NULL;
183         struct obd_ioctl_data *data;
184         struct libcfs_debug_ioctl_data *debug_data;
185         struct obd_device *obd = NULL;
186         int err = 0, len = 0;
187         ENTRY;
188
189         /* only for debugging */
190         if (cmd == LIBCFS_IOC_DEBUG_MASK) {
191                 debug_data = (struct libcfs_debug_ioctl_data*)arg;
192                 libcfs_subsystem_debug = debug_data->subs;
193                 libcfs_debug = debug_data->debug;
194                 return 0;
195         }
196
197         CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
198         if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
199                 CERROR("OBD ioctl: data error\n");
200                 RETURN(-EINVAL);
201         }
202         data = (struct obd_ioctl_data *)buf;
203
204         switch (cmd) {
205         case OBD_IOC_PROCESS_CFG: {
206                 struct lustre_cfg *lcfg;
207
208                 if (!data->ioc_plen1 || !data->ioc_pbuf1) {
209                         CERROR("No config buffer passed!\n");
210                         GOTO(out, err = -EINVAL);
211                 }
212                 OBD_ALLOC(lcfg, data->ioc_plen1);
213                 if (lcfg == NULL)
214                         GOTO(out, err = -ENOMEM);
215                 err = cfs_copy_from_user(lcfg, data->ioc_pbuf1,
216                                          data->ioc_plen1);
217                 if (!err)
218                         err = lustre_cfg_sanity_check(lcfg, data->ioc_plen1);
219                 if (!err)
220                         err = class_process_config(lcfg);
221
222                 OBD_FREE(lcfg, data->ioc_plen1);
223                 GOTO(out, err);
224         }
225
226         case OBD_GET_VERSION:
227                 if (!data->ioc_inlbuf1) {
228                         CERROR("No buffer passed in ioctl\n");
229                         GOTO(out, err = -EINVAL);
230                 }
231
232                 if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
233                         CERROR("ioctl buffer too small to hold version\n");
234                         GOTO(out, err = -EINVAL);
235                 }
236
237                 memcpy(data->ioc_bulk, BUILD_VERSION,
238                        strlen(BUILD_VERSION) + 1);
239
240                 err = obd_ioctl_popdata((void *)arg, data, len);
241                 if (err)
242                         err = -EFAULT;
243                 GOTO(out, err);
244
245         case OBD_IOC_NAME2DEV: {
246                 /* Resolve a device name.  This does not change the
247                  * currently selected device.
248                  */
249                 int dev;
250
251                 dev = class_resolve_dev_name(data->ioc_inllen1,
252                                              data->ioc_inlbuf1);
253                 data->ioc_dev = dev;
254                 if (dev < 0)
255                         GOTO(out, err = -EINVAL);
256
257                 err = obd_ioctl_popdata((void *)arg, data, sizeof(*data));
258                 if (err)
259                         err = -EFAULT;
260                 GOTO(out, err);
261         }
262
263         case OBD_IOC_UUID2DEV: {
264                 /* Resolve a device uuid.  This does not change the
265                  * currently selected device.
266                  */
267                 int dev;
268                 struct obd_uuid uuid;
269
270                 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
271                         CERROR("No UUID passed!\n");
272                         GOTO(out, err = -EINVAL);
273                 }
274                 if (data->ioc_inlbuf1[data->ioc_inllen1 - 1] != 0) {
275                         CERROR("UUID not NUL terminated!\n");
276                         GOTO(out, err = -EINVAL);
277                 }
278
279                 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
280                 obd_str2uuid(&uuid, data->ioc_inlbuf1);
281                 dev = class_uuid2dev(&uuid);
282                 data->ioc_dev = dev;
283                 if (dev == -1) {
284                         CDEBUG(D_IOCTL, "No device for UUID %s!\n",
285                                data->ioc_inlbuf1);
286                         GOTO(out, err = -EINVAL);
287                 }
288
289                 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
290                        dev);
291                 err = obd_ioctl_popdata((void *)arg, data, sizeof(*data));
292                 if (err)
293                         err = -EFAULT;
294                 GOTO(out, err);
295         }
296
297         case OBD_IOC_CLOSE_UUID: {
298                 CDEBUG(D_IOCTL, "closing all connections to uuid %s (NOOP)\n",
299                        data->ioc_inlbuf1);
300                 GOTO(out, err = 0);
301         }
302
303         case OBD_IOC_GETDEVICE: {
304                 int     index = data->ioc_count;
305                 char    *status, *str;
306
307                 if (!data->ioc_inlbuf1) {
308                         CERROR("No buffer passed in ioctl\n");
309                         GOTO(out, err = -EINVAL);
310                 }
311                 if (data->ioc_inllen1 < 128) {
312                         CERROR("ioctl buffer too small to hold version\n");
313                         GOTO(out, err = -EINVAL);
314                 }
315
316                 obd = class_num2obd(index);
317                 if (!obd)
318                         GOTO(out, err = -ENOENT);
319
320                 if (obd->obd_stopping)
321                         status = "ST";
322                 else if (obd->obd_set_up)
323                         status = "UP";
324                 else if (obd->obd_attached)
325                         status = "AT";
326                 else
327                         status = "--";
328                 str = (char *)data->ioc_bulk;
329                 snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d",
330                          (int)index, status, obd->obd_type->typ_name,
331                          obd->obd_name, obd->obd_uuid.uuid,
332                          cfs_atomic_read(&obd->obd_refcount));
333                 err = obd_ioctl_popdata((void *)arg, data, len);
334
335                 GOTO(out, err = 0);
336         }
337
338         }
339
340         if (data->ioc_dev == OBD_DEV_BY_DEVNAME) {
341                 if (data->ioc_inllen4 <= 0 || data->ioc_inlbuf4 == NULL)
342                         GOTO(out, err = -EINVAL);
343                 if (strnlen(data->ioc_inlbuf4, MAX_OBD_NAME) >= MAX_OBD_NAME)
344                         GOTO(out, err = -EINVAL);
345                 obd = class_name2obd(data->ioc_inlbuf4);
346         } else if (data->ioc_dev < class_devno_max()) {
347                 obd = class_num2obd(data->ioc_dev);
348         } else {
349                 CERROR("OBD ioctl: No device\n");
350                 GOTO(out, err = -EINVAL);
351         }
352
353         if (obd == NULL) {
354                 CERROR("OBD ioctl : No Device %d\n", data->ioc_dev);
355                 GOTO(out, err = -EINVAL);
356         }
357         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
358
359         if (!obd->obd_set_up || obd->obd_stopping) {
360                 CERROR("OBD ioctl: device not setup %d \n", data->ioc_dev);
361                 GOTO(out, err = -EINVAL);
362         }
363
364         switch(cmd) {
365         case OBD_IOC_NO_TRANSNO: {
366                 if (!obd->obd_attached) {
367                         CERROR("Device %d not attached\n", obd->obd_minor);
368                         GOTO(out, err = -ENODEV);
369                 }
370                 CDEBUG(D_HA, "%s: disabling committed-transno notification\n",
371                        obd->obd_name);
372                 obd->obd_no_transno = 1;
373                 GOTO(out, err = 0);
374         }
375
376         default: {
377                 err = obd_iocontrol(cmd, obd->obd_self_export, len, data, NULL);
378                 if (err)
379                         GOTO(out, err);
380
381                 err = obd_ioctl_popdata((void *)arg, data, len);
382                 if (err)
383                         err = -EFAULT;
384                 GOTO(out, err);
385         }
386         }
387
388  out:
389         if (buf)
390                 obd_ioctl_freedata(buf, len);
391         RETURN(err);
392 } /* class_handle_ioctl */
393
394
395
396 #ifdef __KERNEL__
397 extern cfs_psdev_t obd_psdev;
398 #else
399 void *obd_psdev = NULL;
400 #endif
401
402 EXPORT_SYMBOL(obd_devs);
403 EXPORT_SYMBOL(obd_debug_peer_on_timeout);
404 EXPORT_SYMBOL(obd_dump_on_timeout);
405 EXPORT_SYMBOL(obd_dump_on_eviction);
406 EXPORT_SYMBOL(obd_timeout);
407 EXPORT_SYMBOL(ldlm_timeout);
408 EXPORT_SYMBOL(obd_max_dirty_pages);
409 EXPORT_SYMBOL(obd_dirty_pages);
410 EXPORT_SYMBOL(obd_dirty_transit_pages);
411 EXPORT_SYMBOL(at_min);
412 EXPORT_SYMBOL(at_max);
413 EXPORT_SYMBOL(at_extra);
414 EXPORT_SYMBOL(at_early_margin);
415 EXPORT_SYMBOL(at_history);
416 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
417 EXPORT_SYMBOL(proc_lustre_root);
418
419 /* uuid.c */
420 EXPORT_SYMBOL(class_uuid_unparse);
421 EXPORT_SYMBOL(lustre_uuid_to_peer);
422
423 EXPORT_SYMBOL(class_handle_hash);
424 EXPORT_SYMBOL(class_handle_unhash);
425 EXPORT_SYMBOL(class_handle_hash_back);
426 EXPORT_SYMBOL(class_handle2object);
427 EXPORT_SYMBOL(class_handle_free_cb);
428
429 /* obd_config.c */
430 EXPORT_SYMBOL(class_incref);
431 EXPORT_SYMBOL(class_decref);
432 EXPORT_SYMBOL(class_get_profile);
433 EXPORT_SYMBOL(class_del_profile);
434 EXPORT_SYMBOL(class_del_profiles);
435 EXPORT_SYMBOL(class_process_config);
436 EXPORT_SYMBOL(class_process_proc_param);
437 EXPORT_SYMBOL(class_config_parse_llog);
438 EXPORT_SYMBOL(class_config_dump_llog);
439 EXPORT_SYMBOL(class_attach);
440 EXPORT_SYMBOL(class_setup);
441 EXPORT_SYMBOL(class_cleanup);
442 EXPORT_SYMBOL(class_detach);
443 EXPORT_SYMBOL(class_manual_cleanup);
444
445 /* mea.c */
446 EXPORT_SYMBOL(mea_name2idx);
447 EXPORT_SYMBOL(raw_name2idx);
448
449 #define OBD_INIT_CHECK
450 #ifdef OBD_INIT_CHECK
451 int obd_init_checks(void)
452 {
453         __u64 u64val, div64val;
454         char buf[64];
455         int len, ret = 0;
456
457         CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s\n", LPU64, LPD64, LPX64);
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" >= "LPU64"\n", u64val,
512                       (__u64)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 cfs_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         for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
537                 CFS_INIT_LIST_HEAD(&capa_list[i]);
538 #endif
539
540         LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n");
541
542         cfs_spin_lock_init(&obd_types_lock);
543         obd_zombie_impexp_init();
544 #ifdef LPROCFS
545         obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
546                                          LPROCFS_STATS_FLAG_NONE);
547         if (obd_memory == NULL) {
548                 CERROR("kmalloc of 'obd_memory' failed\n");
549                 RETURN(-ENOMEM);
550         }
551
552         lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
553                              LPROCFS_CNTR_AVGMINMAX,
554                              "memused", "bytes");
555         lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
556                              LPROCFS_CNTR_AVGMINMAX,
557                              "pagesused", "pages");
558 #endif
559         err = obd_init_checks();
560         if (err == -EOVERFLOW)
561                 return err;
562
563         class_init_uuidlist();
564         err = class_handle_init();
565         if (err)
566                 return err;
567
568         CFS_INIT_LIST_HEAD(&obd_types);
569
570         err = cfs_psdev_register(&obd_psdev);
571         if (err) {
572                 CERROR("cannot register %d err %d\n", OBD_DEV_MINOR, err);
573                 return err;
574         }
575
576         /* This struct is already zeroed for us (static global) */
577         for (i = 0; i < class_devno_max(); i++)
578                 obd_devs[i] = NULL;
579
580         /* Default the dirty page cache cap to 1/2 of system memory.
581          * For clients with less memory, a larger fraction is needed
582          * for other purposes (mostly for BGL). */
583         if (cfs_num_physpages <= 512 << (20 - CFS_PAGE_SHIFT))
584                 obd_max_dirty_pages = cfs_num_physpages / 4;
585         else
586                 obd_max_dirty_pages = cfs_num_physpages / 2;
587
588         err = obd_init_caches();
589         if (err)
590                 return err;
591 #ifdef __KERNEL__
592         err = class_procfs_init();
593         if (err)
594                 return err;
595 #endif
596
597         err = lu_global_init();
598         if (err)
599                 return err;
600
601 #ifdef __KERNEL__
602         err = lustre_register_fs();
603 #endif
604
605         return err;
606 }
607
608 /* liblustre doesn't call cleanup_obdclass, apparently.  we carry on in this
609  * ifdef to the end of the file to cover module and versioning goo.*/
610 #ifdef __KERNEL__
611 static void cleanup_obdclass(void)
612 {
613         int i;
614         int lustre_unregister_fs(void);
615         __u64 memory_leaked, pages_leaked;
616         __u64 memory_max, pages_max;
617         ENTRY;
618
619         lustre_unregister_fs();
620
621         cfs_psdev_deregister(&obd_psdev);
622         for (i = 0; i < class_devno_max(); i++) {
623                 struct obd_device *obd = class_num2obd(i);
624                 if (obd && obd->obd_set_up &&
625                     OBT(obd) && OBP(obd, detach)) {
626                         /* XXX should this call generic detach otherwise? */
627                         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
628                         OBP(obd, detach)(obd);
629                 }
630         }
631         lu_global_fini();
632
633         obd_cleanup_caches();
634         obd_sysctl_clean();
635
636         class_procfs_clean();
637
638         class_handle_cleanup();
639         class_exit_uuidlist();
640         obd_zombie_impexp_stop();
641
642         memory_leaked = obd_memory_sum();
643         pages_leaked = obd_pages_sum();
644
645         memory_max = obd_memory_max();
646         pages_max = obd_pages_max();
647
648         lprocfs_free_stats(&obd_memory);
649         CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
650                "obd_memory max: "LPU64", leaked: "LPU64"\n",
651                memory_max, memory_leaked);
652         CDEBUG((pages_leaked) ? D_ERROR : D_INFO,
653                "obd_memory_pages max: "LPU64", leaked: "LPU64"\n",
654                pages_max, pages_leaked);
655
656         EXIT;
657 }
658
659 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
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