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);
59 * LProcFS specific data structures. These define the namespace for
60 * the various device classes. We will need to distribute these
61 * later, to individual modules (e.g. MDS, MDC etc)
67 * Common OBD namespace for lprocFS (these are used very often)
70 char* obd_dir_nm_1[]= {
79 lprocfs_vars_t obd_var_nm_1[]= {
80 {"num_ops", lprocfs_ll_rd, lprocfs_ll_wr},
81 {"min_time", lprocfs_ll_rd, lprocfs_ll_wr},
82 {"max_time", lprocfs_ll_rd, lprocfs_ll_wr},
83 {"sum_time", lprocfs_ll_rd, lprocfs_ll_wr},
89 * MDC Spcific namespace for lprocFS
92 char *mdc_dir_nm_1[]= {
107 * Create the MDC groupings
109 lprocfs_group_t lprocfs_mdc_nm[]= {
111 {obd_dir_nm_1, obd_var_nm_1, e_generic},
112 {mdc_dir_nm_1, obd_var_nm_1, e_generic},
117 * MDS Device Groupings
119 char *mds_dir_nm_1[]={
122 "disconnect_callback",
142 char *mds_dir_nm_2[]={
148 lprocfs_vars_t mds_var_nm_2[]={
149 {"f_type", rd_other, wr_other},
150 {"f_bsize",rd_other, wr_other},
151 {"f_blocks",rd_other, wr_other},
152 {"f_bfree",rd_other, wr_other},
153 {"f_bavail",rd_other, wr_other},
154 {"uuid",rd_string, wr_string},
159 lprocfs_group_t lprocfs_mds_nm[]={
160 {obd_dir_nm_1, obd_var_nm_1, e_generic},
161 {mds_dir_nm_1, obd_var_nm_1, e_generic},
162 {mds_dir_nm_2, mds_var_nm_2, e_specific},
170 char* osc_dir_nm_1[]={
184 lprocfs_group_t lprocfs_osc_nm[]={
185 {obd_dir_nm_1, obd_var_nm_1, e_generic},
186 {osc_dir_nm_1, obd_var_nm_1, e_generic},
192 * OST, LOV, OBD_FILTER namespace
193 * Note: These namespaces are exactly similar to the osc_dir_namespace
194 * Hence, I use the osc namespace as the base class and add only
195 * those attributes that are missing in osc_dir_namespace.
198 char *ost_lov_obdfilter_dir_nm_1[]={
204 char *ost_lov_obdfilter_dir_nm_2[]={
209 lprocfs_vars_t ost_lov_obdfilter_var_nm_2[]={
210 {"f_type", rd_other, wr_other},
211 {"f_bsize",rd_other, wr_other},
212 {"f_blocks",rd_other, wr_other},
213 {"f_bfree",rd_other, wr_other},
214 {"f_bavail",rd_other, wr_other},
215 {"f_objects", rd_other, wr_other},
216 {"f_ofree", rd_other, wr_other},
217 {"f_objectgroups", rd_other, wr_other},
218 {"f_uuid", rd_string, wr_string},
223 lprocfs_group_t lprocfs_ost_lov_obdf_nm[]={
224 {obd_dir_nm_1, obd_var_nm_1, e_generic},
225 {osc_dir_nm_1, obd_var_nm_1, e_generic},
226 {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
227 {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific},
232 * LDLM Device namespace
236 char* ldlm_dir_nm_1[]={
245 lprocfs_vars_t ldlm_var_nm_1[]= {
246 {"num_total", lprocfs_ll_rd, lprocfs_ll_wr},
247 {"num_zerolatency", lprocfs_ll_rd, lprocfs_ll_wr},
248 {"num_zerolatency_inflight", lprocfs_ll_rd, lprocfs_ll_wr},
249 {"num_zerolatency_done", lprocfs_ll_rd, lprocfs_ll_wr},
250 {"nonzero_mintime", lprocfs_ll_rd, lprocfs_ll_wr},
251 {"nonzero_maxtime", lprocfs_ll_rd, lprocfs_ll_wr},
252 {"nonzero_sumtime", lprocfs_ll_rd, lprocfs_ll_wr},
257 lprocfs_group_t lprocfs_ldlm_nm[]={
258 {obd_dir_nm_1, obd_var_nm_1, e_generic},
259 {ldlm_dir_nm_1, ldlm_var_nm_1, e_generic},
264 * Note: Need to add namespace for breaking out locks by device class
270 char* ptlrpc_dir_nm_1[]={
275 lprocfs_vars_t ptlrpc_var_nm_1[]={
276 {"msgs_alloc", lprocfs_ll_rd, lprocfs_ll_wr},
277 {"msgs_max", lprocfs_ll_rd, lprocfs_ll_wr},
278 {"recv_count", lprocfs_ll_rd, lprocfs_ll_wr},
279 {"recv_length", lprocfs_ll_rd, lprocfs_ll_wr},
280 {"send_count", lprocfs_ll_rd, lprocfs_ll_wr},
281 {"send_length", lprocfs_ll_rd, lprocfs_ll_wr},
282 {"portal_kmemory", lprocfs_ll_rd, lprocfs_ll_wr},
286 char* ptlrpc_dir_nm_2[] = {
291 lprocfs_vars_t ptlrpc_var_nm_2[] = {
292 {"type", rd_string, wr_string},
293 {"mtu", lprocfs_ll_rd, lprocfs_ll_wr},
294 {"rxpackets", lprocfs_ll_rd, lprocfs_ll_wr},
295 {"txpackets", lprocfs_ll_rd, lprocfs_ll_wr},
296 {"txbytes", lprocfs_ll_rd, lprocfs_ll_wr},
300 lprocfs_group_t lprocfs_ptlrpc_nm[]={
301 {obd_dir_nm_1, obd_var_nm_1, e_generic},
302 {ptlrpc_dir_nm_1, ptlrpc_var_nm_1, e_generic},
303 {ptlrpc_dir_nm_2, ptlrpc_var_nm_2, e_specific},
309 * Building the entire device namespace. This will be used during attach and
310 * detach to associate the namespace with the class of the device
313 lprocfs_obd_nm_t obd_nm[]={
314 {"mdc", lprocfs_mdc_nm, sizeof(struct lprofiler_gen)},
315 {"mds", lprocfs_mds_nm, sizeof(struct lprofiler_gen)},
316 {"osc", lprocfs_osc_nm, sizeof(struct lprofiler_gen)},
317 {"ost", lprocfs_ost_lov_obdf_nm, sizeof(struct lprofiler_gen)},
318 {"lov", lprocfs_ost_lov_obdf_nm, sizeof(struct lprofiler_gen)},
319 {"obdfilter", lprocfs_ost_lov_obdf_nm, sizeof(struct lprofiler_gen)},
320 {"obdecho", lprocfs_ost_lov_obdf_nm, sizeof(struct lprofiler_gen)},
321 {"ldlm", lprocfs_ldlm_nm, sizeof(struct lprofiler_ldlm)},
322 {"ptlrpc", lprocfs_ptlrpc_nm, sizeof(struct lprofiler_ptlrpc)},
328 lprocfs_obd_nm_t* obd_nm=0;
332 /* opening /dev/obd */
333 static int obd_class_open(struct inode * inode, struct file * file)
337 file->private_data = NULL;
342 /* closing /dev/obd */
343 static int obd_class_release(struct inode * inode, struct file * file)
347 if (file->private_data)
348 file->private_data = NULL;
355 inline void obd_data2conn(struct lustre_handle *conn, struct obd_ioctl_data *data)
357 conn->addr = data->ioc_addr;
358 conn->cookie = data->ioc_cookie;
362 inline void obd_conn2data(struct obd_ioctl_data *data, struct lustre_handle *conn)
364 data->ioc_addr = conn->addr;
365 data->ioc_cookie = conn->cookie;
369 /* to control /dev/obd */
370 static int obd_class_ioctl (struct inode * inode, struct file * filp,
371 unsigned int cmd, unsigned long arg)
375 struct obd_ioctl_data *data;
376 struct obd_device *obd = filp->private_data;
378 struct lustre_handle conn;
379 int rw = OBD_BRW_READ;
387 case OBD_IOC_BRW_WRITE:
388 case OBD_IOC_BRW_READ:
389 case OBD_IOC_GETATTR:
397 if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS &&
398 cmd != OBD_IOC_LIST &&
399 cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_NEWDEV) {
400 CERROR("OBD ioctl: No device\n");
401 GOTO(out, err=-EINVAL);
403 if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
404 CERROR("OBD ioctl: data error\n");
405 GOTO(out, err=-EINVAL);
407 data = (struct obd_ioctl_data *)buf;
411 GOTO(out, err=-EINVAL);
412 case OBD_IOC_DEVICE: {
413 CDEBUG(D_IOCTL, "\n");
414 if (data->ioc_dev >= MAX_OBD_DEVICES || data->ioc_dev < 0) {
415 CERROR("OBD ioctl: DEVICE insufficient devices\n");
416 GOTO(out, err=-EINVAL);
418 CDEBUG(D_IOCTL, "device %d\n", data->ioc_dev);
420 filp->private_data = &obd_dev[data->ioc_dev];
426 char *buf2 = data->ioc_bulk;
427 int remains = data->ioc_inllen1;
429 if (!data->ioc_inlbuf1) {
430 CERROR("No buffer passed!\n");
431 GOTO(out, err=-EINVAL);
435 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
438 struct obd_device *obd = &obd_dev[i];
441 if (obd->obd_flags & OBD_SET_UP)
443 else if (obd->obd_flags & OBD_ATTACHED)
447 l = snprintf(buf2, remains, "%2d %s %s %s %s %d\n",
448 i, status, obd->obd_type->typ_name,
449 obd->obd_name, obd->obd_uuid, obd->obd_type->typ_refcnt);
453 CERROR("not enough space for device listing\n");
458 err = copy_to_user((int *)arg, data, len);
463 case OBD_IOC_NAME2DEV: {
464 /* Resolve a device name. This does not change the
465 * currently selected device.
469 if (!data->ioc_inllen1 || !data->ioc_inlbuf1 ) {
470 CERROR("No name passed,!\n");
471 GOTO(out, err=-EINVAL);
473 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
474 CERROR("Name not nul terminated!\n");
475 GOTO(out, err=-EINVAL);
478 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
479 dev = class_name2dev(data->ioc_inlbuf1);
482 CDEBUG(D_IOCTL, "No device for name %s!\n",
484 GOTO(out, err=-EINVAL);
487 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
489 err = copy_to_user((int *)arg, data, sizeof(*data));
493 case OBD_IOC_UUID2DEV: {
494 /* Resolve a device uuid. This does not change the
495 * currently selected device.
499 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
500 CERROR("No UUID passed!\n");
501 GOTO(out, err=-EINVAL);
503 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
504 CERROR("Name not nul terminated!\n");
505 GOTO(out, err=-EINVAL);
508 CDEBUG(D_IOCTL, "device name %s\n", data->ioc_inlbuf1);
509 dev = class_uuid2dev(data->ioc_inlbuf1);
512 CDEBUG(D_IOCTL, "No device for name %s!\n",
514 GOTO(out, err=-EINVAL);
517 CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
519 err = copy_to_user((int *)arg, data, sizeof(*data));
523 case OBD_IOC_NEWDEV: {
527 filp->private_data = NULL;
528 for (i = 0 ; i < MAX_OBD_DEVICES ; i++) {
529 struct obd_device *obd = &obd_dev[i];
530 if (!obd->obd_type) {
531 filp->private_data = obd;
540 GOTO(out, err=-EINVAL);
542 err = copy_to_user((int *)arg, data, sizeof(*data));
546 case OBD_IOC_ATTACH: {
547 struct obd_type *type;
550 /* have we attached a type to this device */
551 if (obd->obd_flags & OBD_ATTACHED || obd->obd_type) {
552 CERROR("OBD: Device %d already typed as %s.\n",
553 obd->obd_minor, MKSTR(obd->obd_type->typ_name));
554 GOTO(out, err=-EBUSY);
557 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
558 CERROR("No type passed!\n");
559 GOTO(out, err=-EINVAL);
561 if (data->ioc_inlbuf1[data->ioc_inllen1-1] !=0) {
562 CERROR("Type not nul terminated!\n");
563 GOTO(out, err=-EINVAL);
566 CDEBUG(D_IOCTL, "attach type %s name: %s uuid: %s\n",
567 MKSTR(data->ioc_inlbuf1),
568 MKSTR(data->ioc_inlbuf2), MKSTR(data->ioc_inlbuf3));
571 type = class_nm_to_type(data->ioc_inlbuf1);
573 CERROR("OBD: unknown type dev %d\n", obd->obd_minor);
574 GOTO(out, err=-EINVAL);
577 minor = obd->obd_minor;
578 memset(obd, 0, sizeof(*obd));
579 obd->obd_minor = minor;
580 obd->obd_type = type;
581 INIT_LIST_HEAD(&obd->obd_exports);
582 INIT_LIST_HEAD(&obd->obd_imports);
583 spin_lock_init(&obd->obd_dev_lock);
586 if (OBP(obd, attach))
587 err = OBP(obd,attach)(obd, sizeof(*data), data);
589 obd->obd_type = NULL;
591 obd->obd_flags |= OBD_ATTACHED;
594 CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
595 obd->obd_minor, data->ioc_inlbuf1);
596 if (data->ioc_inlbuf2) {
597 int len = strlen(data->ioc_inlbuf2) + 1;
598 OBD_ALLOC(obd->obd_name, len);
599 if (!obd->obd_name) {
600 CERROR("no memory\n");
603 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
604 /* obd->obd_proc_entry =
605 proc_lustre_register_obd_device(obd);
608 CERROR("WARNING: unnamed obd device\n");
609 obd->obd_proc_entry = NULL;
612 if (data->ioc_inlbuf3) {
613 int len = strlen(data->ioc_inlbuf3);
614 if (len >= sizeof(obd->obd_uuid)) {
615 CERROR("uuid must be < %d bytes long\n",
616 sizeof(obd->obd_uuid));
618 OBD_FREE(obd->obd_name,
619 strlen(obd->obd_name) + 1);
620 GOTO(out, err=-EINVAL);
622 memcpy(obd->obd_uuid, data->ioc_inlbuf3, len);
624 /* Get the LprocFS namespace for this device class */
626 l_idx = lprocfs_get_nm(data->ioc_inlbuf1, obd_nm);
628 CERROR("Non-existent device class"
629 "or proc/lustre not compiled \n");
631 lprocfs_reg_dev(obd, obd_nm[l_idx].obd_names,
632 obd_nm[l_idx].cntr_blk_sz);
641 case OBD_IOC_DETACH: {
643 if (obd->obd_flags & OBD_SET_UP) {
644 CERROR("OBD device %d still set up\n", obd->obd_minor);
645 GOTO(out, err=-EBUSY);
647 if (!(obd->obd_flags & OBD_ATTACHED) ) {
648 CERROR("OBD device %d not attached\n", obd->obd_minor);
649 GOTO(out, err=-ENODEV);
651 #warning FIXME: Mike, we probably need some sort of "force detach" here
652 if (!list_empty(&obd->obd_exports) ) {
653 CERROR("OBD device %d (%p) has exports\n",
654 obd->obd_minor, obd);
655 GOTO(out, err=-EBUSY);
659 if (lprocfs_dereg_dev(obd) != LPROCFS_SUCCESS) {
660 CERROR("Could not remove /proc entry\n");
664 OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
665 obd->obd_name = NULL;
668 if (obd->obd_proc_entry)
669 proc_lustre_release_obd_device(obd);
672 obd->obd_flags &= ~OBD_ATTACHED;
673 obd->obd_type->typ_refcnt--;
674 obd->obd_type = NULL;
679 case OBD_IOC_SETUP: {
680 /* have we attached a type to this device? */
681 if (!(obd->obd_flags & OBD_ATTACHED)) {
682 CERROR("Device %d not attached\n", obd->obd_minor);
683 GOTO(out, err=-ENODEV);
686 /* has this been done already? */
687 if ( obd->obd_flags & OBD_SET_UP ) {
688 CERROR("Device %d already setup (type %s)\n",
689 obd->obd_minor, obd->obd_type->typ_name);
690 GOTO(out, err=-EBUSY);
693 if ( OBT(obd) && OBP(obd, setup) )
694 err = obd_setup(obd, sizeof(*data), data);
697 obd->obd_type->typ_refcnt++;
698 obd->obd_flags |= OBD_SET_UP;
703 case OBD_IOC_CLEANUP: {
704 /* have we attached a type to this device? */
705 if (!(obd->obd_flags & OBD_ATTACHED)) {
706 CERROR("Device %d not attached\n", obd->obd_minor);
707 GOTO(out, err=-ENODEV);
710 if ( OBT(obd) && OBP(obd, cleanup) )
711 err = obd_cleanup(obd);
714 obd->obd_flags &= ~OBD_SET_UP;
715 obd->obd_type->typ_refcnt--;
720 case OBD_IOC_CONNECT: {
721 char * cluuid = "OBD_CLASS_UUID";
722 obd_data2conn(&conn, data);
724 err = obd_connect(&conn, obd, cluuid);
726 CDEBUG(D_IOCTL, "assigned export "LPX64"\n", conn.addr);
727 obd_conn2data(data, &conn);
731 err = copy_to_user((int *)arg, data, sizeof(*data));
735 case OBD_IOC_DISCONNECT: {
736 obd_data2conn(&conn, data);
737 err = obd_disconnect(&conn);
741 case OBD_IOC_DEC_USE_COUNT: {
746 case OBD_IOC_CREATE: {
747 struct lov_stripe_md *ea = NULL;
748 obd_data2conn(&conn, data);
750 err = obd_create(&conn, &data->ioc_obdo1, &ea);
754 err = copy_to_user((int *)arg, data, sizeof(*data));
758 case OBD_IOC_GETATTR: {
760 obd_data2conn(&conn, data);
761 err = obd_getattr(&conn, &data->ioc_obdo1, NULL);
765 err = copy_to_user((int *)arg, data, sizeof(*data));
769 case OBD_IOC_SETATTR: {
770 obd_data2conn(&conn, data);
771 err = obd_setattr(&conn, &data->ioc_obdo1, NULL);
775 err = copy_to_user((int *)arg, data, sizeof(*data));
779 case OBD_IOC_DESTROY: {
781 obd_data2conn(&conn, data);
783 err = obd_destroy(&conn, &data->ioc_obdo1, NULL);
787 err = copy_to_user((int *)arg, data, sizeof(*data));
792 struct lov_stripe_md *md; // XXX fill in md from create
794 obd_data2conn(&conn, data);
795 err = obd_open(&conn, &data->ioc_obdo1, NULL);
799 case OBD_IOC_CLOSE: {
800 struct lov_stripe_md *md; // XXX fill in md from create
802 obd_data2conn(&conn, data);
803 obd_data2conn(&conn, data);
804 err = obd_close(&conn, &data->ioc_obdo1, NULL);
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;
827 off = data->ioc_offset;
829 CDEBUG(D_INODE, "BRW %s with %d pages @ "LPX64"\n",
830 rw == OBD_BRW_READ ? "read" : "write", pages, off);
831 OBD_ALLOC(pga, pages * sizeof(*pga));
833 CERROR("no memory for %d BRW per-page data\n", pages);
834 GOTO(brw_free, err = -ENOMEM);
837 memset(&smd, 0, sizeof(smd));
838 smd.lmd_object_id = id;
840 for (j = 0, pgp = pga; j < pages; j++, off += PAGE_SIZE, pgp++){
841 pgp->pg = alloc_pages(gfp_mask, 0);
843 CERROR("no memory for brw pages\n");
844 GOTO(brw_cleanup, err = -ENOMEM);
846 pgp->count = PAGE_SIZE;
851 void *addr = kmap(pgp->pg);
853 if (rw == OBD_BRW_WRITE)
854 page_debug_setup(addr, pgp->count,
857 page_debug_setup(addr, pgp->count,
864 err = obd_brw(rw, &conn, &smd, j, pga, ll_sync_io_cb, cbd);
866 CERROR("test_brw: error from obd_brw: err = %d\n", err);
869 for (j = 0, pgp = pga; j < pages; j++, pgp++) {
870 if (pgp->pg != NULL) {
871 if (verify && !err) {
872 void *addr = kmap(pgp->pg);
874 err = page_debug_check("test_brw",
880 __free_pages(pgp->pg, 0);
884 OBD_FREE(pga, pages * sizeof(*pga));
888 obd_data2conn(&conn, data);
890 err = obd_iocontrol(cmd, &conn, len, data, NULL);
894 err = copy_to_user((int *)arg, data, len);
904 } /* obd_class_ioctl */
908 /* declare character device */
909 static struct file_operations obd_psdev_fops = {
910 ioctl: obd_class_ioctl, /* ioctl */
911 open: obd_class_open, /* open */
912 release: obd_class_release, /* release */
916 #define OBD_MINOR 241
917 static struct miscdevice obd_psdev = {
923 void (*class_signal_connection_failure)(struct ptlrpc_connection *);
924 int (*mds_destroy_export)(struct obd_export *exp);
925 int (*ldlm_destroy_export)(struct obd_export *exp);
927 EXPORT_SYMBOL(obd_dev);
928 EXPORT_SYMBOL(obdo_cachep);
929 EXPORT_SYMBOL(obd_memory);
930 EXPORT_SYMBOL(obd_fail_loc);
931 EXPORT_SYMBOL(obd_timeout);
932 EXPORT_SYMBOL(obd_recovery_upcall);
934 EXPORT_SYMBOL(class_register_type);
935 EXPORT_SYMBOL(class_unregister_type);
936 EXPORT_SYMBOL(class_name2dev);
937 EXPORT_SYMBOL(class_uuid2dev);
938 EXPORT_SYMBOL(class_uuid2obd);
939 EXPORT_SYMBOL(class_new_export);
940 EXPORT_SYMBOL(class_destroy_export);
941 EXPORT_SYMBOL(class_connect);
942 EXPORT_SYMBOL(class_conn2export);
943 EXPORT_SYMBOL(class_conn2obd);
944 EXPORT_SYMBOL(class_conn2cliimp);
945 EXPORT_SYMBOL(class_conn2ldlmimp);
946 EXPORT_SYMBOL(class_disconnect);
947 EXPORT_SYMBOL(class_disconnect_all);
948 //EXPORT_SYMBOL(class_uuid_parse);
949 EXPORT_SYMBOL(class_uuid_unparse);
950 //EXPORT_SYMBOL(class_multi_setup);
951 //EXPORT_SYMBOL(class_multi_cleanup);
953 EXPORT_SYMBOL(class_signal_connection_failure);
954 EXPORT_SYMBOL(mds_destroy_export);
955 EXPORT_SYMBOL(ldlm_destroy_export);
956 EXPORT_SYMBOL(ll_sync_io_cb);
957 EXPORT_SYMBOL(ll_init_cb);
959 static int __init init_obdclass(void)
961 struct obd_device *obd;
965 printk(KERN_INFO "OBD class driver v0.9, info@clusterfs.com\n");
967 sema_init(&obd_conf_sem, 1);
968 INIT_LIST_HEAD(&obd_types);
970 if ((err = misc_register(&obd_psdev))) {
971 CERROR("cannot register %d err %d\n", OBD_MINOR, err);
975 /* This struct is already zerod for us (static global) */
976 for (i = 0, obd = obd_dev; i < MAX_OBD_DEVICES; i++, obd++)
979 err = obd_init_caches();
986 static void __exit cleanup_obdclass(void)
991 misc_deregister(&obd_psdev);
992 for (i = 0; i < MAX_OBD_DEVICES; i++) {
993 struct obd_device *obd = &obd_dev[i];
994 if (obd->obd_type && (obd->obd_flags & OBD_SET_UP) &&
995 OBT(obd) && OBP(obd, detach)) {
996 /* XXX should this call generic detach otherwise? */
997 OBP(obd, detach)(obd);
1001 obd_cleanup_caches();
1003 CERROR("obd memory leaked: %ld bytes\n", obd_memory);
1007 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1008 MODULE_DESCRIPTION("Lustre Class Driver v1.0");
1009 MODULE_LICENSE("GPL");
1011 module_init(init_obdclass);
1012 module_exit(cleanup_obdclass);