Whamcloud - gitweb
Branch: b1_4_smallfix
[fs/lustre-release.git] / lnet / libcfs / module.c
index 06f1578..9358af2 100644 (file)
@@ -266,7 +266,7 @@ libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *private)
         int                     i;
         int                     rc;
 
-        CDEBUG(D_IOCTL, "Register NAL %d, handler: %p\n", nal, handler);
+        CDEBUG(D_IOCTL, "Register NAL %x, handler: %p\n", nal, handler);
 
         down(&nal_cmd_sem);
 
@@ -302,7 +302,7 @@ libcfs_nal_cmd_unregister(int nal)
 {
         struct nal_cmd_handler *cmd;
 
-        CDEBUG(D_IOCTL, "Unregister NAL %d\n", nal);
+        CDEBUG(D_IOCTL, "Unregister NAL %x\n", nal);
 
         down(&nal_cmd_sem);
         cmd = libcfs_find_nal_cmd_handler(nal);
@@ -316,6 +316,10 @@ EXPORT_SYMBOL(libcfs_nal_cmd_unregister);
 int
 libcfs_nal_cmd(struct portals_cfg *pcfg)
 {
+#if CRAY_PORTALS
+        /* pretend success */
+        RETURN(0);
+#else
         struct nal_cmd_handler *cmd;
         __u32 nal = pcfg->pcfg_nal;
         int   rc = -EINVAL;
@@ -324,13 +328,16 @@ libcfs_nal_cmd(struct portals_cfg *pcfg)
         down(&nal_cmd_sem);
         cmd = libcfs_find_nal_cmd_handler(nal);
         if (cmd != NULL) {
-                CDEBUG(D_IOCTL, "calling handler nal: %d, cmd: %d\n", nal, 
+                CDEBUG(D_IOCTL, "calling handler nal: %x, cmd: %d\n", nal, 
                        pcfg->pcfg_command);
                 rc = cmd->nch_handler(pcfg, cmd->nch_private);
+        } else {
+                CERROR("invalid nal: %x, cmd: %d\n", nal, pcfg->pcfg_command);
         }
         up(&nal_cmd_sem);
 
         RETURN(rc);
+#endif
 }
 EXPORT_SYMBOL(libcfs_nal_cmd);
 
@@ -398,23 +405,6 @@ static int libcfs_ioctl(struct inode *inode, struct file *file,
         data = (struct portal_ioctl_data *)buf;
 
         switch (cmd) {
-        case IOC_PORTAL_SET_DAEMON: 
-                RETURN (portals_debug_set_daemon ( 
-                                        (unsigned int) data->ioc_count,
-                                        (unsigned int) data->ioc_inllen1,
-                                        (char *) data->ioc_inlbuf1,
-                                        (unsigned int) data->ioc_misc)); 
-        case IOC_PORTAL_GET_DEBUG: {
-                __s32 size = portals_debug_copy_to_user(data->ioc_pbuf1,
-                                                        data->ioc_plen1);
-
-                if (size < 0)
-                        RETURN(size);
-
-                data->ioc_size = size;
-                err = copy_to_user((char *)arg, data, sizeof(*data));
-                RETURN(err);
-        }
         case IOC_PORTAL_CLEAR_DEBUG:
                 portals_debug_clear_buffer();
                 RETURN(0);
@@ -430,27 +420,31 @@ static int libcfs_ioctl(struct inode *inode, struct file *file,
                 portals_debug_mark_buffer(data->ioc_inlbuf1);
                 RETURN(0);
 #if LWT_SUPPORT
-        case IOC_PORTAL_LWT_CONTROL: 
+        case IOC_PORTAL_LWT_CONTROL:
                 err = lwt_control (data->ioc_flags, data->ioc_misc);
                 break;
-                
+
         case IOC_PORTAL_LWT_SNAPSHOT: {
                 cycles_t   now;
                 int        ncpu;
                 int        total_size;
-                
+
                 err = lwt_snapshot (&now, &ncpu, &total_size,
                                     data->ioc_pbuf1, data->ioc_plen1);
                 data->ioc_nid = now;
                 data->ioc_count = ncpu;
                 data->ioc_misc = total_size;
 
+                /* Hedge against broken user/kernel typedefs (e.g. cycles_t) */
+                data->ioc_nid2 = sizeof(lwt_event_t);
+                data->ioc_nid3 = offsetof(lwt_event_t, lwte_where);
+
                 if (err == 0 &&
                     copy_to_user((char *)arg, data, sizeof (*data)))
                         err = -EFAULT;
                 break;
         }
-                
+
         case IOC_PORTAL_LWT_LOOKUP_STRING:
                 err = lwt_lookup_string (&data->ioc_count, data->ioc_pbuf1,
                                          data->ioc_pbuf2, data->ioc_plen2);
@@ -463,24 +457,24 @@ static int libcfs_ioctl(struct inode *inode, struct file *file,
                 struct portals_cfg pcfg;
 
                 if (data->ioc_plen1 != sizeof(pcfg)) {
-                        CERROR("Bad ioc_plen1 %d (wanted %d)\n",
+                        CERROR("Bad ioc_plen1 %d (wanted "LPSZ")\n",
                                data->ioc_plen1, sizeof(pcfg));
                         err = -EINVAL;
                         break;
                 }
 
-                if (copy_from_user(&pcfg, (void *)data->ioc_pbuf1, 
+                if (copy_from_user(&pcfg, (void *)data->ioc_pbuf1,
                                    sizeof(pcfg))) {
                         err = -EFAULT;
                         break;
                 }
 
-                CDEBUG (D_IOCTL, "nal command nal %d cmd %d\n", pcfg.pcfg_nal,
+                CDEBUG (D_IOCTL, "nal command nal %x cmd %d\n", pcfg.pcfg_nal,
                         pcfg.pcfg_command);
                 err = libcfs_nal_cmd(&pcfg);
 
                 if (err == 0 &&
-                    copy_to_user((char *)data->ioc_pbuf1, &pcfg, 
+                    copy_to_user((char *)data->ioc_pbuf1, &pcfg,
                                  sizeof (pcfg)))
                         err = -EFAULT;
                 break;
@@ -589,7 +583,6 @@ static void exit_libcfs_module(void)
         CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
                atomic_read(&portal_kmemory));
 
-
         rc = misc_deregister(&libcfs_dev);
         if (rc)
                 CERROR("misc_deregister error %d\n", rc);