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>
56 # include <liblustre.h>
60 #include <linux/obd_support.h>
61 #include <linux/obd_class.h>
62 #include <linux/lustre_debug.h>
63 #include <linux/smp_lock.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;
77 /* The following are visible and mutable through /proc/sys/lustre/. */
78 unsigned long obd_fail_loc;
79 unsigned long obd_timeout = 100;
80 char obd_recovery_upcall[128] = "/usr/lib/lustre/ha_assist";
81 unsigned long obd_sync_filter; /* = 0, don't sync by default */
83 /* opening /dev/obd */
84 static int obd_class_open(struct inode * inode, struct file * file)
86 struct obd_class_user_state *ocus;
89 OBD_ALLOC (ocus, sizeof (*ocus));
93 INIT_LIST_HEAD (&ocus->ocus_conns);
94 ocus->ocus_current_obd = NULL;
95 file->private_data = ocus;
102 obd_class_add_user_conn (struct obd_class_user_state *ocus,
103 struct lustre_handle *conn)
105 struct obd_class_user_conn *c;
107 /* NB holding obd_conf_sem */
109 OBD_ALLOC (c, sizeof (*c));
113 c->ocuc_conn = *conn;
114 list_add (&c->ocuc_chain, &ocus->ocus_conns);
119 obd_class_remove_user_conn (struct obd_class_user_state *ocus,
120 struct lustre_handle *conn)
123 struct obd_class_user_conn *c;
125 /* NB holding obd_conf_sem or last reference */
127 list_for_each (e, &ocus->ocus_conns) {
128 c = list_entry (e, struct obd_class_user_conn, ocuc_chain);
129 if (!memcmp (conn, &c->ocuc_conn, sizeof (*conn))) {
130 list_del (&c->ocuc_chain);
131 OBD_FREE (c, sizeof (*c));
137 /* closing /dev/obd */
138 static int obd_class_release(struct inode * inode, struct file * file)
140 struct obd_class_user_state *ocus = file->private_data;
141 struct obd_class_user_conn *c;
144 while (!list_empty (&ocus->ocus_conns)) {
145 c = list_entry (ocus->ocus_conns.next,
146 struct obd_class_user_conn, ocuc_chain);
147 list_del (&c->ocuc_chain);
149 CDEBUG (D_IOCTL, "Auto-disconnect %p\n", &c->ocuc_conn);
151 down (&obd_conf_sem);
152 obd_disconnect (&c->ocuc_conn);
155 OBD_FREE (c, sizeof (*c));
158 OBD_FREE (ocus, sizeof (*ocus));
164 static inline void obd_data2conn(struct lustre_handle *conn,
165 struct obd_ioctl_data *data)
167 conn->addr = data->ioc_addr;
168 conn->cookie = data->ioc_cookie;
171 static inline void obd_conn2data(struct obd_ioctl_data *data,
172 struct lustre_handle *conn)
174 data->ioc_addr = conn->addr;
175 data->ioc_cookie = conn->cookie;
178 static void forcibly_detach_exports(struct obd_device *obd)
181 struct list_head *tmp, *n;
182 struct lustre_handle fake_conn;
184 CDEBUG(D_IOCTL, "OBD device %d (%p) has exports, "
185 "disconnecting them", obd->obd_minor, obd);
186 list_for_each_safe(tmp, n, &obd->obd_exports) {
187 struct obd_export *exp = list_entry(tmp, struct obd_export,
189 fake_conn.addr = (__u64)(unsigned long)exp;
190 fake_conn.cookie = exp->exp_cookie;
191 rc = obd_disconnect(&fake_conn);
193 CDEBUG(D_IOCTL, "disconnecting export %p failed: %d\n",
196 CDEBUG(D_IOCTL, "export %p disconnected\n", exp);
202 int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd,
206 struct obd_ioctl_data *data;
207 struct obd_device *obd = ocus->ocus_current_obd;
208 struct lustre_handle conn;
209 int err = 0, len = 0, serialised = 0;
213 case OBD_IOC_BRW_WRITE:
214 case OBD_IOC_BRW_READ:
215 case OBD_IOC_GETATTR:
216 case ECHO_IOC_ENQUEUE:
217 case ECHO_IOC_CANCEL:
225 if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS &&
226 cmd != OBD_IOC_LIST && cmd != OBD_GET_VERSION &&
227 cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_NEWDEV &&
228 cmd != OBD_IOC_ADD_UUID && cmd != OBD_IOC_DEL_UUID &&
229 cmd != OBD_IOC_CLOSE_UUID) {
230 CERROR("OBD ioctl: No device\n");
231 GOTO(out, err = -EINVAL);
233 if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
234 CERROR("OBD ioctl: data error\n");
235 GOTO(out, err = -EINVAL);
237 data = (struct obd_ioctl_data *)buf;
241 GOTO(out, err=-EINVAL);
242 case OBD_IOC_DEVICE: {
243 CDEBUG(D_IOCTL, "\n");
244 if (data->ioc_dev >= MAX_OBD_DEVICES || data->ioc_dev < 0) {
245 CERROR("OBD ioctl: DEVICE insufficient devices\n");
246 GOTO(out, err=-EINVAL);
248 CDEBUG(D_IOCTL, "device %d\n", data->ioc_dev);
250 ocus->ocus_current_obd = &obd_dev[data->ioc_dev];
256 char *buf2 = data->ioc_bulk;
257 int remains = data->ioc_inllen1;
259 if (!data->ioc_inlbuf1) {
260 CERROR("No buffer passed!\n");
261 GOTO(out, err=-EINVAL);
265 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
268 struct obd_device *obd = &obd_dev[i];
271 if (obd->obd_flags & OBD_SET_UP)
273 else if (obd->obd_flags & OBD_ATTACHED)
277 l = snprintf(buf2, remains, "%2d %s %s %s %s %d\n",
278 i, status, obd->obd_type->typ_name,
279 obd->obd_name, obd->obd_uuid.uuid,
280 obd->obd_type->typ_refcnt);
284 CERROR("not enough space for device listing\n");
289 err = copy_to_user((void *)arg, data, len);
295 case OBD_GET_VERSION:
296 if (!data->ioc_inlbuf1) {
297 CERROR("No buffer passed in ioctl\n");
298 GOTO(out, err = -EINVAL);
301 if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
302 CERROR("ioctl buffer too small to hold version\n");
303 GOTO(out, err = -EINVAL);
306 memcpy(data->ioc_bulk, BUILD_VERSION,
307 strlen(BUILD_VERSION) + 1);
309 err = copy_to_user((void *)arg, data, len);
314 case OBD_IOC_NAME2DEV: {
315 /* Resolve a device name. This does not change the
316 * currently selected device.
320 if (!data->ioc_inllen1 || !data->ioc_inlbuf1 ) {
321 CERROR("No name passed,!\n");
322 GOTO(out, err=-EINVAL);
324 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
325 CERROR("Name not nul terminated!\n");
326 GOTO(out, err=-EINVAL);
329 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
330 dev = class_name2dev(data->ioc_inlbuf1);
333 CDEBUG(D_IOCTL, "No device for name %s!\n",
335 GOTO(out, err=-EINVAL);
338 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
340 err = copy_to_user((void *)arg, data, sizeof(*data));
346 case OBD_IOC_UUID2DEV: {
347 /* Resolve a device uuid. This does not change the
348 * currently selected device.
351 struct obd_uuid uuid;
353 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
354 CERROR("No UUID passed!\n");
355 GOTO(out, err=-EINVAL);
357 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
358 CERROR("Name not nul terminated!\n");
359 GOTO(out, err=-EINVAL);
362 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
363 obd_str2uuid(&uuid, data->ioc_inlbuf1);
364 dev = class_uuid2dev(&uuid);
367 CDEBUG(D_IOCTL, "No device for name %s!\n",
369 GOTO(out, err=-EINVAL);
372 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
374 err = copy_to_user((void *)arg, data, sizeof(*data));
380 case OBD_IOC_NEWDEV: {
384 ocus->ocus_current_obd = NULL;
385 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
386 struct obd_device *obd = &obd_dev[i];
387 if (!obd->obd_type) {
388 ocus->ocus_current_obd = obd;
397 GOTO(out, err=-EINVAL);
399 err = copy_to_user((void *)arg, data, sizeof(*data));
405 case OBD_IOC_ATTACH: {
406 struct obd_type *type;
409 /* have we attached a type to this device */
410 if (obd->obd_flags & OBD_ATTACHED || obd->obd_type) {
411 CERROR("OBD: Device %d already typed as %s.\n",
412 obd->obd_minor, MKSTR(obd->obd_type->typ_name));
413 GOTO(out, err = -EBUSY);
416 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
417 CERROR("No type passed!\n");
418 GOTO(out, err = -EINVAL);
420 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
421 CERROR("Type not nul terminated!\n");
422 GOTO(out, err = -EINVAL);
424 if (!data->ioc_inllen2 || !data->ioc_inlbuf2) {
425 CERROR("No name passed!\n");
426 GOTO(out, err = -EINVAL);
428 CDEBUG(D_IOCTL, "attach type %s name: %s uuid: %s\n",
429 MKSTR(data->ioc_inlbuf1),
430 MKSTR(data->ioc_inlbuf2), MKSTR(data->ioc_inlbuf3));
433 type = class_get_type(data->ioc_inlbuf1);
435 CERROR("OBD: unknown type dev %d\n", obd->obd_minor);
436 GOTO(out, err = -EINVAL);
439 minor = obd->obd_minor;
440 memset(obd, 0, sizeof(*obd));
441 obd->obd_minor = minor;
442 obd->obd_type = type;
443 INIT_LIST_HEAD(&obd->obd_exports);
444 INIT_LIST_HEAD(&obd->obd_imports);
445 spin_lock_init(&obd->obd_dev_lock);
447 /* XXX belong ins setup not attach */
449 spin_lock_init(&obd->obd_processing_task_lock);
450 init_waitqueue_head(&obd->obd_next_transno_waitq);
451 INIT_LIST_HEAD(&obd->obd_recovery_queue);
452 INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
454 len = strlen(data->ioc_inlbuf2) + 1;
455 OBD_ALLOC(obd->obd_name, len);
456 if (!obd->obd_name) {
457 class_put_type(obd->obd_type);
458 obd->obd_type = NULL;
459 GOTO(out, err = -ENOMEM);
461 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
463 if (data->ioc_inlbuf3) {
464 int len = strlen(data->ioc_inlbuf3);
465 if (len >= sizeof(obd->obd_uuid)) {
466 CERROR("uuid must be < "LPSZ" bytes long\n",
467 sizeof(obd->obd_uuid));
469 OBD_FREE(obd->obd_name,
470 strlen(obd->obd_name) + 1);
471 class_put_type(obd->obd_type);
472 obd->obd_type = NULL;
473 GOTO(out, err=-EINVAL);
475 memcpy(obd->obd_uuid.uuid, data->ioc_inlbuf3, len);
478 if (OBP(obd, attach))
479 err = OBP(obd,attach)(obd, sizeof(*data), data);
481 if(data->ioc_inlbuf2)
482 OBD_FREE(obd->obd_name,
483 strlen(obd->obd_name) + 1);
484 class_put_type(obd->obd_type);
485 obd->obd_type = NULL;
487 obd->obd_flags |= OBD_ATTACHED;
490 CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
491 obd->obd_minor, data->ioc_inlbuf1);
497 case OBD_IOC_DETACH: {
499 if (obd->obd_flags & OBD_SET_UP) {
500 CERROR("OBD device %d still set up\n", obd->obd_minor);
501 GOTO(out, err=-EBUSY);
503 if (!(obd->obd_flags & OBD_ATTACHED) ) {
504 CERROR("OBD device %d not attached\n", obd->obd_minor);
505 GOTO(out, err=-ENODEV);
507 if (OBP(obd, detach))
508 err = OBP(obd,detach)(obd);
511 OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
512 obd->obd_name = NULL;
515 obd->obd_flags &= ~OBD_ATTACHED;
516 obd->obd_type->typ_refcnt--;
517 class_put_type(obd->obd_type);
518 obd->obd_type = NULL;
522 case OBD_IOC_SETUP: {
523 /* have we attached a type to this device? */
524 if (!(obd->obd_flags & OBD_ATTACHED)) {
525 CERROR("Device %d not attached\n", obd->obd_minor);
526 GOTO(out, err=-ENODEV);
529 /* has this been done already? */
530 if ( obd->obd_flags & OBD_SET_UP ) {
531 CERROR("Device %d already setup (type %s)\n",
532 obd->obd_minor, obd->obd_type->typ_name);
533 GOTO(out, err=-EBUSY);
536 if ( OBT(obd) && OBP(obd, setup) )
537 err = obd_setup(obd, sizeof(*data), data);
540 obd->obd_type->typ_refcnt++;
541 obd->obd_flags |= OBD_SET_UP;
546 case OBD_IOC_CLEANUP: {
547 /* have we attached a type to this device? */
548 if (!(obd->obd_flags & OBD_ATTACHED)) {
549 CERROR("Device %d not attached\n", obd->obd_minor);
550 GOTO(out, err=-ENODEV);
552 if (!list_empty(&obd->obd_exports)) {
553 if (!data->ioc_inlbuf1 || data->ioc_inlbuf1[0] != 'F') {
554 CERROR("OBD device %d (%p) has exports\n",
555 obd->obd_minor, obd);
556 GOTO(out, err = -EBUSY);
558 forcibly_detach_exports(obd);
560 if (OBT(obd) && OBP(obd, cleanup))
561 err = obd_cleanup(obd);
564 obd->obd_flags &= ~OBD_SET_UP;
565 obd->obd_type->typ_refcnt--;
570 case OBD_IOC_CONNECT: {
571 struct obd_uuid cluuid = { "OBD_CLASS_UUID" };
572 obd_data2conn(&conn, data);
574 err = obd_connect(&conn, obd, &cluuid, NULL, NULL);
576 CDEBUG(D_IOCTL, "assigned export "LPX64"\n", conn.addr);
577 obd_conn2data(data, &conn);
581 err = obd_class_add_user_conn (ocus, &conn);
583 obd_disconnect (&conn);
587 err = copy_to_user((void *)arg, data, sizeof(*data));
589 obd_class_remove_user_conn (ocus, &conn);
590 obd_disconnect (&conn);
591 GOTO (out, err=-EFAULT);
596 case OBD_IOC_DISCONNECT: {
597 obd_data2conn(&conn, data);
598 obd_class_remove_user_conn (ocus, &conn);
599 err = obd_disconnect(&conn);
603 case OBD_IOC_NO_TRANSNO: {
604 if (!(obd->obd_flags & OBD_ATTACHED)) {
605 CERROR("Device %d not attached\n", obd->obd_minor);
606 GOTO(out, err=-ENODEV);
609 "disabling committed-transno notifications on %d\n",
611 obd->obd_flags |= OBD_NO_TRANSNO;
615 case OBD_IOC_CLOSE_UUID: {
616 struct lustre_peer peer;
617 CDEBUG(D_IOCTL, "closing all connections to uuid %s\n",
619 lustre_uuid_to_peer(data->ioc_inlbuf1, &peer);
622 case OBD_IOC_ADD_UUID: {
623 CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid "LPX64
624 ", nal %d\n", data->ioc_inlbuf1, data->ioc_nid,
627 err = class_add_uuid(data->ioc_inlbuf1, data->ioc_nid,
631 case OBD_IOC_DEL_UUID: {
632 CDEBUG(D_IOCTL, "removing mappings for uuid %s\n",
633 data->ioc_inlbuf1 == NULL ? "<all uuids>" :
636 err = class_del_uuid(data->ioc_inlbuf1);
640 // obd_data2conn(&conn, data);
641 struct obd_class_user_conn *oconn = list_entry(ocus->ocus_conns.next, struct obd_class_user_conn, ocuc_chain);
642 err = obd_iocontrol(cmd, &oconn->ocuc_conn, len, data, NULL);
646 err = copy_to_user((void *)arg, data, len);
659 } /* obd_class_ioctl */
663 #define OBD_MINOR 241
665 /* to control /dev/obd */
666 static int obd_class_ioctl (struct inode * inode, struct file * filp,
667 unsigned int cmd, unsigned long arg)
669 return class_handle_ioctl(filp->private_data, cmd, arg);
672 /* declare character device */
673 static struct file_operations obd_psdev_fops = {
674 ioctl: obd_class_ioctl, /* ioctl */
675 open: obd_class_open, /* open */
676 release: obd_class_release, /* release */
680 static struct miscdevice obd_psdev = {
686 void *obd_psdev = NULL;
689 void (*class_signal_connection_failure)(struct ptlrpc_connection *);
691 #ifdef CONFIG_HIGHMEM
692 /* Allow at most 3/4 of the kmap mappings to be consumed by vector I/O
693 * requests. This avoids deadlocks on servers which have a lot of clients
694 * doing vector I/O. We don't need to do this for non-vector I/O requests
695 * because singleton requests will just block on the kmap itself and never
696 * deadlock waiting for additional kmaps to complete.
698 * If we are a "server" task, we can have at most a single reservation
699 * in excess of the maximum. This avoids a deadlock when multiple client
700 * threads are on the same machine as the server threads, and the clients
701 * have consumed all of the available mappings. As long as a single server
702 * thread is can make progress, we are guaranteed to avoid deadlock.
704 #define OBD_KMAP_MAX (LAST_PKMAP * 3 / 4)
705 static atomic_t obd_kmap_count = ATOMIC_INIT(OBD_KMAP_MAX);
706 static DECLARE_WAIT_QUEUE_HEAD(obd_kmap_waitq);
708 void obd_kmap_get(int count, int server)
710 //CERROR("getting %d kmap counts (%d/%d)\n", count,
711 // atomic_read(&obd_kmap_count), OBD_KMAP_MAX);
713 atomic_dec(&obd_kmap_count);
714 else while (atomic_add_negative(-count, &obd_kmap_count)) {
715 static long next_show = 0;
716 static int skipped = 0;
718 if (server && atomic_read(&obd_kmap_count) >= -PTL_MD_MAX_IOV)
721 CDEBUG(D_OTHER, "negative kmap reserved count: %d\n",
722 atomic_read(&obd_kmap_count));
723 atomic_add(count, &obd_kmap_count);
725 if (time_after(jiffies, next_show)) {
726 CERROR("blocking %s (and %d others) for kmaps\n",
727 current->comm, skipped);
728 next_show = jiffies + 5*HZ;
732 wait_event(obd_kmap_waitq,
733 atomic_read(&obd_kmap_count) >= count);
737 void obd_kmap_put(int count)
739 atomic_add(count, &obd_kmap_count);
740 /* Wake up sleepers. Sadly, this wakes up all of the tasks at once.
741 * We could have something smarter here like:
742 while (atomic_read(&obd_kmap_count) > 0)
743 wake_up_nr(obd_kmap_waitq, 1);
744 although we would need to set somewhere (probably obd_class_init):
745 obd_kmap_waitq.flags |= WQ_FLAG_EXCLUSIVE;
746 For now the wait_event() condition will handle this OK I believe.
748 if (atomic_read(&obd_kmap_count) > 0)
749 wake_up(&obd_kmap_waitq);
752 EXPORT_SYMBOL(obd_kmap_get);
753 EXPORT_SYMBOL(obd_kmap_put);
756 EXPORT_SYMBOL(obd_dev);
757 EXPORT_SYMBOL(obdo_cachep);
758 EXPORT_SYMBOL(obd_memory);
759 EXPORT_SYMBOL(obd_memmax);
760 EXPORT_SYMBOL(obd_fail_loc);
761 EXPORT_SYMBOL(obd_timeout);
762 EXPORT_SYMBOL(obd_recovery_upcall);
763 EXPORT_SYMBOL(obd_sync_filter);
764 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
765 EXPORT_SYMBOL(ptlrpc_abort_inflight_superhack);
766 EXPORT_SYMBOL(proc_lustre_root);
768 EXPORT_SYMBOL(class_register_type);
769 EXPORT_SYMBOL(class_unregister_type);
770 EXPORT_SYMBOL(class_get_type);
771 EXPORT_SYMBOL(class_put_type);
772 EXPORT_SYMBOL(class_name2dev);
773 EXPORT_SYMBOL(class_uuid2dev);
774 EXPORT_SYMBOL(class_uuid2obd);
775 EXPORT_SYMBOL(class_new_export);
776 EXPORT_SYMBOL(class_destroy_export);
777 EXPORT_SYMBOL(class_connect);
778 EXPORT_SYMBOL(class_conn2export);
779 EXPORT_SYMBOL(class_conn2obd);
780 EXPORT_SYMBOL(class_conn2cliimp);
781 EXPORT_SYMBOL(class_conn2ldlmimp);
782 EXPORT_SYMBOL(class_disconnect);
783 EXPORT_SYMBOL(class_disconnect_all);
784 EXPORT_SYMBOL(class_uuid_unparse);
785 EXPORT_SYMBOL(lustre_uuid_to_peer);
787 EXPORT_SYMBOL(class_signal_connection_failure);
789 EXPORT_SYMBOL(class_handle_hash);
790 EXPORT_SYMBOL(class_handle_unhash);
791 EXPORT_SYMBOL(class_handle2object);
794 static int __init init_obdclass(void)
796 int init_obdclass(void)
799 struct obd_device *obd;
803 printk(KERN_INFO "OBD class driver Build Version: " BUILD_VERSION
804 ", info@clusterfs.com\n");
806 class_init_uuidlist();
809 sema_init(&obd_conf_sem, 1);
810 INIT_LIST_HEAD(&obd_types);
812 if ((err = misc_register(&obd_psdev))) {
813 CERROR("cannot register %d err %d\n", OBD_MINOR, err);
817 /* This struct is already zerod for us (static global) */
818 for (i = 0, obd = obd_dev; i < MAX_OBD_DEVICES; i++, obd++)
821 err = obd_init_caches();
830 proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
831 if (!proc_lustre_root)
832 printk(KERN_ERR "error registering /proc/fs/lustre\n");
834 proc_lustre_root = NULL;
840 static void __exit cleanup_obdclass(void)
842 static void cleanup_obdclass(void)
848 misc_deregister(&obd_psdev);
849 for (i = 0; i < MAX_OBD_DEVICES; i++) {
850 struct obd_device *obd = &obd_dev[i];
851 if (obd->obd_type && (obd->obd_flags & OBD_SET_UP) &&
852 OBT(obd) && OBP(obd, detach)) {
853 /* XXX should this call generic detach otherwise? */
854 OBP(obd, detach)(obd);
858 obd_cleanup_caches();
862 if (proc_lustre_root) {
863 lprocfs_remove(proc_lustre_root);
864 proc_lustre_root = NULL;
867 class_handle_cleanup();
868 class_exit_uuidlist();
870 CERROR("obd mem max: %d leaked: %d\n", obd_memmax,
871 atomic_read(&obd_memory));
875 /* Check that we're building against the appropriate version of the Lustre
878 #include <linux/lustre_version.h>
879 #define LUSTRE_SOURCE_VERSION 13
880 #if (LUSTRE_KERNEL_VERSION < LUSTRE_SOURCE_VERSION)
881 # error Cannot continue: Your Lustre kernel patch is older than the sources
882 #elif (LUSTRE_KERNEL_VERSION > LUSTRE_SOURCE_VERSION)
883 # error Cannot continue: Your Lustre sources are older than the kernel patch
886 #warning "Lib Lustre - no versioning information"
890 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
891 MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
892 MODULE_LICENSE("GPL");
894 module_init(init_obdclass);
895 module_exit(cleanup_obdclass);