1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * These are the only exported functions, they provide some generic
10 * infrastructure for managing object devices
12 * Object Devices Class Driver
16 #include <linux/config.h> /* for CONFIG_PROC_FS */
17 #include <linux/module.h>
18 #include <linux/errno.h>
19 #include <linux/kernel.h>
20 #include <linux/major.h>
21 #include <linux/sched.h>
23 #include <linux/slab.h>
24 #include <linux/ioport.h>
25 #include <linux/fcntl.h>
26 #include <linux/delay.h>
27 #include <linux/skbuff.h>
28 #include <linux/proc_fs.h>
30 #include <linux/poll.h>
31 #include <linux/init.h>
32 #include <linux/list.h>
34 #include <asm/system.h>
36 #include <asm/uaccess.h>
37 #include <linux/miscdevice.h>
39 #define DEBUG_SUBSYSTEM S_CLASS
41 #include <linux/obd_support.h>
42 #include <linux/obd_class.h>
43 #include <linux/lustre_debug.h>
44 #include <linux/smp_lock.h>
45 #include <linux/lprocfs.h>
47 struct semaphore obd_conf_sem; /* serialize configuration commands */
48 struct obd_device obd_dev[MAX_OBD_DEVICES];
49 struct list_head obd_types;
50 unsigned long obd_memory;
52 /* The following are visible and mutable through /proc/sys/lustre/. */
53 unsigned long obd_fail_loc;
54 unsigned long obd_timeout = 100;
55 char obd_recovery_upcall[128] = "/usr/lib/lustre/ha_assist";
57 extern struct obd_type *class_nm_to_type(char *nm);
60 * LProcFS specific data structures. These define the namespace for
61 * the various device classes. We will need to distribute these
62 * later, to individual modules (e.g. MDS, MDC etc)
68 * Common OBD namespace for lprocFS (these are used very often)
71 char* obd_dir_namespace_1[]= {
80 lprocfs_vars_t obd_var_namespace_1[]= {
82 {"num_ops", lprocfs_longlong_read, lprocfs_longlong_write},
83 {"min_time", lprocfs_longlong_read, lprocfs_longlong_write},
84 {"max_time", lprocfs_longlong_read, lprocfs_longlong_write},
85 {"sum_time", lprocfs_longlong_read, lprocfs_longlong_write},
91 * MDC Spcific namespace for lprocFS
94 char* mdc_dir_namespace_1[]= {
110 * Create the MDC groupings
113 lprocfs_group_t lprocfs_mdc_namespace[]= {
115 {obd_dir_namespace_1, obd_var_namespace_1, e_generic},
116 {mdc_dir_namespace_1, obd_var_namespace_1, e_generic},
121 * MDS Device Groupings
124 char* mds_dir_namespace_1[]={
127 "disconnect_callback",
147 char* mds_dir_namespace_2[]={
154 lprocfs_vars_t mds_var_namespace_2[]={
155 {"f_type", read_other, write_other},
156 {"f_bsize",read_other, write_other},
157 {"f_blocks",read_other, write_other},
158 {"f_bfree",read_other, write_other},
159 {"f_bavail",read_other, write_other},
160 {"uuid",read_string, write_string},
165 lprocfs_group_t lprocfs_mds_namespace[]={
166 {obd_dir_namespace_1, obd_var_namespace_1, e_generic},
167 {mds_dir_namespace_1, obd_var_namespace_1, e_generic},
168 {mds_dir_namespace_2, mds_var_namespace_2, e_specific},
176 char* osc_dir_namespace_1[]={
190 lprocfs_group_t lprocfs_osc_namespace[]={
191 {obd_dir_namespace_1, obd_var_namespace_1, e_generic},
192 {osc_dir_namespace_1, obd_var_namespace_1, e_generic},
198 * OST, LOV, OBD_FILTER namespace
199 * Note: These namespaces are exactly similar to the osc_dir_namespace
200 * Hence, I use the osc namespace as the base class and add only
201 * those attributes that are missing in osc_dir_namespace.
204 char* ost_lov_obdfilter_dir_namespace_1[]={
209 char* ost_lov_obdfilter_dir_namespace_2[]={
214 lprocfs_vars_t ost_lov_obdfilter_var_namespace_2[]={
215 {"f_type", read_other, write_other},
216 {"f_bsize",read_other, write_other},
217 {"f_blocks",read_other, write_other},
218 {"f_bfree",read_other, write_other},
219 {"f_bavail",read_other, write_other},
220 {"f_objects", read_other, write_other},
221 {"f_ofree", read_other, write_other},
222 {"f_objectgroups", read_other, write_other},
223 {"f_uuid", read_string, write_string},
228 lprocfs_group_t lprocfs_ost_lov_obdfilter_namespace[]={
229 {obd_dir_namespace_1, obd_var_namespace_1, e_generic},
230 {osc_dir_namespace_1, obd_var_namespace_1, e_generic},
231 {ost_lov_obdfilter_dir_namespace_1, obd_var_namespace_1, e_generic},
232 {ost_lov_obdfilter_dir_namespace_2, ost_lov_obdfilter_var_namespace_2, e_specific},
237 * LDLM Device namespace
241 char* ldlm_dir_namespace_1[]={
251 lprocfs_vars_t ldlm_var_namespace_1[]= {
253 {"num_total", lprocfs_longlong_read, lprocfs_longlong_write},
254 {"num_zerolatency", lprocfs_longlong_read, lprocfs_longlong_write},
255 {"num_zerolatency_inflight", lprocfs_longlong_read, lprocfs_longlong_write},
256 {"num_zerolatency_done", lprocfs_longlong_read, lprocfs_longlong_write},
257 {"nonzero_mintime", lprocfs_longlong_read, lprocfs_longlong_write},
258 {"nonzero_maxtime", lprocfs_longlong_read, lprocfs_longlong_write},
259 {"nonzero_sumtime", lprocfs_longlong_read, lprocfs_longlong_write},
264 lprocfs_group_t lprocfs_ldlm_namespace[]={
265 {obd_dir_namespace_1, obd_var_namespace_1, e_generic},
266 {ldlm_dir_namespace_1, ldlm_var_namespace_1, e_generic},
271 * Note: Need to add namespace for breaking out locks by device class
277 char* ptlrpc_dir_namespace_1[]={
282 lprocfs_vars_t ptlrpc_var_namespace_1[]={
283 {"msgs_alloc", lprocfs_longlong_read, lprocfs_longlong_write},
284 {"msgs_max", lprocfs_longlong_read, lprocfs_longlong_write},
285 {"recv_count", lprocfs_longlong_read, lprocfs_longlong_write},
286 {"recv_length", lprocfs_longlong_read, lprocfs_longlong_write},
287 {"send_count", lprocfs_longlong_read, lprocfs_longlong_write},
288 {"send_length", lprocfs_longlong_read, lprocfs_longlong_write},
289 {"portal_kmemory", lprocfs_longlong_read, lprocfs_longlong_write},
292 char* ptlrpc_dir_namespace_2[] = {
297 lprocfs_vars_t ptlrpc_var_namespace_2[] = {
298 {"type", read_string, write_string},
299 {"mtu", lprocfs_longlong_read, lprocfs_longlong_write},
300 {"rxpackets", lprocfs_longlong_read, lprocfs_longlong_write},
301 {"txpackets", lprocfs_longlong_read, lprocfs_longlong_write},
302 {"txbytes", lprocfs_longlong_read, lprocfs_longlong_write},
306 lprocfs_group_t lprocfs_ptlrpc_namespace[]={
307 {obd_dir_namespace_1, obd_var_namespace_1, e_generic},
308 {ptlrpc_dir_namespace_1, ptlrpc_var_namespace_1, e_generic},
309 {ptlrpc_dir_namespace_2, ptlrpc_var_namespace_2, e_specific},
315 * Building the entire device namespace. This will be used during attach and
316 * detach to associate the namespace with the class of the device
319 lprocfs_obd_namespace_t obd_namespace[]={
320 {"mdc", lprocfs_mdc_namespace, sizeof(struct lprocfs_profiler_gen)},
321 {"mds", lprocfs_mds_namespace, sizeof(struct lprocfs_profiler_gen)},
322 {"osc", lprocfs_osc_namespace, sizeof(struct lprocfs_profiler_gen)},
323 {"ost", lprocfs_ost_lov_obdfilter_namespace, sizeof(struct lprocfs_profiler_gen)},
324 {"lov", lprocfs_ost_lov_obdfilter_namespace, sizeof(struct lprocfs_profiler_gen)},
325 {"obdfilter", lprocfs_ost_lov_obdfilter_namespace, sizeof(struct lprocfs_profiler_gen)},
326 {"ldlm", lprocfs_ldlm_namespace, sizeof(struct lprocfs_profiler_ldlm)},
327 {"ptlrpc", lprocfs_ptlrpc_namespace, sizeof(struct lprocfs_profiler_ptlrpc)},
334 lprocfs_obd_namespace_t* obd_namespace=0;
340 /* opening /dev/obd */
341 static int obd_class_open(struct inode * inode, struct file * file)
345 file->private_data = NULL;
350 /* closing /dev/obd */
351 static int obd_class_release(struct inode * inode, struct file * file)
355 if (file->private_data)
356 file->private_data = NULL;
363 inline void obd_data2conn(struct lustre_handle *conn, struct obd_ioctl_data *data)
365 conn->addr = data->ioc_addr;
366 conn->cookie = data->ioc_cookie;
370 inline void obd_conn2data(struct obd_ioctl_data *data, struct lustre_handle *conn)
372 data->ioc_addr = conn->addr;
373 data->ioc_cookie = conn->cookie;
377 /* to control /dev/obd */
378 static int obd_class_ioctl (struct inode * inode, struct file * filp,
379 unsigned int cmd, unsigned long arg)
383 struct obd_ioctl_data *data;
384 struct obd_device *obd = filp->private_data;
386 struct lustre_handle conn;
387 int rw = OBD_BRW_READ;
390 int obd_lprocfs_index = 0;
395 case OBD_IOC_BRW_WRITE:
396 case OBD_IOC_BRW_READ:
397 case OBD_IOC_GETATTR:
405 if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS &&
406 cmd != OBD_IOC_LIST &&
407 cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_NEWDEV) {
408 CERROR("OBD ioctl: No device\n");
409 GOTO(out, err=-EINVAL);
411 if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
412 CERROR("OBD ioctl: data error\n");
413 GOTO(out, err=-EINVAL);
415 data = (struct obd_ioctl_data *)buf;
419 GOTO(out, err=-EINVAL);
420 case OBD_IOC_DEVICE: {
421 CDEBUG(D_IOCTL, "\n");
422 if (data->ioc_dev >= MAX_OBD_DEVICES || data->ioc_dev < 0) {
423 CERROR("OBD ioctl: DEVICE insufficient devices\n");
424 GOTO(out, err=-EINVAL);
426 CDEBUG(D_IOCTL, "device %d\n", data->ioc_dev);
428 filp->private_data = &obd_dev[data->ioc_dev];
434 char *buf2 = data->ioc_bulk;
435 int remains = data->ioc_inllen1;
437 if (!data->ioc_inlbuf1) {
438 CERROR("No buffer passed!\n");
439 GOTO(out, err=-EINVAL);
443 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
446 struct obd_device *obd = &obd_dev[i];
449 if (obd->obd_flags & OBD_SET_UP)
451 else if (obd->obd_flags & OBD_ATTACHED)
455 l = snprintf(buf2, remains, "%2d %s %s %s %s %d\n",
456 i, status, obd->obd_type->typ_name,
457 obd->obd_name, obd->obd_uuid, obd->obd_type->typ_refcnt);
461 CERROR("not enough space for device listing\n");
466 err = copy_to_user((int *)arg, data, len);
471 case OBD_IOC_NAME2DEV: {
472 /* Resolve a device name. This does not change the
473 * currently selected device.
477 if (!data->ioc_inllen1 || !data->ioc_inlbuf1 ) {
478 CERROR("No name passed,!\n");
479 GOTO(out, err=-EINVAL);
481 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
482 CERROR("Name not nul terminated!\n");
483 GOTO(out, err=-EINVAL);
486 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
487 dev = class_name2dev(data->ioc_inlbuf1);
490 CDEBUG(D_IOCTL, "No device for name %s!\n",
492 GOTO(out, err=-EINVAL);
495 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
497 err = copy_to_user((int *)arg, data, sizeof(*data));
501 case OBD_IOC_UUID2DEV: {
502 /* Resolve a device uuid. This does not change the
503 * currently selected device.
507 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
508 CERROR("No UUID passed!\n");
509 GOTO(out, err=-EINVAL);
511 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
512 CERROR("Name not nul terminated!\n");
513 GOTO(out, err=-EINVAL);
516 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
517 dev = class_uuid2dev(data->ioc_inlbuf1);
520 CDEBUG(D_IOCTL, "No device for name %s!\n",
522 GOTO(out, err=-EINVAL);
525 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
527 err = copy_to_user((int *)arg, data, sizeof(*data));
531 case OBD_IOC_NEWDEV: {
535 filp->private_data = NULL;
536 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
537 struct obd_device *obd = &obd_dev[i];
538 if (!obd->obd_type) {
539 filp->private_data = obd;
548 GOTO(out, err=-EINVAL);
550 err = copy_to_user((int *)arg, data, sizeof(*data));
554 case OBD_IOC_ATTACH: {
555 struct obd_type *type;
558 /* have we attached a type to this device */
559 if (obd->obd_flags & OBD_ATTACHED || obd->obd_type) {
560 CERROR("OBD: Device %d already typed as %s.\n",
561 obd->obd_minor, MKSTR(obd->obd_type->typ_name));
562 GOTO(out, err=-EBUSY);
565 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
566 CERROR("No type passed!\n");
567 GOTO(out, err=-EINVAL);
569 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
570 CERROR("Type not nul terminated!\n");
571 GOTO(out, err=-EINVAL);
574 CDEBUG(D_IOCTL, "attach type %s name: %s uuid: %s\n",
575 MKSTR(data->ioc_inlbuf1),
576 MKSTR(data->ioc_inlbuf2), MKSTR(data->ioc_inlbuf3));
579 type = class_nm_to_type(data->ioc_inlbuf1);
581 CERROR("OBD: unknown type dev %d\n", obd->obd_minor);
582 GOTO(out, err=-EINVAL);
585 minor = obd->obd_minor;
586 memset(obd, 0, sizeof(*obd));
587 obd->obd_minor = minor;
588 obd->obd_type = type;
589 INIT_LIST_HEAD(&obd->obd_exports);
590 INIT_LIST_HEAD(&obd->obd_imports);
591 spin_lock_init(&obd->obd_dev_lock);
594 if (OBP(obd, attach))
595 err = OBP(obd,attach)(obd, sizeof(*data), data);
597 obd->obd_type = NULL;
599 obd->obd_flags |= OBD_ATTACHED;
602 CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
603 obd->obd_minor, data->ioc_inlbuf1);
604 if (data->ioc_inlbuf2) {
605 int len = strlen(data->ioc_inlbuf2) + 1;
606 OBD_ALLOC(obd->obd_name, len);
607 if (!obd->obd_name) {
608 CERROR("no memory\n");
611 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
612 /* obd->obd_proc_entry =
613 proc_lustre_register_obd_device(obd);
617 CERROR("WARNING: unnamed obd device\n");
618 obd->obd_proc_entry = NULL;
621 if (data->ioc_inlbuf3) {
622 int len = strlen(data->ioc_inlbuf3);
623 if (len >= sizeof(obd->obd_uuid)) {
624 CERROR("uuid must be < %d bytes long\n",
625 sizeof(obd->obd_uuid));
627 OBD_FREE(obd->obd_name,
628 strlen(obd->obd_name) + 1);
629 GOTO(out, err=-EINVAL);
631 memcpy(obd->obd_uuid, data->ioc_inlbuf3, len);
635 * Get the LprocFS namespace for this device class
638 obd_lprocfs_index=lprocfs_get_namespace(data->ioc_inlbuf1, \
641 if(obd_lprocfs_index<0) {
642 CERROR("Non-existent device class or proc/lustre not compiled \n");
645 lprocfs_register_dev(obd, \
646 obd_namespace[obd_lprocfs_index].obd_namespace, \
647 obd_namespace[obd_lprocfs_index].cntr_blk_size);
656 case OBD_IOC_DETACH: {
658 if (obd->obd_flags & OBD_SET_UP) {
659 CERROR("OBD device %d still set up\n", obd->obd_minor);
660 GOTO(out, err=-EBUSY);
662 if (!(obd->obd_flags & OBD_ATTACHED) ) {
663 CERROR("OBD device %d not attached\n", obd->obd_minor);
664 GOTO(out, err=-ENODEV);
666 #warning FIXME: Mike, we probably need some sort of "force detach" here
667 if (!list_empty(&obd->obd_exports) ) {
668 CERROR("OBD device %d (%p) has exports\n",
669 obd->obd_minor, obd);
670 GOTO(out, err=-EBUSY);
673 if(lprocfs_deregister_dev(obd)!=LPROCFS_SUCCESS){
674 CERROR("Could not remove Proc Entry\n");
675 GOTO(out, err=-ENODEV);
680 OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
681 obd->obd_name = NULL;
684 if (obd->obd_proc_entry)
685 proc_lustre_release_obd_device(obd);
687 obd->obd_flags &= ~OBD_ATTACHED;
689 obd->obd_type->typ_refcnt--;
690 obd->obd_type = NULL;
695 case OBD_IOC_SETUP: {
696 /* have we attached a type to this device? */
697 if (!(obd->obd_flags & OBD_ATTACHED)) {
698 CERROR("Device %d not attached\n", obd->obd_minor);
699 GOTO(out, err=-ENODEV);
702 /* has this been done already? */
703 if ( obd->obd_flags & OBD_SET_UP ) {
704 CERROR("Device %d already setup (type %s)\n",
705 obd->obd_minor, obd->obd_type->typ_name);
706 GOTO(out, err=-EBUSY);
709 if ( OBT(obd) && OBP(obd, setup) )
710 err = obd_setup(obd, sizeof(*data), data);
713 obd->obd_type->typ_refcnt++;
714 obd->obd_flags |= OBD_SET_UP;
719 case OBD_IOC_CLEANUP: {
720 /* have we attached a type to this device? */
721 if (!(obd->obd_flags & OBD_ATTACHED)) {
722 CERROR("Device %d not attached\n", obd->obd_minor);
723 GOTO(out, err=-ENODEV);
726 if ( OBT(obd) && OBP(obd, cleanup) )
727 err = obd_cleanup(obd);
730 obd->obd_flags &= ~OBD_SET_UP;
731 obd->obd_type->typ_refcnt--;
736 case OBD_IOC_CONNECT: {
737 char * cluuid = "OBD_CLASS_UUID";
738 obd_data2conn(&conn, data);
740 err = obd_connect(&conn, obd, cluuid);
742 CDEBUG(D_IOCTL, "assigned export %Lx\n", conn.addr);
743 obd_conn2data(data, &conn);
747 err = copy_to_user((int *)arg, data, sizeof(*data));
751 case OBD_IOC_DISCONNECT: {
752 obd_data2conn(&conn, data);
753 err = obd_disconnect(&conn);
757 case OBD_IOC_DEC_USE_COUNT: {
762 case OBD_IOC_CREATE: {
763 struct lov_stripe_md *ea;
764 obd_data2conn(&conn, data);
767 err = obd_create(&conn, &data->ioc_obdo1, &ea);
771 err = copy_to_user((int *)arg, data, sizeof(*data));
775 case OBD_IOC_GETATTR: {
777 obd_data2conn(&conn, data);
778 err = obd_getattr(&conn, &data->ioc_obdo1, NULL);
782 err = copy_to_user((int *)arg, data, sizeof(*data));
786 case OBD_IOC_SETATTR: {
787 obd_data2conn(&conn, data);
788 err = obd_setattr(&conn, &data->ioc_obdo1, NULL);
792 err = copy_to_user((int *)arg, data, sizeof(*data));
796 case OBD_IOC_DESTROY: {
798 obd_data2conn(&conn, data);
800 err = obd_destroy(&conn, &data->ioc_obdo1, NULL);
804 err = copy_to_user((int *)arg, data, sizeof(*data));
808 case OBD_IOC_BRW_WRITE:
810 case OBD_IOC_BRW_READ: {
811 struct lov_stripe_md smd;
812 struct io_cb_data *cbd = ll_init_cb();
814 struct brw_page *pga, *pgp;
815 __u64 id = data->ioc_obdo1.o_id;
816 int gfp_mask = (id & 1) ? GFP_HIGHUSER : GFP_KERNEL;
817 int verify = (id != 0);
822 GOTO(out, err = -ENOMEM);
824 obd_data2conn(&conn, data);
826 pages = data->ioc_count / PAGE_SIZE;
828 CDEBUG(D_INODE, "BRW %s with %d pages\n",
829 rw == OBD_BRW_READ ? "read" : "write", pages);
830 OBD_ALLOC(pga, pages * sizeof(*pga));
832 CERROR("no memory for %d BRW per-page data\n", pages);
833 GOTO(brw_free, err = -ENOMEM);
836 memset(&smd, 0, sizeof(smd));
837 smd.lmd_object_id = id;
839 off = data->ioc_offset;
841 for (j = 0, pgp = pga; j < pages; j++, off += PAGE_SIZE, pgp++){
842 pgp->pg = alloc_pages(gfp_mask, 0);
844 CERROR("no memory for brw pages\n");
845 GOTO(brw_cleanup, err = -ENOMEM);
847 pgp->count = PAGE_SIZE;
852 void *addr = kmap(pgp->pg);
854 if (rw == OBD_BRW_WRITE)
855 page_debug_setup(addr, pgp->count,
858 page_debug_setup(addr, pgp->count,
865 err = obd_brw(rw, &conn, &smd, j, pga, ll_sync_io_cb, cbd);
867 CERROR("test_brw: error from obd_brw: err = %d\n", err);
870 for (j = 0, pgp = pga; j < pages; j++, pgp++) {
871 if (pgp->pg != NULL) {
872 if (verify && !err) {
873 void *addr = kmap(pgp->pg);
875 err = page_debug_check("test_brw",
881 __free_pages(pgp->pg, 0);
885 OBD_FREE(pga, pages * sizeof(*pga));
889 obd_data2conn(&conn, data);
892 err = obd_iocontrol(cmd, &conn, len, data, NULL);
896 err = copy_to_user((int *)arg, data, len);
906 } /* obd_class_ioctl */
910 /* declare character device */
911 static struct file_operations obd_psdev_fops = {
912 ioctl: obd_class_ioctl, /* ioctl */
913 open: obd_class_open, /* open */
914 release: obd_class_release, /* release */
918 #define OBD_MINOR 241
919 static struct miscdevice obd_psdev = {
925 void (*class_signal_connection_failure)(struct ptlrpc_connection *);
926 int (*mds_destroy_export)(struct obd_export *exp);
927 int (*ldlm_destroy_export)(struct obd_export *exp);
929 EXPORT_SYMBOL(obd_dev);
930 EXPORT_SYMBOL(obdo_cachep);
931 EXPORT_SYMBOL(obd_memory);
932 EXPORT_SYMBOL(obd_fail_loc);
933 EXPORT_SYMBOL(obd_timeout);
934 EXPORT_SYMBOL(obd_recovery_upcall);
936 EXPORT_SYMBOL(class_register_type);
937 EXPORT_SYMBOL(class_unregister_type);
938 EXPORT_SYMBOL(class_name2dev);
939 EXPORT_SYMBOL(class_uuid2dev);
940 EXPORT_SYMBOL(class_uuid2obd);
941 EXPORT_SYMBOL(class_new_export);
942 EXPORT_SYMBOL(class_destroy_export);
943 EXPORT_SYMBOL(class_connect);
944 EXPORT_SYMBOL(class_conn2export);
945 EXPORT_SYMBOL(class_conn2obd);
946 EXPORT_SYMBOL(class_conn2cliimp);
947 EXPORT_SYMBOL(class_conn2ldlmimp);
948 EXPORT_SYMBOL(class_disconnect);
949 EXPORT_SYMBOL(class_disconnect_all);
950 //EXPORT_SYMBOL(class_uuid_parse);
951 EXPORT_SYMBOL(class_uuid_unparse);
952 //EXPORT_SYMBOL(class_multi_setup);
953 //EXPORT_SYMBOL(class_multi_cleanup);
955 EXPORT_SYMBOL(class_signal_connection_failure);
956 EXPORT_SYMBOL(mds_destroy_export);
957 EXPORT_SYMBOL(ldlm_destroy_export);
958 EXPORT_SYMBOL(ll_sync_io_cb);
959 EXPORT_SYMBOL(ll_init_cb);
961 static int __init init_obdclass(void)
963 struct obd_device *obd;
967 printk(KERN_INFO "OBD class driver v0.9, info@clusterfs.com\n");
969 sema_init(&obd_conf_sem, 1);
970 INIT_LIST_HEAD(&obd_types);
972 if ((err = misc_register(&obd_psdev))) {
973 CERROR("cannot register %d err %d\n", OBD_MINOR, err);
977 /* This struct is already zerod for us (static global) */
978 for (i = 0, obd = obd_dev; i < MAX_OBD_DEVICES; i++, obd++)
981 err = obd_init_caches();
988 static void __exit cleanup_obdclass(void)
993 misc_deregister(&obd_psdev);
994 for (i = 0; i < MAX_OBD_DEVICES; i++) {
995 struct obd_device *obd = &obd_dev[i];
996 if (obd->obd_type && (obd->obd_flags & OBD_SET_UP) &&
997 OBT(obd) && OBP(obd, detach)) {
998 /* XXX should this call generic detach otherwise? */
999 OBP(obd, detach)(obd);
1003 obd_cleanup_caches();
1005 CERROR("obd memory leaked: %ld bytes\n", obd_memory);
1009 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1010 MODULE_DESCRIPTION("Lustre Class Driver v1.0");
1011 MODULE_LICENSE("GPL");
1013 module_init(init_obdclass);
1014 module_exit(cleanup_obdclass);