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