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