HID: Drop owner assignment from i2c_driver
[cascardo/linux.git] / drivers / staging / lustre / lustre / libcfs / module.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36 #include <linux/module.h>
37 #include <linux/kernel.h>
38 #include <linux/mm.h>
39 #include <linux/string.h>
40 #include <linux/stat.h>
41 #include <linux/errno.h>
42 #include <linux/unistd.h>
43 #include <net/sock.h>
44 #include <linux/uio.h>
45
46 #include <linux/uaccess.h>
47
48 #include <linux/fs.h>
49 #include <linux/file.h>
50 #include <linux/list.h>
51
52 #include <linux/sysctl.h>
53 #include <linux/debugfs.h>
54
55 # define DEBUG_SUBSYSTEM S_LNET
56
57 #include "../../include/linux/libcfs/libcfs.h"
58 #include <asm/div64.h>
59
60 #include "../../include/linux/libcfs/libcfs_crypto.h"
61 #include "../../include/linux/lnet/lib-lnet.h"
62 #include "../../include/linux/lnet/lnet.h"
63 #include "tracefile.h"
64
65 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
66 MODULE_DESCRIPTION("Portals v3.1");
67 MODULE_LICENSE("GPL");
68
69 static struct dentry *lnet_debugfs_root;
70
71 static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
72 {
73         struct page **level0p = &ldu->ldu_memhog_root_page;
74         struct page **level1p;
75         struct page **level2p;
76         int        count1;
77         int        count2;
78
79         if (*level0p != NULL) {
80
81                 level1p = (struct page **)page_address(*level0p);
82                 count1 = 0;
83
84                 while (count1 < PAGE_CACHE_SIZE/sizeof(struct page *) &&
85                        *level1p != NULL) {
86
87                         level2p = (struct page **)page_address(*level1p);
88                         count2 = 0;
89
90                         while (count2 < PAGE_CACHE_SIZE/sizeof(struct page *) &&
91                                *level2p != NULL) {
92
93                                 __free_page(*level2p);
94                                 ldu->ldu_memhog_pages--;
95                                 level2p++;
96                                 count2++;
97                         }
98
99                         __free_page(*level1p);
100                         ldu->ldu_memhog_pages--;
101                         level1p++;
102                         count1++;
103                 }
104
105                 __free_page(*level0p);
106                 ldu->ldu_memhog_pages--;
107
108                 *level0p = NULL;
109         }
110
111         LASSERT(ldu->ldu_memhog_pages == 0);
112 }
113
114 static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
115                      gfp_t flags)
116 {
117         struct page **level0p;
118         struct page **level1p;
119         struct page **level2p;
120         int        count1;
121         int        count2;
122
123         LASSERT(ldu->ldu_memhog_pages == 0);
124         LASSERT(ldu->ldu_memhog_root_page == NULL);
125
126         if (npages < 0)
127                 return -EINVAL;
128
129         if (npages == 0)
130                 return 0;
131
132         level0p = &ldu->ldu_memhog_root_page;
133         *level0p = alloc_page(flags);
134         if (*level0p == NULL)
135                 return -ENOMEM;
136         ldu->ldu_memhog_pages++;
137
138         level1p = (struct page **)page_address(*level0p);
139         count1 = 0;
140         memset(level1p, 0, PAGE_CACHE_SIZE);
141
142         while (ldu->ldu_memhog_pages < npages &&
143                count1 < PAGE_CACHE_SIZE/sizeof(struct page *)) {
144
145                 if (cfs_signal_pending())
146                         return -EINTR;
147
148                 *level1p = alloc_page(flags);
149                 if (*level1p == NULL)
150                         return -ENOMEM;
151                 ldu->ldu_memhog_pages++;
152
153                 level2p = (struct page **)page_address(*level1p);
154                 count2 = 0;
155                 memset(level2p, 0, PAGE_CACHE_SIZE);
156
157                 while (ldu->ldu_memhog_pages < npages &&
158                        count2 < PAGE_CACHE_SIZE/sizeof(struct page *)) {
159
160                         if (cfs_signal_pending())
161                                 return -EINTR;
162
163                         *level2p = alloc_page(flags);
164                         if (*level2p == NULL)
165                                 return -ENOMEM;
166                         ldu->ldu_memhog_pages++;
167
168                         level2p++;
169                         count2++;
170                 }
171
172                 level1p++;
173                 count1++;
174         }
175
176         return 0;
177 }
178
179 /* called when opening /dev/device */
180 static int libcfs_psdev_open(unsigned long flags, void *args)
181 {
182         struct libcfs_device_userstate *ldu;
183
184         try_module_get(THIS_MODULE);
185
186         LIBCFS_ALLOC(ldu, sizeof(*ldu));
187         if (ldu != NULL) {
188                 ldu->ldu_memhog_pages = 0;
189                 ldu->ldu_memhog_root_page = NULL;
190         }
191         *(struct libcfs_device_userstate **)args = ldu;
192
193         return 0;
194 }
195
196 /* called when closing /dev/device */
197 static int libcfs_psdev_release(unsigned long flags, void *args)
198 {
199         struct libcfs_device_userstate *ldu;
200
201         ldu = (struct libcfs_device_userstate *)args;
202         if (ldu != NULL) {
203                 kportal_memhog_free(ldu);
204                 LIBCFS_FREE(ldu, sizeof(*ldu));
205         }
206
207         module_put(THIS_MODULE);
208         return 0;
209 }
210
211 static DECLARE_RWSEM(ioctl_list_sem);
212 static LIST_HEAD(ioctl_list);
213
214 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand)
215 {
216         int rc = 0;
217
218         down_write(&ioctl_list_sem);
219         if (!list_empty(&hand->item))
220                 rc = -EBUSY;
221         else
222                 list_add_tail(&hand->item, &ioctl_list);
223         up_write(&ioctl_list_sem);
224
225         return rc;
226 }
227 EXPORT_SYMBOL(libcfs_register_ioctl);
228
229 int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
230 {
231         int rc = 0;
232
233         down_write(&ioctl_list_sem);
234         if (list_empty(&hand->item))
235                 rc = -ENOENT;
236         else
237                 list_del_init(&hand->item);
238         up_write(&ioctl_list_sem);
239
240         return rc;
241 }
242 EXPORT_SYMBOL(libcfs_deregister_ioctl);
243
244 static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
245                             void *arg, struct libcfs_ioctl_data *data)
246 {
247         int err = -EINVAL;
248
249         switch (cmd) {
250         case IOC_LIBCFS_CLEAR_DEBUG:
251                 libcfs_debug_clear_buffer();
252                 return 0;
253         /*
254          * case IOC_LIBCFS_PANIC:
255          * Handled in arch/cfs_module.c
256          */
257         case IOC_LIBCFS_MARK_DEBUG:
258                 if (data->ioc_inlbuf1 == NULL ||
259                     data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0')
260                         return -EINVAL;
261                 libcfs_debug_mark_buffer(data->ioc_inlbuf1);
262                 return 0;
263         case IOC_LIBCFS_MEMHOG:
264                 if (pfile->private_data == NULL) {
265                         err = -EINVAL;
266                 } else {
267                         kportal_memhog_free(pfile->private_data);
268                         /* XXX The ioc_flags is not GFP flags now, need to be fixed */
269                         err = kportal_memhog_alloc(pfile->private_data,
270                                                    data->ioc_count,
271                                                    data->ioc_flags);
272                         if (err != 0)
273                                 kportal_memhog_free(pfile->private_data);
274                 }
275                 break;
276
277         case IOC_LIBCFS_PING_TEST: {
278                 extern void (kping_client)(struct libcfs_ioctl_data *);
279                 void (*ping)(struct libcfs_ioctl_data *);
280
281                 CDEBUG(D_IOCTL, "doing %d pings to nid %s (%s)\n",
282                        data->ioc_count, libcfs_nid2str(data->ioc_nid),
283                        libcfs_nid2str(data->ioc_nid));
284                 ping = symbol_get(kping_client);
285                 if (!ping)
286                         CERROR("symbol_get failed\n");
287                 else {
288                         ping(data);
289                         symbol_put(kping_client);
290                 }
291                 return 0;
292         }
293
294         default: {
295                 struct libcfs_ioctl_handler *hand;
296
297                 err = -EINVAL;
298                 down_read(&ioctl_list_sem);
299                 list_for_each_entry(hand, &ioctl_list, item) {
300                         err = hand->handle_ioctl(cmd, data);
301                         if (err != -EINVAL) {
302                                 if (err == 0)
303                                         err = libcfs_ioctl_popdata(arg,
304                                                         data, sizeof(*data));
305                                 break;
306                         }
307                 }
308                 up_read(&ioctl_list_sem);
309                 break;
310         }
311         }
312
313         return err;
314 }
315
316 static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *arg)
317 {
318         char    *buf;
319         struct libcfs_ioctl_data *data;
320         int err = 0;
321
322         LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS);
323         if (buf == NULL)
324                 return -ENOMEM;
325
326         /* 'cmd' and permissions get checked in our arch-specific caller */
327         if (libcfs_ioctl_getdata(buf, buf + 800, arg)) {
328                 CERROR("PORTALS ioctl: data error\n");
329                 err = -EINVAL;
330                 goto out;
331         }
332         data = (struct libcfs_ioctl_data *)buf;
333
334         err = libcfs_ioctl_int(pfile, cmd, arg, data);
335
336 out:
337         LIBCFS_FREE(buf, 1024);
338         return err;
339 }
340
341 struct cfs_psdev_ops libcfs_psdev_ops = {
342         libcfs_psdev_open,
343         libcfs_psdev_release,
344         NULL,
345         NULL,
346         libcfs_ioctl
347 };
348
349 static int proc_call_handler(void *data, int write, loff_t *ppos,
350                 void __user *buffer, size_t *lenp,
351                 int (*handler)(void *data, int write,
352                 loff_t pos, void __user *buffer, int len))
353 {
354         int rc = handler(data, write, *ppos, buffer, *lenp);
355
356         if (rc < 0)
357                 return rc;
358
359         if (write) {
360                 *ppos += *lenp;
361         } else {
362                 *lenp = rc;
363                 *ppos += rc;
364         }
365         return 0;
366 }
367
368 static int __proc_dobitmasks(void *data, int write,
369                              loff_t pos, void __user *buffer, int nob)
370 {
371         const int     tmpstrlen = 512;
372         char     *tmpstr;
373         int        rc;
374         unsigned int *mask = data;
375         int        is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0;
376         int        is_printk = (mask == &libcfs_printk) ? 1 : 0;
377
378         rc = cfs_trace_allocate_string_buffer(&tmpstr, tmpstrlen);
379         if (rc < 0)
380                 return rc;
381
382         if (!write) {
383                 libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys);
384                 rc = strlen(tmpstr);
385
386                 if (pos >= rc) {
387                         rc = 0;
388                 } else {
389                         rc = cfs_trace_copyout_string(buffer, nob,
390                                                       tmpstr + pos, "\n");
391                 }
392         } else {
393                 rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
394                 if (rc < 0) {
395                         cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
396                         return rc;
397                 }
398
399                 rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys);
400                 /* Always print LBUG/LASSERT to console, so keep this mask */
401                 if (is_printk)
402                         *mask |= D_EMERG;
403         }
404
405         cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
406         return rc;
407 }
408
409 static int proc_dobitmasks(struct ctl_table *table, int write,
410                            void __user *buffer, size_t *lenp, loff_t *ppos)
411 {
412         return proc_call_handler(table->data, write, ppos, buffer, lenp,
413                                  __proc_dobitmasks);
414 }
415
416 static int __proc_dump_kernel(void *data, int write,
417                               loff_t pos, void __user *buffer, int nob)
418 {
419         if (!write)
420                 return 0;
421
422         return cfs_trace_dump_debug_buffer_usrstr(buffer, nob);
423 }
424
425 static int proc_dump_kernel(struct ctl_table *table, int write,
426                             void __user *buffer, size_t *lenp, loff_t *ppos)
427 {
428         return proc_call_handler(table->data, write, ppos, buffer, lenp,
429                                  __proc_dump_kernel);
430 }
431
432 static int __proc_daemon_file(void *data, int write,
433                               loff_t pos, void __user *buffer, int nob)
434 {
435         if (!write) {
436                 int len = strlen(cfs_tracefile);
437
438                 if (pos >= len)
439                         return 0;
440
441                 return cfs_trace_copyout_string(buffer, nob,
442                                                 cfs_tracefile + pos, "\n");
443         }
444
445         return cfs_trace_daemon_command_usrstr(buffer, nob);
446 }
447
448 static int proc_daemon_file(struct ctl_table *table, int write,
449                             void __user *buffer, size_t *lenp, loff_t *ppos)
450 {
451         return proc_call_handler(table->data, write, ppos, buffer, lenp,
452                                  __proc_daemon_file);
453 }
454
455 static int libcfs_force_lbug(struct ctl_table *table, int write,
456                              void __user *buffer,
457                              size_t *lenp, loff_t *ppos)
458 {
459         if (write)
460                 LBUG();
461         return 0;
462 }
463
464 static int proc_fail_loc(struct ctl_table *table, int write,
465                          void __user *buffer,
466                          size_t *lenp, loff_t *ppos)
467 {
468         int rc;
469         long old_fail_loc = cfs_fail_loc;
470
471         rc = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
472         if (old_fail_loc != cfs_fail_loc)
473                 wake_up(&cfs_race_waitq);
474         return rc;
475 }
476
477 static int __proc_cpt_table(void *data, int write,
478                             loff_t pos, void __user *buffer, int nob)
479 {
480         char *buf = NULL;
481         int   len = 4096;
482         int   rc  = 0;
483
484         if (write)
485                 return -EPERM;
486
487         LASSERT(cfs_cpt_table != NULL);
488
489         while (1) {
490                 LIBCFS_ALLOC(buf, len);
491                 if (buf == NULL)
492                         return -ENOMEM;
493
494                 rc = cfs_cpt_table_print(cfs_cpt_table, buf, len);
495                 if (rc >= 0)
496                         break;
497
498                 if (rc == -EFBIG) {
499                         LIBCFS_FREE(buf, len);
500                         len <<= 1;
501                         continue;
502                 }
503                 goto out;
504         }
505
506         if (pos >= rc) {
507                 rc = 0;
508                 goto out;
509         }
510
511         rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
512  out:
513         if (buf != NULL)
514                 LIBCFS_FREE(buf, len);
515         return rc;
516 }
517
518 static int proc_cpt_table(struct ctl_table *table, int write,
519                            void __user *buffer, size_t *lenp, loff_t *ppos)
520 {
521         return proc_call_handler(table->data, write, ppos, buffer, lenp,
522                                  __proc_cpt_table);
523 }
524
525 static struct ctl_table lnet_table[] = {
526         /*
527          * NB No .strategy entries have been provided since sysctl(8) prefers
528          * to go via /proc for portability.
529          */
530         {
531                 .procname = "debug",
532                 .data     = &libcfs_debug,
533                 .maxlen   = sizeof(int),
534                 .mode     = 0644,
535                 .proc_handler = &proc_dobitmasks,
536         },
537         {
538                 .procname = "subsystem_debug",
539                 .data     = &libcfs_subsystem_debug,
540                 .maxlen   = sizeof(int),
541                 .mode     = 0644,
542                 .proc_handler = &proc_dobitmasks,
543         },
544         {
545                 .procname = "printk",
546                 .data     = &libcfs_printk,
547                 .maxlen   = sizeof(int),
548                 .mode     = 0644,
549                 .proc_handler = &proc_dobitmasks,
550         },
551         {
552                 .procname = "cpu_partition_table",
553                 .maxlen   = 128,
554                 .mode     = 0444,
555                 .proc_handler = &proc_cpt_table,
556         },
557
558         {
559                 .procname = "upcall",
560                 .data     = lnet_upcall,
561                 .maxlen   = sizeof(lnet_upcall),
562                 .mode     = 0644,
563                 .proc_handler = &proc_dostring,
564         },
565         {
566                 .procname = "debug_log_upcall",
567                 .data     = lnet_debug_log_upcall,
568                 .maxlen   = sizeof(lnet_debug_log_upcall),
569                 .mode     = 0644,
570                 .proc_handler = &proc_dostring,
571         },
572         {
573                 .procname = "catastrophe",
574                 .data     = &libcfs_catastrophe,
575                 .maxlen   = sizeof(int),
576                 .mode     = 0444,
577                 .proc_handler = &proc_dointvec,
578         },
579         {
580                 .procname = "dump_kernel",
581                 .maxlen   = 256,
582                 .mode     = 0200,
583                 .proc_handler = &proc_dump_kernel,
584         },
585         {
586                 .procname = "daemon_file",
587                 .mode     = 0644,
588                 .maxlen   = 256,
589                 .proc_handler = &proc_daemon_file,
590         },
591         {
592                 .procname = "force_lbug",
593                 .data     = NULL,
594                 .maxlen   = 0,
595                 .mode     = 0200,
596                 .proc_handler = &libcfs_force_lbug
597         },
598         {
599                 .procname = "fail_loc",
600                 .data     = &cfs_fail_loc,
601                 .maxlen   = sizeof(cfs_fail_loc),
602                 .mode     = 0644,
603                 .proc_handler = &proc_fail_loc
604         },
605         {
606                 .procname = "fail_val",
607                 .data     = &cfs_fail_val,
608                 .maxlen   = sizeof(int),
609                 .mode     = 0644,
610                 .proc_handler = &proc_dointvec
611         },
612         {
613         }
614 };
615
616 static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
617         { "console_ratelimit",
618           "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
619         { "debug_path",
620           "/sys/module/libcfs/parameters/libcfs_debug_file_path"},
621         { "panic_on_lbug",
622           "/sys/module/libcfs/parameters/libcfs_panic_on_lbug"},
623         { "libcfs_console_backoff",
624           "/sys/module/libcfs/parameters/libcfs_console_backoff"},
625         { "debug_mb",
626           "/sys/module/libcfs/parameters/libcfs_debug_mb"},
627         { "console_min_delay_centisecs",
628           "/sys/module/libcfs/parameters/libcfs_console_min_delay"},
629         { "console_max_delay_centisecs",
630           "/sys/module/libcfs/parameters/libcfs_console_max_delay"},
631         {},
632 };
633
634 static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
635                                  size_t count, loff_t *ppos)
636 {
637         struct ctl_table *table = filp->private_data;
638         int error;
639
640         error = table->proc_handler(table, 0, (void __user *)buf, &count, ppos);
641         if (!error)
642                 error = count;
643
644         return error;
645 }
646
647 static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf,
648                                   size_t count, loff_t *ppos)
649 {
650         struct ctl_table *table = filp->private_data;
651         int error;
652
653         error = table->proc_handler(table, 1, (void __user *)buf, &count, ppos);
654         if (!error)
655                 error = count;
656
657         return error;
658 }
659
660 static const struct file_operations lnet_debugfs_file_operations = {
661         .open           = simple_open,
662         .read           = lnet_debugfs_read,
663         .write          = lnet_debugfs_write,
664         .llseek         = default_llseek,
665 };
666
667 void lustre_insert_debugfs(struct ctl_table *table,
668                            const struct lnet_debugfs_symlink_def *symlinks)
669 {
670         struct dentry *entry;
671
672         if (lnet_debugfs_root == NULL)
673                 lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
674
675         /* Even if we cannot create, just ignore it altogether) */
676         if (IS_ERR_OR_NULL(lnet_debugfs_root))
677                 return;
678
679         for (; table->procname; table++)
680                 entry = debugfs_create_file(table->procname, table->mode,
681                                             lnet_debugfs_root, table,
682                                             &lnet_debugfs_file_operations);
683
684         for (; symlinks && symlinks->name; symlinks++)
685                 entry = debugfs_create_symlink(symlinks->name,
686                                                lnet_debugfs_root,
687                                                symlinks->target);
688
689 }
690 EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
691
692 static void lustre_remove_debugfs(void)
693 {
694         if (lnet_debugfs_root != NULL)
695                 debugfs_remove_recursive(lnet_debugfs_root);
696
697         lnet_debugfs_root = NULL;
698 }
699
700 static int init_libcfs_module(void)
701 {
702         int rc;
703
704         rc = libcfs_debug_init(5 * 1024 * 1024);
705         if (rc < 0) {
706                 pr_err("LustreError: libcfs_debug_init: %d\n", rc);
707                 return rc;
708         }
709
710         rc = cfs_cpu_init();
711         if (rc != 0)
712                 goto cleanup_debug;
713
714         rc = misc_register(&libcfs_dev);
715         if (rc) {
716                 CERROR("misc_register: error %d\n", rc);
717                 goto cleanup_cpu;
718         }
719
720         rc = cfs_wi_startup();
721         if (rc) {
722                 CERROR("initialize workitem: error %d\n", rc);
723                 goto cleanup_deregister;
724         }
725
726         /* max to 4 threads, should be enough for rehash */
727         rc = min(cfs_cpt_weight(cfs_cpt_table, CFS_CPT_ANY), 4);
728         rc = cfs_wi_sched_create("cfs_rh", cfs_cpt_table, CFS_CPT_ANY,
729                                  rc, &cfs_sched_rehash);
730         if (rc != 0) {
731                 CERROR("Startup workitem scheduler: error: %d\n", rc);
732                 goto cleanup_deregister;
733         }
734
735         rc = cfs_crypto_register();
736         if (rc) {
737                 CERROR("cfs_crypto_register: error %d\n", rc);
738                 goto cleanup_wi;
739         }
740
741         lustre_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
742
743         CDEBUG(D_OTHER, "portals setup OK\n");
744         return 0;
745  cleanup_wi:
746         cfs_wi_shutdown();
747  cleanup_deregister:
748         misc_deregister(&libcfs_dev);
749 cleanup_cpu:
750         cfs_cpu_fini();
751  cleanup_debug:
752         libcfs_debug_cleanup();
753         return rc;
754 }
755
756 static void exit_libcfs_module(void)
757 {
758         int rc;
759
760         lustre_remove_debugfs();
761
762         if (cfs_sched_rehash) {
763                 cfs_wi_sched_destroy(cfs_sched_rehash);
764                 cfs_sched_rehash = NULL;
765         }
766
767         cfs_crypto_unregister();
768         cfs_wi_shutdown();
769
770         misc_deregister(&libcfs_dev);
771
772         cfs_cpu_fini();
773
774         rc = libcfs_debug_cleanup();
775         if (rc)
776                 pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
777 }
778
779 MODULE_VERSION("1.0.0");
780
781 module_init(init_libcfs_module);
782 module_exit(exit_libcfs_module);