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 file->private_data = ocus;
101 obd_class_add_user_conn (struct obd_class_user_state *ocus,
102 struct lustre_handle *conn)
104 struct obd_class_user_conn *c;
106 /* NB holding obd_conf_sem */
108 OBD_ALLOC (c, sizeof (*c));
112 c->ocuc_conn = *conn;
113 list_add (&c->ocuc_chain, &ocus->ocus_conns);
118 obd_class_remove_user_conn (struct obd_class_user_state *ocus,
119 struct lustre_handle *conn)
122 struct obd_class_user_conn *c;
124 /* NB holding obd_conf_sem or last reference */
126 list_for_each (e, &ocus->ocus_conns) {
127 c = list_entry (e, struct obd_class_user_conn, ocuc_chain);
128 if (!memcmp (conn, &c->ocuc_conn, sizeof (*conn))) {
129 list_del (&c->ocuc_chain);
130 OBD_FREE (c, sizeof (*c));
136 /* closing /dev/obd */
137 static int obd_class_release(struct inode * inode, struct file * file)
139 struct obd_class_user_state *ocus = file->private_data;
140 struct obd_class_user_conn *c;
143 while (!list_empty (&ocus->ocus_conns)) {
144 c = list_entry (ocus->ocus_conns.next,
145 struct obd_class_user_conn, ocuc_chain);
146 list_del (&c->ocuc_chain);
148 CDEBUG (D_IOCTL, "Auto-disconnect %p\n", &c->ocuc_conn);
150 down (&obd_conf_sem);
151 obd_disconnect (&c->ocuc_conn);
154 OBD_FREE (c, sizeof (*c));
157 OBD_FREE (ocus, sizeof (*ocus));
163 static inline void obd_data2conn(struct lustre_handle *conn,
164 struct obd_ioctl_data *data)
166 conn->addr = data->ioc_addr;
167 conn->cookie = data->ioc_cookie;
170 static inline void obd_conn2data(struct obd_ioctl_data *data,
171 struct lustre_handle *conn)
173 data->ioc_addr = conn->addr;
174 data->ioc_cookie = conn->cookie;
177 static void forcibly_detach_exports(struct obd_device *obd)
180 struct list_head *tmp, *n;
181 struct lustre_handle fake_conn;
183 CDEBUG(D_IOCTL, "OBD device %d (%p) has exports, "
184 "disconnecting them", obd->obd_minor, obd);
185 list_for_each_safe(tmp, n, &obd->obd_exports) {
186 struct obd_export *exp = list_entry(tmp, struct obd_export,
188 fake_conn.addr = (__u64)(unsigned long)exp;
189 fake_conn.cookie = exp->exp_cookie;
190 rc = obd_disconnect(&fake_conn);
192 CDEBUG(D_IOCTL, "disconnecting export %p failed: %d\n",
195 CDEBUG(D_IOCTL, "export %p disconnected\n", exp);
201 int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd,
205 struct obd_ioctl_data *data;
206 struct obd_device *obd = ocus->ocus_current_obd;
207 struct lustre_handle conn;
208 int err = 0, len = 0, serialised = 0;
211 if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
212 RETURN(err = -ENOTTY);
215 case OBD_IOC_BRW_WRITE:
216 case OBD_IOC_BRW_READ:
217 case OBD_IOC_GETATTR:
218 case ECHO_IOC_ENQUEUE:
219 case ECHO_IOC_CANCEL:
227 CDEBUG(D_IOCTL, "cmd = %x, obd = %p\n", cmd, obd);
228 if (!obd && cmd != OBD_IOC_DEVICE &&
229 cmd != OBD_IOC_LIST && cmd != OBD_GET_VERSION &&
230 cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_NEWDEV &&
231 cmd != OBD_IOC_ADD_UUID && cmd != OBD_IOC_DEL_UUID &&
232 cmd != OBD_IOC_CLOSE_UUID) {
233 CERROR("OBD ioctl: No device\n");
234 GOTO(out, err = -EINVAL);
236 if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
237 CERROR("OBD ioctl: data error\n");
238 GOTO(out, err = -EINVAL);
240 data = (struct obd_ioctl_data *)buf;
243 case OBD_IOC_DEVICE: {
244 CDEBUG(D_IOCTL, "\n");
245 if (data->ioc_dev >= MAX_OBD_DEVICES || data->ioc_dev < 0) {
246 CERROR("OBD ioctl: DEVICE insufficient devices\n");
247 GOTO(out, err=-EINVAL);
249 CDEBUG(D_IOCTL, "device %d\n", data->ioc_dev);
251 ocus->ocus_current_obd = &obd_dev[data->ioc_dev];
257 char *buf2 = data->ioc_bulk;
258 int remains = data->ioc_inllen1;
260 if (!data->ioc_inlbuf1) {
261 CERROR("No buffer passed!\n");
262 GOTO(out, err=-EINVAL);
266 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
269 struct obd_device *obd = &obd_dev[i];
273 if (obd->obd_flags & OBD_SET_UP)
275 else if (obd->obd_flags & OBD_ATTACHED)
279 l = snprintf(buf2, remains, "%2d %s %s %s %s %d\n",
280 i, status, obd->obd_type->typ_name,
281 obd->obd_name, obd->obd_uuid.uuid,
282 obd->obd_type->typ_refcnt);
286 CERROR("not enough space for device listing\n");
291 err = copy_to_user((void *)arg, data, len);
297 case OBD_GET_VERSION:
298 if (!data->ioc_inlbuf1) {
299 CERROR("No buffer passed in ioctl\n");
300 GOTO(out, err = -EINVAL);
303 if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
304 CERROR("ioctl buffer too small to hold version\n");
305 GOTO(out, err = -EINVAL);
308 memcpy(data->ioc_bulk, BUILD_VERSION,
309 strlen(BUILD_VERSION) + 1);
311 err = copy_to_user((void *)arg, data, len);
316 case OBD_IOC_NAME2DEV: {
317 /* Resolve a device name. This does not change the
318 * currently selected device.
322 if (!data->ioc_inllen1 || !data->ioc_inlbuf1 ) {
323 CERROR("No name passed,!\n");
324 GOTO(out, err=-EINVAL);
326 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
327 CERROR("Name not nul terminated!\n");
328 GOTO(out, err=-EINVAL);
331 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
332 dev = class_name2dev(data->ioc_inlbuf1);
335 CDEBUG(D_IOCTL, "No device for name %s!\n",
337 GOTO(out, err=-EINVAL);
340 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
342 err = copy_to_user((void *)arg, data, sizeof(*data));
348 case OBD_IOC_UUID2DEV: {
349 /* Resolve a device uuid. This does not change the
350 * currently selected device.
353 struct obd_uuid uuid;
355 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
356 CERROR("No UUID passed!\n");
357 GOTO(out, err=-EINVAL);
359 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
360 CERROR("Name not nul terminated!\n");
361 GOTO(out, err=-EINVAL);
364 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
365 obd_str2uuid(&uuid, data->ioc_inlbuf1);
366 dev = class_uuid2dev(&uuid);
369 CDEBUG(D_IOCTL, "No device for name %s!\n",
371 GOTO(out, err=-EINVAL);
374 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
376 err = copy_to_user((void *)arg, data, sizeof(*data));
382 case OBD_IOC_NEWDEV: {
386 ocus->ocus_current_obd = NULL;
387 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
388 struct obd_device *obd = &obd_dev[i];
389 if (!obd->obd_type) {
390 ocus->ocus_current_obd = obd;
399 GOTO(out, err=-EINVAL);
401 err = copy_to_user((void *)arg, data, sizeof(*data));
407 case OBD_IOC_ATTACH: {
408 struct obd_type *type;
411 /* have we attached a type to this device */
412 if (obd->obd_flags & OBD_ATTACHED || obd->obd_type) {
413 CERROR("OBD: Device %d already typed as %s.\n",
414 obd->obd_minor, MKSTR(obd->obd_type->typ_name));
415 GOTO(out, err = -EBUSY);
418 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
419 CERROR("No type passed!\n");
420 GOTO(out, err = -EINVAL);
422 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
423 CERROR("Type not nul terminated!\n");
424 GOTO(out, err = -EINVAL);
426 if (!data->ioc_inllen2 || !data->ioc_inlbuf2) {
427 CERROR("No name passed!\n");
428 GOTO(out, err = -EINVAL);
430 CDEBUG(D_IOCTL, "attach type %s name: %s uuid: %s\n",
431 MKSTR(data->ioc_inlbuf1),
432 MKSTR(data->ioc_inlbuf2), MKSTR(data->ioc_inlbuf3));
435 type = class_get_type(data->ioc_inlbuf1);
437 CERROR("OBD: unknown type dev %d\n", obd->obd_minor);
438 GOTO(out, err = -EINVAL);
441 minor = obd->obd_minor;
442 memset(obd, 0, sizeof(*obd));
443 obd->obd_minor = minor;
444 obd->obd_type = type;
445 INIT_LIST_HEAD(&obd->obd_exports);
446 INIT_LIST_HEAD(&obd->obd_imports);
447 spin_lock_init(&obd->obd_dev_lock);
449 /* XXX belong ins setup not attach */
451 spin_lock_init(&obd->obd_processing_task_lock);
452 init_waitqueue_head(&obd->obd_next_transno_waitq);
453 INIT_LIST_HEAD(&obd->obd_recovery_queue);
454 INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
456 len = strlen(data->ioc_inlbuf2) + 1;
457 OBD_ALLOC(obd->obd_name, len);
458 if (!obd->obd_name) {
459 class_put_type(obd->obd_type);
460 obd->obd_type = NULL;
461 GOTO(out, err = -ENOMEM);
463 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
465 if (data->ioc_inlbuf3) {
466 int len = strlen(data->ioc_inlbuf3);
467 if (len >= sizeof(obd->obd_uuid)) {
468 CERROR("uuid must be < "LPSZ" bytes long\n",
469 sizeof(obd->obd_uuid));
471 OBD_FREE(obd->obd_name,
472 strlen(obd->obd_name) + 1);
473 class_put_type(obd->obd_type);
474 obd->obd_type = NULL;
475 GOTO(out, err=-EINVAL);
477 memcpy(obd->obd_uuid.uuid, data->ioc_inlbuf3, len);
480 if (OBP(obd, attach))
481 err = OBP(obd,attach)(obd, sizeof(*data), data);
483 if(data->ioc_inlbuf2)
484 OBD_FREE(obd->obd_name,
485 strlen(obd->obd_name) + 1);
486 class_put_type(obd->obd_type);
487 obd->obd_type = NULL;
489 obd->obd_flags |= OBD_ATTACHED;
492 CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
493 obd->obd_minor, data->ioc_inlbuf1);
499 case OBD_IOC_DETACH: {
501 if (obd->obd_flags & OBD_SET_UP) {
502 CERROR("OBD device %d still set up\n", obd->obd_minor);
503 GOTO(out, err=-EBUSY);
505 if (!(obd->obd_flags & OBD_ATTACHED) ) {
506 CERROR("OBD device %d not attached\n", obd->obd_minor);
507 GOTO(out, err=-ENODEV);
509 if (OBP(obd, detach))
510 err = OBP(obd,detach)(obd);
513 OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
514 obd->obd_name = NULL;
517 obd->obd_flags &= ~OBD_ATTACHED;
518 obd->obd_type->typ_refcnt--;
519 class_put_type(obd->obd_type);
520 obd->obd_type = NULL;
524 case OBD_IOC_SETUP: {
525 /* have we attached a type to this device? */
526 if (!(obd->obd_flags & OBD_ATTACHED)) {
527 CERROR("Device %d not attached\n", obd->obd_minor);
528 GOTO(out, err=-ENODEV);
531 /* has this been done already? */
532 if ( obd->obd_flags & OBD_SET_UP ) {
533 CERROR("Device %d already setup (type %s)\n",
534 obd->obd_minor, obd->obd_type->typ_name);
535 GOTO(out, err=-EBUSY);
538 if ( OBT(obd) && OBP(obd, setup) )
539 err = obd_setup(obd, sizeof(*data), data);
542 obd->obd_type->typ_refcnt++;
543 obd->obd_flags |= OBD_SET_UP;
548 case OBD_IOC_CLEANUP: {
549 /* have we attached a type to this device? */
550 if (!(obd->obd_flags & OBD_ATTACHED)) {
551 CERROR("Device %d not attached\n", obd->obd_minor);
552 GOTO(out, err=-ENODEV);
554 if (!list_empty(&obd->obd_exports)) {
555 if (!data->ioc_inlbuf1 || data->ioc_inlbuf1[0] != 'F') {
556 CERROR("OBD device %d (%p) has exports\n",
557 obd->obd_minor, obd);
558 GOTO(out, err = -EBUSY);
560 forcibly_detach_exports(obd);
562 if (OBT(obd) && OBP(obd, cleanup))
563 err = obd_cleanup(obd);
566 obd->obd_flags &= ~OBD_SET_UP;
567 obd->obd_type->typ_refcnt--;
572 case OBD_IOC_CONNECT: {
573 struct obd_uuid cluuid = { "OBD_CLASS_UUID" };
574 obd_data2conn(&conn, data);
576 err = obd_connect(&conn, obd, &cluuid, NULL, NULL);
578 CDEBUG(D_IOCTL, "assigned export "LPX64"\n", conn.addr);
579 obd_conn2data(data, &conn);
583 err = obd_class_add_user_conn (ocus, &conn);
585 obd_disconnect (&conn);
589 err = copy_to_user((void *)arg, data, sizeof(*data));
591 obd_class_remove_user_conn (ocus, &conn);
592 obd_disconnect (&conn);
593 GOTO (out, err=-EFAULT);
598 case OBD_IOC_DISCONNECT: {
599 obd_data2conn(&conn, data);
600 obd_class_remove_user_conn (ocus, &conn);
601 err = obd_disconnect(&conn);
605 case OBD_IOC_NO_TRANSNO: {
606 if (!(obd->obd_flags & OBD_ATTACHED)) {
607 CERROR("Device %d not attached\n", obd->obd_minor);
608 GOTO(out, err=-ENODEV);
611 "disabling committed-transno notifications on %d\n",
613 obd->obd_flags |= OBD_NO_TRANSNO;
617 case OBD_IOC_CLOSE_UUID: {
618 struct lustre_peer peer;
619 CDEBUG(D_IOCTL, "closing all connections to uuid %s\n",
621 lustre_uuid_to_peer(data->ioc_inlbuf1, &peer);
624 case OBD_IOC_ADD_UUID: {
625 CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid "LPX64
626 ", nal %d\n", data->ioc_inlbuf1, data->ioc_nid,
629 err = class_add_uuid(data->ioc_inlbuf1, data->ioc_nid,
633 case OBD_IOC_DEL_UUID: {
634 CDEBUG(D_IOCTL, "removing mappings for uuid %s\n",
635 data->ioc_inlbuf1 == NULL ? "<all uuids>" :
638 err = class_del_uuid(data->ioc_inlbuf1);
642 // obd_data2conn(&conn, data);
643 struct obd_class_user_conn *oconn = list_entry(ocus->ocus_conns.next, struct obd_class_user_conn, ocuc_chain);
644 err = obd_iocontrol(cmd, &oconn->ocuc_conn, len, data, NULL);
648 err = copy_to_user((void *)arg, data, len);
661 } /* obd_class_ioctl */
665 #define OBD_MINOR 241
667 /* to control /dev/obd */
668 static int obd_class_ioctl(struct inode *inode, struct file *filp,
669 unsigned int cmd, unsigned long arg)
671 return class_handle_ioctl(filp->private_data, cmd, arg);
674 /* declare character device */
675 static struct file_operations obd_psdev_fops = {
676 ioctl: obd_class_ioctl, /* ioctl */
677 open: obd_class_open, /* open */
678 release: obd_class_release, /* release */
682 static struct miscdevice obd_psdev = {
688 void *obd_psdev = NULL;
691 void (*class_signal_connection_failure)(struct ptlrpc_connection *);
693 #ifdef CONFIG_HIGHMEM
694 /* Allow at most 3/4 of the kmap mappings to be consumed by vector I/O
695 * requests. This avoids deadlocks on servers which have a lot of clients
696 * doing vector I/O. We don't need to do this for non-vector I/O requests
697 * because singleton requests will just block on the kmap itself and never
698 * deadlock waiting for additional kmaps to complete.
700 * If we are a "server" task, we can have at most a single reservation
701 * in excess of the maximum. This avoids a deadlock when multiple client
702 * threads are on the same machine as the server threads, and the clients
703 * have consumed all of the available mappings. As long as a single server
704 * thread is can make progress, we are guaranteed to avoid deadlock.
706 #define OBD_KMAP_MAX (LAST_PKMAP * 3 / 4)
707 static atomic_t obd_kmap_count = ATOMIC_INIT(OBD_KMAP_MAX);
708 static DECLARE_WAIT_QUEUE_HEAD(obd_kmap_waitq);
710 void obd_kmap_get(int count, int server)
712 //CERROR("getting %d kmap counts (%d/%d)\n", count,
713 // atomic_read(&obd_kmap_count), OBD_KMAP_MAX);
715 atomic_dec(&obd_kmap_count);
716 else while (atomic_add_negative(-count, &obd_kmap_count)) {
717 struct l_wait_info lwi = { 0 };
718 static long next_show = 0;
719 static int skipped = 0;
721 if (server && atomic_read(&obd_kmap_count) >= -PTL_MD_MAX_IOV)
724 CDEBUG(D_OTHER, "negative kmap reserved count: %d\n",
725 atomic_read(&obd_kmap_count));
726 atomic_add(count, &obd_kmap_count);
728 if (time_after(jiffies, next_show)) {
729 CERROR("blocking %s (and %d others) for kmaps\n",
730 current->comm, skipped);
731 next_show = jiffies + 5*HZ;
735 l_wait_event(obd_kmap_waitq,
736 atomic_read(&obd_kmap_count) >= count, &lwi);
740 void obd_kmap_put(int count)
742 atomic_add(count, &obd_kmap_count);
743 /* Wake up sleepers. Sadly, this wakes up all of the tasks at once.
744 * We could have something smarter here like:
745 while (atomic_read(&obd_kmap_count) > 0)
746 wake_up_nr(obd_kmap_waitq, 1);
747 although we would need to set somewhere (probably obd_class_init):
748 obd_kmap_waitq.flags |= WQ_FLAG_EXCLUSIVE;
749 For now the wait_event() condition will handle this OK I believe.
751 if (atomic_read(&obd_kmap_count) > 0)
752 wake_up(&obd_kmap_waitq);
755 EXPORT_SYMBOL(obd_kmap_get);
756 EXPORT_SYMBOL(obd_kmap_put);
759 EXPORT_SYMBOL(obd_dev);
760 EXPORT_SYMBOL(obdo_cachep);
761 EXPORT_SYMBOL(obd_memory);
762 EXPORT_SYMBOL(obd_memmax);
763 EXPORT_SYMBOL(obd_fail_loc);
764 EXPORT_SYMBOL(obd_timeout);
765 EXPORT_SYMBOL(obd_recovery_upcall);
766 EXPORT_SYMBOL(obd_sync_filter);
767 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
768 EXPORT_SYMBOL(ptlrpc_abort_inflight_superhack);
769 EXPORT_SYMBOL(proc_lustre_root);
771 EXPORT_SYMBOL(class_register_type);
772 EXPORT_SYMBOL(class_unregister_type);
773 EXPORT_SYMBOL(class_get_type);
774 EXPORT_SYMBOL(class_put_type);
775 EXPORT_SYMBOL(class_name2dev);
776 EXPORT_SYMBOL(class_uuid2dev);
777 EXPORT_SYMBOL(class_uuid2obd);
778 EXPORT_SYMBOL(class_new_export);
779 EXPORT_SYMBOL(class_destroy_export);
780 EXPORT_SYMBOL(class_connect);
781 EXPORT_SYMBOL(class_conn2export);
782 EXPORT_SYMBOL(class_conn2obd);
783 EXPORT_SYMBOL(class_conn2cliimp);
784 EXPORT_SYMBOL(class_conn2ldlmimp);
785 EXPORT_SYMBOL(class_disconnect);
786 EXPORT_SYMBOL(class_disconnect_all);
787 EXPORT_SYMBOL(class_uuid_unparse);
788 EXPORT_SYMBOL(lustre_uuid_to_peer);
790 EXPORT_SYMBOL(class_signal_connection_failure);
792 EXPORT_SYMBOL(class_handle_hash);
793 EXPORT_SYMBOL(class_handle_unhash);
794 EXPORT_SYMBOL(class_handle2object);
797 static int __init init_obdclass(void)
799 int init_obdclass(void)
802 struct obd_device *obd;
806 printk(KERN_INFO "OBD class driver Build Version: " BUILD_VERSION
807 ", info@clusterfs.com\n");
809 class_init_uuidlist();
812 sema_init(&obd_conf_sem, 1);
813 INIT_LIST_HEAD(&obd_types);
815 if ((err = misc_register(&obd_psdev))) {
816 CERROR("cannot register %d err %d\n", OBD_MINOR, err);
820 /* This struct is already zerod for us (static global) */
821 for (i = 0, obd = obd_dev; i < MAX_OBD_DEVICES; i++, obd++)
824 err = obd_init_caches();
833 proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
834 if (!proc_lustre_root)
835 printk(KERN_ERR "error registering /proc/fs/lustre\n");
837 proc_lustre_root = NULL;
843 static void __exit cleanup_obdclass(void)
845 static void cleanup_obdclass(void)
851 misc_deregister(&obd_psdev);
852 for (i = 0; i < MAX_OBD_DEVICES; i++) {
853 struct obd_device *obd = &obd_dev[i];
854 if (obd->obd_type && (obd->obd_flags & OBD_SET_UP) &&
855 OBT(obd) && OBP(obd, detach)) {
856 /* XXX should this call generic detach otherwise? */
857 OBP(obd, detach)(obd);
861 obd_cleanup_caches();
865 if (proc_lustre_root) {
866 lprocfs_remove(proc_lustre_root);
867 proc_lustre_root = NULL;
870 class_handle_cleanup();
871 class_exit_uuidlist();
873 CERROR("obd mem max: %d leaked: %d\n", obd_memmax,
874 atomic_read(&obd_memory));
878 /* Check that we're building against the appropriate version of the Lustre
881 #include <linux/lustre_version.h>
882 #define LUSTRE_SOURCE_VERSION 13
883 #if (LUSTRE_KERNEL_VERSION < LUSTRE_SOURCE_VERSION)
884 # error Cannot continue: Your Lustre kernel patch is older than the sources
885 #elif (LUSTRE_KERNEL_VERSION > LUSTRE_SOURCE_VERSION)
886 # error Cannot continue: Your Lustre sources are older than the kernel patch
889 #warning "Lib Lustre - no versioning information"
893 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
894 MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
895 MODULE_LICENSE("GPL");
897 module_init(init_obdclass);
898 module_exit(cleanup_obdclass);