1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Object Devices Class Driver
6 * Copyright (C) 2001-2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * These are the only exported functions, they provide some generic
24 * infrastructure for managing object devices
27 #define DEBUG_SUBSYSTEM S_CLASS
30 #include <linux/config.h> /* for CONFIG_PROC_FS */
31 #include <linux/module.h>
32 #include <linux/errno.h>
33 #include <linux/kernel.h>
34 #include <linux/major.h>
35 #include <linux/sched.h>
37 #include <linux/slab.h>
38 #include <linux/ioport.h>
39 #include <linux/fcntl.h>
40 #include <linux/delay.h>
41 #include <linux/skbuff.h>
42 #include <linux/proc_fs.h>
44 #include <linux/poll.h>
45 #include <linux/init.h>
46 #include <linux/list.h>
47 #include <linux/highmem.h>
49 #include <asm/ioctls.h>
50 #include <asm/system.h>
52 #include <asm/uaccess.h>
53 #include <linux/miscdevice.h>
54 #include <linux/smp_lock.h>
57 # include <liblustre.h>
61 #include <linux/obd_support.h>
62 #include <linux/obd_class.h>
63 #include <linux/lustre_debug.h>
64 #include <linux/lprocfs_status.h>
65 #include <portals/lib-types.h> /* for PTL_MD_MAX_IOV */
66 #include <linux/lustre_build_version.h>
68 struct semaphore obd_conf_sem; /* serialize configuration commands */
69 struct obd_device obd_dev[MAX_OBD_DEVICES];
70 struct list_head obd_types;
74 /* Root for /proc/lustre */
75 struct proc_dir_entry *proc_lustre_root = NULL;
76 int obd_proc_read_version(char *page, char **start, off_t off, int count, int *eof, void *data);
77 struct lprocfs_vars lprocfs_version[] = {{"version", obd_proc_read_version, NULL, NULL },{NULL,NULL,NULL,NULL}};
80 /* The following are visible and mutable through /proc/sys/lustre/. */
81 unsigned long obd_fail_loc;
82 unsigned long obd_timeout = 100;
83 unsigned long obd_bulk_timeout = 1;
84 char obd_lustre_upcall[128] = "/usr/lib/lustre/lustre_upcall";
85 unsigned long obd_sync_filter; /* = 0, don't sync by default */
88 /* opening /dev/obd */
89 static int obd_class_open(struct inode * inode, struct file * file)
91 struct obd_class_user_state *ocus;
94 OBD_ALLOC(ocus, sizeof(*ocus));
98 INIT_LIST_HEAD(&ocus->ocus_conns);
99 file->private_data = ocus;
105 /* closing /dev/obd */
106 static int obd_class_release(struct inode * inode, struct file * file)
108 struct obd_class_user_state *ocus = file->private_data;
109 struct obd_class_user_conn *c;
112 while (!list_empty (&ocus->ocus_conns)) {
113 c = list_entry (ocus->ocus_conns.next,
114 struct obd_class_user_conn, ocuc_chain);
115 list_del (&c->ocuc_chain);
117 CDEBUG (D_IOCTL, "Auto-disconnect %p\n", &c->ocuc_conn);
119 down (&obd_conf_sem);
120 obd_disconnect (&c->ocuc_conn, 0);
123 OBD_FREE (c, sizeof (*c));
126 OBD_FREE (ocus, sizeof (*ocus));
134 obd_class_add_user_conn (struct obd_class_user_state *ocus,
135 struct lustre_handle *conn)
137 struct obd_class_user_conn *c;
139 /* NB holding obd_conf_sem */
141 OBD_ALLOC (c, sizeof (*c));
145 c->ocuc_conn = *conn;
146 list_add (&c->ocuc_chain, &ocus->ocus_conns);
151 obd_class_remove_user_conn (struct obd_class_user_state *ocus,
152 struct lustre_handle *conn)
155 struct obd_class_user_conn *c;
157 /* NB holding obd_conf_sem or last reference */
159 list_for_each (e, &ocus->ocus_conns) {
160 c = list_entry (e, struct obd_class_user_conn, ocuc_chain);
161 if (conn->cookie == c->ocuc_conn.cookie) {
162 list_del (&c->ocuc_chain);
163 OBD_FREE (c, sizeof (*c));
169 static inline void obd_data2conn(struct lustre_handle *conn,
170 struct obd_ioctl_data *data)
172 memset(conn, 0, sizeof *conn);
173 conn->cookie = data->ioc_cookie;
176 static inline void obd_conn2data(struct obd_ioctl_data *data,
177 struct lustre_handle *conn)
179 data->ioc_cookie = conn->cookie;
182 static void dump_exports(struct obd_device *obd)
184 struct list_head *tmp, *n;
186 list_for_each_safe(tmp, n, &obd->obd_exports) {
187 struct obd_export *exp = list_entry(tmp, struct obd_export,
189 CDEBUG(D_ERROR, "%s: %p %s %d %d %p\n",
190 obd->obd_name, exp, exp->exp_client_uuid.uuid,
191 atomic_read(&exp->exp_refcount),
192 exp->exp_failed, exp->exp_outstanding_reply );
196 int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd,
200 struct obd_ioctl_data *data;
201 struct portals_debug_ioctl_data *debug_data;
202 struct obd_device *obd = ocus->ocus_current_obd;
203 struct lustre_handle conn;
204 int err = 0, len = 0, serialised = 0;
207 if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
208 RETURN(err = -ENOTTY);
210 /* only for debugging */
211 if (cmd == PTL_IOC_DEBUG_MASK) {
212 debug_data = (struct portals_debug_ioctl_data*)arg;
213 portal_subsystem_debug = debug_data->subs;
214 portal_debug = debug_data->debug;
219 case OBD_IOC_BRW_WRITE:
220 case OBD_IOC_BRW_READ:
221 case OBD_IOC_GETATTR:
222 case ECHO_IOC_ENQUEUE:
223 case ECHO_IOC_CANCEL:
231 CDEBUG(D_IOCTL, "cmd = %x, obd = %p\n", cmd, obd);
232 if (!obd && cmd != OBD_IOC_DEVICE &&
233 cmd != OBD_IOC_LIST && cmd != OBD_GET_VERSION &&
234 cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_UUID2DEV &&
235 cmd != OBD_IOC_NEWDEV && cmd != OBD_IOC_ADD_UUID &&
236 cmd != OBD_IOC_DEL_UUID && cmd != OBD_IOC_CLOSE_UUID) {
237 CERROR("OBD ioctl: No device\n");
238 GOTO(out, err = -EINVAL);
240 if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
241 CERROR("OBD ioctl: data error\n");
242 GOTO(out, err = -EINVAL);
244 data = (struct obd_ioctl_data *)buf;
247 case OBD_IOC_DEVICE: {
248 CDEBUG(D_IOCTL, "\n");
249 if (data->ioc_dev >= MAX_OBD_DEVICES || data->ioc_dev < 0) {
250 CERROR("OBD ioctl: DEVICE invalid device %d\n",
252 GOTO(out, err = -EINVAL);
254 CDEBUG(D_IOCTL, "device %d\n", data->ioc_dev);
256 ocus->ocus_current_obd = &obd_dev[data->ioc_dev];
262 char *buf2 = data->ioc_bulk;
263 int remains = data->ioc_inllen1;
265 if (!data->ioc_inlbuf1) {
266 CERROR("No buffer passed!\n");
267 GOTO(out, err = -EINVAL);
271 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
274 struct obd_device *obd = &obd_dev[i];
278 if (obd->obd_stopping)
280 else if (obd->obd_set_up)
282 else if (obd->obd_attached)
286 l = snprintf(buf2, remains, "%2d %s %s %s %s %d\n",
287 i, status, obd->obd_type->typ_name,
288 obd->obd_name, obd->obd_uuid.uuid,
289 obd->obd_type->typ_refcnt);
293 CERROR("not enough space for device listing\n");
298 err = copy_to_user((void *)arg, data, len);
304 case OBD_GET_VERSION:
305 if (!data->ioc_inlbuf1) {
306 CERROR("No buffer passed in ioctl\n");
307 GOTO(out, err = -EINVAL);
310 if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
311 CERROR("ioctl buffer too small to hold version\n");
312 GOTO(out, err = -EINVAL);
315 memcpy(data->ioc_bulk, BUILD_VERSION,
316 strlen(BUILD_VERSION) + 1);
318 err = copy_to_user((void *)arg, data, len);
323 case OBD_IOC_NAME2DEV: {
324 /* Resolve a device name. This does not change the
325 * currently selected device.
329 if (!data->ioc_inllen1 || !data->ioc_inlbuf1 ) {
330 CERROR("No name passed,!\n");
331 GOTO(out, err = -EINVAL);
333 if (data->ioc_inlbuf1[data->ioc_inllen1 - 1] != 0) {
334 CERROR("Name not nul terminated!\n");
335 GOTO(out, err = -EINVAL);
338 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
339 dev = class_name2dev(data->ioc_inlbuf1);
342 CDEBUG(D_IOCTL, "No device for name %s!\n",
344 GOTO(out, err = -EINVAL);
347 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
349 err = copy_to_user((void *)arg, data, sizeof(*data));
355 case OBD_IOC_UUID2DEV: {
356 /* Resolve a device uuid. This does not change the
357 * currently selected device.
360 struct obd_uuid uuid;
362 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
363 CERROR("No UUID passed!\n");
364 GOTO(out, err = -EINVAL);
366 if (data->ioc_inlbuf1[data->ioc_inllen1 - 1] != 0) {
367 CERROR("UUID not NUL terminated!\n");
368 GOTO(out, err = -EINVAL);
371 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
372 obd_str2uuid(&uuid, data->ioc_inlbuf1);
373 dev = class_uuid2dev(&uuid);
376 CDEBUG(D_IOCTL, "No device for UUID %s!\n",
378 GOTO(out, err = -EINVAL);
381 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
383 err = copy_to_user((void *)arg, data, sizeof(*data));
391 case OBD_IOC_NEWDEV: {
395 ocus->ocus_current_obd = NULL;
396 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
397 struct obd_device *obd = &obd_dev[i];
398 if (!obd->obd_type) {
399 ocus->ocus_current_obd = obd;
408 GOTO(out, err = -EINVAL);
410 err = copy_to_user((void *)arg, data, sizeof(*data));
416 case OBD_IOC_ATTACH: {
417 struct obd_type *type;
420 /* have we attached a type to this device */
421 if (obd->obd_attached|| obd->obd_type) {
422 CERROR("OBD: Device %d already typed as %s.\n",
423 obd->obd_minor, MKSTR(obd->obd_type->typ_name));
424 GOTO(out, err = -EBUSY);
427 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
428 CERROR("No type passed!\n");
429 GOTO(out, err = -EINVAL);
431 if (data->ioc_inlbuf1[data->ioc_inllen1 - 1] != 0) {
432 CERROR("Type not nul terminated!\n");
433 GOTO(out, err = -EINVAL);
435 if (!data->ioc_inllen2 || !data->ioc_inlbuf2) {
436 CERROR("No name passed!\n");
437 GOTO(out, err = -EINVAL);
439 if (data->ioc_inlbuf2[data->ioc_inllen2 - 1] != 0) {
440 CERROR("Name not nul terminated!\n");
441 GOTO(out, err = -EINVAL);
443 if (!data->ioc_inllen3 || !data->ioc_inlbuf3) {
444 CERROR("No UUID passed!\n");
445 GOTO(out, err = -EINVAL);
447 if (data->ioc_inlbuf3[data->ioc_inllen3 - 1] != 0) {
448 CERROR("UUID not nul terminated!\n");
449 GOTO(out, err = -EINVAL);
452 CDEBUG(D_IOCTL, "attach type %s name: %s uuid: %s\n",
453 MKSTR(data->ioc_inlbuf1),
454 MKSTR(data->ioc_inlbuf2), MKSTR(data->ioc_inlbuf3));
457 type = class_get_type(data->ioc_inlbuf1);
459 CERROR("OBD: unknown type dev %d\n", obd->obd_minor);
460 GOTO(out, err = -EINVAL);
463 minor = obd->obd_minor;
464 memset(obd, 0, sizeof(*obd));
465 obd->obd_minor = minor;
466 obd->obd_type = type;
467 INIT_LIST_HEAD(&obd->obd_exports);
468 obd->obd_num_exports = 0;
469 INIT_LIST_HEAD(&obd->obd_imports);
470 spin_lock_init(&obd->obd_dev_lock);
471 init_waitqueue_head(&obd->obd_refcount_waitq);
473 /* XXX belong ins setup not attach */
475 spin_lock_init(&obd->obd_processing_task_lock);
476 init_waitqueue_head(&obd->obd_next_transno_waitq);
477 INIT_LIST_HEAD(&obd->obd_recovery_queue);
478 INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
480 init_waitqueue_head(&obd->obd_commit_waitq);
482 len = strlen(data->ioc_inlbuf2) + 1;
483 OBD_ALLOC(obd->obd_name, len);
484 if (!obd->obd_name) {
485 class_put_type(obd->obd_type);
486 obd->obd_type = NULL;
487 GOTO(out, err = -ENOMEM);
489 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
491 len = strlen(data->ioc_inlbuf3);
492 if (len >= sizeof(obd->obd_uuid)) {
493 CERROR("uuid must be < "LPSZ" bytes long\n",
494 sizeof(obd->obd_uuid));
496 OBD_FREE(obd->obd_name,
497 strlen(obd->obd_name) + 1);
498 class_put_type(obd->obd_type);
499 obd->obd_type = NULL;
500 GOTO(out, err = -EINVAL);
502 memcpy(obd->obd_uuid.uuid, data->ioc_inlbuf3, len);
505 if (OBP(obd, attach))
506 err = OBP(obd,attach)(obd, sizeof(*data), data);
508 if(data->ioc_inlbuf2)
509 OBD_FREE(obd->obd_name,
510 strlen(obd->obd_name) + 1);
511 class_put_type(obd->obd_type);
512 obd->obd_type = NULL;
514 obd->obd_attached = 1;
517 CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
518 obd->obd_minor, data->ioc_inlbuf1);
524 case OBD_IOC_DETACH: {
526 if (obd->obd_set_up) {
527 CERROR("OBD device %d still set up\n", obd->obd_minor);
528 GOTO(out, err = -EBUSY);
530 if (!obd->obd_attached) {
531 CERROR("OBD device %d not attached\n", obd->obd_minor);
532 GOTO(out, err = -ENODEV);
534 if (OBP(obd, detach))
535 err = OBP(obd,detach)(obd);
538 OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
539 obd->obd_name = NULL;
542 obd->obd_attached = 0;
543 obd->obd_type->typ_refcnt--;
544 class_put_type(obd->obd_type);
545 obd->obd_type = NULL;
549 case OBD_IOC_SETUP: {
550 /* have we attached a type to this device? */
551 if (!obd->obd_attached) {
552 CERROR("Device %d not attached\n", obd->obd_minor);
553 GOTO(out, err = -ENODEV);
556 /* has this been done already? */
557 if (obd->obd_set_up) {
558 CERROR("Device %d already setup (type %s)\n",
559 obd->obd_minor, obd->obd_type->typ_name);
560 GOTO(out, err = -EBUSY);
563 atomic_set(&obd->obd_refcount, 0);
565 if ( OBT(obd) && OBP(obd, setup) )
566 err = obd_setup(obd, sizeof(*data), data);
569 obd->obd_type->typ_refcnt++;
571 atomic_inc(&obd->obd_refcount);
576 case OBD_IOC_CLEANUP: {
577 int force = 0, failover = 0;
580 if (!obd->obd_set_up) {
581 CERROR("Device %d not setup\n", obd->obd_minor);
582 GOTO(out, err = -ENODEV);
585 if (data->ioc_inlbuf1) {
586 for (flag = data->ioc_inlbuf1; *flag != 0; flag++)
595 CERROR("unrecognised flag '%c'\n",
600 if (atomic_read(&obd->obd_refcount) == 1 || force) {
601 /* this will stop new connections, and need to
602 do it before class_disconnect_exports() */
603 obd->obd_stopping = 1;
606 if (atomic_read(&obd->obd_refcount) > 1) {
607 struct l_wait_info lwi = LWI_TIMEOUT_INTR(60 * HZ, NULL,
612 CERROR("OBD device %d (%p) has refcount %d\n",
614 atomic_read(&obd->obd_refcount));
616 GOTO(out, err = -EBUSY);
618 class_disconnect_exports(obd, failover);
620 "%s: waiting for obd refs to go away: %d\n",
621 obd->obd_name, atomic_read(&obd->obd_refcount));
623 rc = l_wait_event(obd->obd_refcount_waitq,
624 atomic_read(&obd->obd_refcount) < 2, &lwi);
626 LASSERT(atomic_read(&obd->obd_refcount) == 1);
628 CERROR("wait cancelled cleaning anyway. "
630 atomic_read(&obd->obd_refcount));
633 CDEBUG(D_IOCTL, "%s: awake, now finishing cleanup\n",
637 if (OBT(obd) && OBP(obd, cleanup))
638 err = obd_cleanup(obd, force, failover);
641 obd->obd_set_up = obd->obd_stopping = 0;
642 obd->obd_type->typ_refcnt--;
643 atomic_dec(&obd->obd_refcount);
644 /* XXX this should be an LASSERT */
645 if (atomic_read(&obd->obd_refcount) > 0)
646 CERROR("%s still has refcount %d after "
647 "cleanup.\n", obd->obd_name,
648 atomic_read(&obd->obd_refcount));
654 case OBD_IOC_CONNECT: {
655 struct obd_uuid cluuid = { "OBD_CLASS_UUID" };
656 obd_data2conn(&conn, data);
658 err = obd_connect(&conn, obd, &cluuid);
660 CDEBUG(D_IOCTL, "assigned export "LPX64"\n", conn.cookie);
661 obd_conn2data(data, &conn);
665 err = obd_class_add_user_conn (ocus, &conn);
667 obd_disconnect (&conn, 0);
671 err = copy_to_user((void *)arg, data, sizeof(*data));
673 obd_class_remove_user_conn (ocus, &conn);
674 obd_disconnect (&conn, 0);
675 GOTO (out, err = -EFAULT);
680 case OBD_IOC_DISCONNECT: {
681 obd_data2conn(&conn, data);
682 obd_class_remove_user_conn (ocus, &conn);
683 err = obd_disconnect(&conn, 0);
687 case OBD_IOC_NO_TRANSNO: {
688 if (!obd->obd_attached) {
689 CERROR("Device %d not attached\n", obd->obd_minor);
690 GOTO(out, err = -ENODEV);
693 "disabling committed-transno notifications on %d\n",
695 obd->obd_no_transno = 1;
699 case OBD_IOC_CLOSE_UUID: {
700 struct lustre_peer peer;
701 CDEBUG(D_IOCTL, "closing all connections to uuid %s\n",
703 lustre_uuid_to_peer(data->ioc_inlbuf1, &peer);
706 case OBD_IOC_ADD_UUID: {
707 CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid "LPX64
708 ", nal %d\n", data->ioc_inlbuf1, data->ioc_nid,
711 err = class_add_uuid(data->ioc_inlbuf1, data->ioc_nid,
715 case OBD_IOC_DEL_UUID: {
716 CDEBUG(D_IOCTL, "removing mappings for uuid %s\n",
717 data->ioc_inlbuf1 == NULL ? "<all uuids>" :
720 err = class_del_uuid(data->ioc_inlbuf1);
724 // obd_data2conn(&conn, data);
725 struct obd_class_user_conn *oconn = list_entry(ocus->ocus_conns.next, struct obd_class_user_conn, ocuc_chain);
726 err = obd_iocontrol(cmd, &oconn->ocuc_conn, len, data, NULL);
730 err = copy_to_user((void *)arg, data, len);
739 obd_ioctl_freedata(buf, len);
743 } /* class_handle_ioctl */
747 #define OBD_MINOR 241
749 /* to control /dev/obd */
750 static int obd_class_ioctl(struct inode *inode, struct file *filp,
751 unsigned int cmd, unsigned long arg)
753 return class_handle_ioctl(filp->private_data, cmd, arg);
756 /* declare character device */
757 static struct file_operations obd_psdev_fops = {
758 ioctl: obd_class_ioctl, /* ioctl */
759 open: obd_class_open, /* open */
760 release: obd_class_release, /* release */
764 static struct miscdevice obd_psdev = {
770 void *obd_psdev = NULL;
773 EXPORT_SYMBOL(obd_dev);
774 EXPORT_SYMBOL(obdo_cachep);
775 EXPORT_SYMBOL(obd_memory);
776 EXPORT_SYMBOL(obd_memmax);
777 EXPORT_SYMBOL(obd_fail_loc);
778 EXPORT_SYMBOL(obd_timeout);
779 EXPORT_SYMBOL(obd_lustre_upcall);
780 EXPORT_SYMBOL(obd_sync_filter);
781 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
782 EXPORT_SYMBOL(ptlrpc_abort_inflight_superhack);
783 EXPORT_SYMBOL(proc_lustre_root);
785 EXPORT_SYMBOL(lctl_fake_uuid);
787 EXPORT_SYMBOL(class_register_type);
788 EXPORT_SYMBOL(class_unregister_type);
789 EXPORT_SYMBOL(class_get_type);
790 EXPORT_SYMBOL(class_put_type);
791 EXPORT_SYMBOL(class_name2dev);
792 EXPORT_SYMBOL(class_name2obd);
793 EXPORT_SYMBOL(class_uuid2dev);
794 EXPORT_SYMBOL(class_uuid2obd);
795 EXPORT_SYMBOL(class_export_get);
796 EXPORT_SYMBOL(class_export_put);
797 EXPORT_SYMBOL(class_new_export);
798 EXPORT_SYMBOL(class_unlink_export);
799 EXPORT_SYMBOL(class_import_get);
800 EXPORT_SYMBOL(class_import_put);
801 EXPORT_SYMBOL(class_new_import);
802 EXPORT_SYMBOL(class_destroy_import);
803 EXPORT_SYMBOL(class_connect);
804 EXPORT_SYMBOL(class_conn2export);
805 EXPORT_SYMBOL(class_conn2obd);
806 EXPORT_SYMBOL(class_conn2cliimp);
807 EXPORT_SYMBOL(class_conn2ldlmimp);
808 EXPORT_SYMBOL(class_disconnect);
809 EXPORT_SYMBOL(class_disconnect_exports);
810 EXPORT_SYMBOL(lustre_uuid_to_peer);
813 EXPORT_SYMBOL(class_uuid_unparse);
814 EXPORT_SYMBOL(client_tgtuuid2obd);
816 EXPORT_SYMBOL(class_handle_hash);
817 EXPORT_SYMBOL(class_handle_unhash);
818 EXPORT_SYMBOL(class_handle2object);
821 static int __init init_obdclass(void)
823 int init_obdclass(void)
826 struct obd_device *obd;
830 printk(KERN_INFO "OBD class driver Build Version: " BUILD_VERSION
831 ", info@clusterfs.com\n");
833 class_init_uuidlist();
836 sema_init(&obd_conf_sem, 1);
837 INIT_LIST_HEAD(&obd_types);
839 if ((err = misc_register(&obd_psdev))) {
840 CERROR("cannot register %d err %d\n", OBD_MINOR, err);
844 /* This struct is already zerod for us (static global) */
845 for (i = 0, obd = obd_dev; i < MAX_OBD_DEVICES; i++, obd++)
848 err = obd_init_caches();
857 proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
858 if (!proc_lustre_root)
859 printk(KERN_ERR "error registering /proc/fs/lustre\n");
860 proc_version = lprocfs_add_vars(proc_lustre_root,lprocfs_version,NULL);
862 proc_lustre_root = NULL;
869 int obd_proc_read_version(char *page, char **start, off_t off, int count, int *eof, void *data) {
871 return snprintf(page, count, "%s\n", BUILD_VERSION);
874 int obd_proc_read_version(char *page, char **start, off_t off, int count, int *eof, void *data) { return 0; }
878 static void __exit cleanup_obdclass(void)
880 static void cleanup_obdclass(void)
886 misc_deregister(&obd_psdev);
887 for (i = 0; i < MAX_OBD_DEVICES; i++) {
888 struct obd_device *obd = &obd_dev[i];
889 if (obd->obd_type && obd->obd_set_up &&
890 OBT(obd) && OBP(obd, detach)) {
891 /* XXX should this call generic detach otherwise? */
892 OBP(obd, detach)(obd);
896 obd_cleanup_caches();
900 if (proc_lustre_root) {
901 lprocfs_remove(proc_lustre_root);
902 proc_lustre_root = NULL;
905 class_handle_cleanup();
906 class_exit_uuidlist();
908 CERROR("obd mem max: %d leaked: %d\n", obd_memmax,
909 atomic_read(&obd_memory));
913 /* Check that we're building against the appropriate version of the Lustre
916 #include <linux/lustre_version.h>
917 #define LUSTRE_MIN_VERSION 18
918 #define LUSTRE_MAX_VERSION 19
919 #if (LUSTRE_KERNEL_VERSION < LUSTRE_MIN_VERSION)
920 # error Cannot continue: Your Lustre kernel patch is older than the sources
921 #elif (LUSTRE_KERNEL_VERSION > LUSTRE_MAX_VERSION)
922 # error Cannot continue: Your Lustre sources are older than the kernel patch
925 # warning "Lib Lustre - no versioning information"
929 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
930 MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
931 MODULE_LICENSE("GPL");
933 module_init(init_obdclass);
934 module_exit(cleanup_obdclass);