Whamcloud - gitweb
b=19808 : 2.6.29-fc11 patchless client support
[fs/lustre-release.git] / libcfs / libcfs / module.c
index 5918560..a5a8071 100644 (file)
@@ -220,21 +220,12 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
 }
 EXPORT_SYMBOL(libcfs_deregister_ioctl);
 
-static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *arg)
+static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd,
+                            void *arg, struct libcfs_ioctl_data *data)
 {
-        char    buf[1024];
         int err = -EINVAL;
-        struct libcfs_ioctl_data *data;
         ENTRY;
 
-        /* 'cmd' and permissions get checked in our arch-specific caller */
-
-        if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) {
-                CERROR("PORTALS ioctl: data error\n");
-                RETURN(-EINVAL);
-        }
-        data = (struct libcfs_ioctl_data *)buf;
-
         switch (cmd) {
         case IOC_LIBCFS_CLEAR_DEBUG:
                 libcfs_debug_clear_buffer();
@@ -319,7 +310,8 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a
                 struct libcfs_ioctl_handler *hand;
                 err = -EINVAL;
                 down_read(&ioctl_list_sem);
-                list_for_each_entry(hand, &ioctl_list, item) {
+                cfs_list_for_each_entry_typed(hand, &ioctl_list,
+                        struct libcfs_ioctl_handler, item) {
                         err = hand->handle_ioctl(cmd, data);
                         if (err != -EINVAL) {
                                 if (err == 0)
@@ -336,6 +328,32 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a
         RETURN(err);
 }
 
+static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *arg)
+{
+        char    *buf;
+        struct libcfs_ioctl_data *data;
+        int err;
+        ENTRY;
+
+        LIBCFS_ALLOC_GFP(buf, 1024, CFS_ALLOC_STD);
+        if (buf == NULL)
+                RETURN(-ENOMEM);
+
+        /* 'cmd' and permissions get checked in our arch-specific caller */
+        if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) {
+                CERROR("PORTALS ioctl: data error\n");
+                GOTO(out, err = -EINVAL);
+        }
+        data = (struct libcfs_ioctl_data *)buf;
+
+        err = libcfs_ioctl_int(pfile, cmd, arg, data);
+
+out:
+        LIBCFS_FREE(buf, 1024);
+        RETURN(err);
+}
+
+
 struct cfs_psdev_ops libcfs_psdev_ops = {
         libcfs_psdev_open,
         libcfs_psdev_release,
@@ -432,6 +450,10 @@ static void exit_libcfs_module(void)
         rc = libcfs_debug_cleanup();
         if (rc)
                 printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n", rc);
+
+        fini_rwsem(&ioctl_list_sem);
+        fini_rwsem(&tracefile_sem);
+
         libcfs_arch_cleanup();
 }