]> git.proxmox.com Git - mirror_spl.git/blob - module/spl/spl-generic.c
Fix cstyle warnings
[mirror_spl.git] / module / spl / spl-generic.c
1 /*
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6 * UCRL-CODE-235197
7 *
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://zfsonlinux.org/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 *
24 * Solaris Porting Layer (SPL) Generic Implementation.
25 */
26
27 #include <sys/sysmacros.h>
28 #include <sys/systeminfo.h>
29 #include <sys/vmsystm.h>
30 #include <sys/kobj.h>
31 #include <sys/kmem.h>
32 #include <sys/kmem_cache.h>
33 #include <sys/vmem.h>
34 #include <sys/mutex.h>
35 #include <sys/rwlock.h>
36 #include <sys/taskq.h>
37 #include <sys/tsd.h>
38 #include <sys/zmod.h>
39 #include <sys/debug.h>
40 #include <sys/proc.h>
41 #include <sys/kstat.h>
42 #include <sys/file.h>
43 #include <linux/ctype.h>
44 #include <sys/disp.h>
45 #include <sys/random.h>
46 #include <linux/kmod.h>
47 #include <linux/math64_compat.h>
48 #include <linux/proc_compat.h>
49
50 char spl_version[32] = "SPL v" SPL_META_VERSION "-" SPL_META_RELEASE;
51 EXPORT_SYMBOL(spl_version);
52
53 unsigned long spl_hostid = 0;
54 EXPORT_SYMBOL(spl_hostid);
55 module_param(spl_hostid, ulong, 0644);
56 MODULE_PARM_DESC(spl_hostid, "The system hostid.");
57
58 proc_t p0;
59 EXPORT_SYMBOL(p0);
60
61 /*
62 * Xorshift Pseudo Random Number Generator based on work by Sebastiano Vigna
63 *
64 * "Further scramblings of Marsaglia's xorshift generators"
65 * http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
66 *
67 * random_get_pseudo_bytes() is an API function on Illumos whose sole purpose
68 * is to provide bytes containing random numbers. It is mapped to /dev/urandom
69 * on Illumos, which uses a "FIPS 186-2 algorithm". No user of the SPL's
70 * random_get_pseudo_bytes() needs bytes that are of cryptographic quality, so
71 * we can implement it using a fast PRNG that we seed using Linux' actual
72 * equivalent to random_get_pseudo_bytes(). We do this by providing each CPU
73 * with an independent seed so that all calls to random_get_pseudo_bytes() are
74 * free of atomic instructions.
75 *
76 * A consequence of using a fast PRNG is that using random_get_pseudo_bytes()
77 * to generate words larger than 128 bits will paradoxically be limited to
78 * `2^128 - 1` possibilities. This is because we have a sequence of `2^128 - 1`
79 * 128-bit words and selecting the first will implicitly select the second. If
80 * a caller finds this behavior undesireable, random_get_bytes() should be used
81 * instead.
82 *
83 * XXX: Linux interrupt handlers that trigger within the critical section
84 * formed by `s[1] = xp[1];` and `xp[0] = s[0];` and call this function will
85 * see the same numbers. Nothing in the code currently calls this in an
86 * interrupt handler, so this is considered to be okay. If that becomes a
87 * problem, we could create a set of per-cpu variables for interrupt handlers
88 * and use them when in_interrupt() from linux/preempt_mask.h evaluates to
89 * true.
90 */
91 static DEFINE_PER_CPU(uint64_t[2], spl_pseudo_entropy);
92
93 /*
94 * spl_rand_next()/spl_rand_jump() are copied from the following CC-0 licensed
95 * file:
96 *
97 * http://xorshift.di.unimi.it/xorshift128plus.c
98 */
99
100 static inline uint64_t
101 spl_rand_next(uint64_t *s) {
102 uint64_t s1 = s[0];
103 const uint64_t s0 = s[1];
104 s[0] = s0;
105 s1 ^= s1 << 23; // a
106 s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5); // b, c
107 return (s[1] + s0);
108 }
109
110 static inline void
111 spl_rand_jump(uint64_t *s) {
112 static const uint64_t JUMP[] =
113 { 0x8a5cd789635d2dff, 0x121fd2155c472f96 };
114
115 uint64_t s0 = 0;
116 uint64_t s1 = 0;
117 int i, b;
118 for (i = 0; i < sizeof (JUMP) / sizeof (*JUMP); i++)
119 for (b = 0; b < 64; b++) {
120 if (JUMP[i] & 1ULL << b) {
121 s0 ^= s[0];
122 s1 ^= s[1];
123 }
124 (void) spl_rand_next(s);
125 }
126
127 s[0] = s0;
128 s[1] = s1;
129 }
130
131 int
132 random_get_pseudo_bytes(uint8_t *ptr, size_t len)
133 {
134 uint64_t *xp, s[2];
135
136 ASSERT(ptr);
137
138 xp = get_cpu_var(spl_pseudo_entropy);
139
140 s[0] = xp[0];
141 s[1] = xp[1];
142
143 while (len) {
144 union {
145 uint64_t ui64;
146 uint8_t byte[sizeof (uint64_t)];
147 }entropy;
148 int i = MIN(len, sizeof (uint64_t));
149
150 len -= i;
151 entropy.ui64 = spl_rand_next(s);
152
153 while (i--)
154 *ptr++ = entropy.byte[i];
155 }
156
157 xp[0] = s[0];
158 xp[1] = s[1];
159
160 put_cpu_var(spl_pseudo_entropy);
161
162 return (0);
163 }
164
165
166 EXPORT_SYMBOL(random_get_pseudo_bytes);
167
168 #if BITS_PER_LONG == 32
169 /*
170 * Support 64/64 => 64 division on a 32-bit platform. While the kernel
171 * provides a div64_u64() function for this we do not use it because the
172 * implementation is flawed. There are cases which return incorrect
173 * results as late as linux-2.6.35. Until this is fixed upstream the
174 * spl must provide its own implementation.
175 *
176 * This implementation is a slightly modified version of the algorithm
177 * proposed by the book 'Hacker's Delight'. The original source can be
178 * found here and is available for use without restriction.
179 *
180 * http://www.hackersdelight.org/HDcode/newCode/divDouble.c
181 */
182
183 /*
184 * Calculate number of leading of zeros for a 64-bit value.
185 */
186 static int
187 nlz64(uint64_t x) {
188 register int n = 0;
189
190 if (x == 0)
191 return (64);
192
193 if (x <= 0x00000000FFFFFFFFULL) { n = n + 32; x = x << 32; }
194 if (x <= 0x0000FFFFFFFFFFFFULL) { n = n + 16; x = x << 16; }
195 if (x <= 0x00FFFFFFFFFFFFFFULL) { n = n + 8; x = x << 8; }
196 if (x <= 0x0FFFFFFFFFFFFFFFULL) { n = n + 4; x = x << 4; }
197 if (x <= 0x3FFFFFFFFFFFFFFFULL) { n = n + 2; x = x << 2; }
198 if (x <= 0x7FFFFFFFFFFFFFFFULL) { n = n + 1; }
199
200 return (n);
201 }
202
203 /*
204 * Newer kernels have a div_u64() function but we define our own
205 * to simplify portibility between kernel versions.
206 */
207 static inline uint64_t
208 __div_u64(uint64_t u, uint32_t v)
209 {
210 (void) do_div(u, v);
211 return (u);
212 }
213
214 /*
215 * Implementation of 64-bit unsigned division for 32-bit machines.
216 *
217 * First the procedure takes care of the case in which the divisor is a
218 * 32-bit quantity. There are two subcases: (1) If the left half of the
219 * dividend is less than the divisor, one execution of do_div() is all that
220 * is required (overflow is not possible). (2) Otherwise it does two
221 * divisions, using the grade school method.
222 */
223 uint64_t
224 __udivdi3(uint64_t u, uint64_t v)
225 {
226 uint64_t u0, u1, v1, q0, q1, k;
227 int n;
228
229 if (v >> 32 == 0) { // If v < 2**32:
230 if (u >> 32 < v) { // If u/v cannot overflow,
231 return (__div_u64(u, v)); // just do one division.
232 } else { // If u/v would overflow:
233 u1 = u >> 32; // Break u into two halves.
234 u0 = u & 0xFFFFFFFF;
235 q1 = __div_u64(u1, v); // First quotient digit.
236 k = u1 - q1 * v; // First remainder, < v.
237 u0 += (k << 32);
238 q0 = __div_u64(u0, v); // Seconds quotient digit.
239 return ((q1 << 32) + q0);
240 }
241 } else { // If v >= 2**32:
242 n = nlz64(v); // 0 <= n <= 31.
243 v1 = (v << n) >> 32; // Normalize divisor, MSB is 1.
244 u1 = u >> 1; // To ensure no overflow.
245 q1 = __div_u64(u1, v1); // Get quotient from
246 q0 = (q1 << n) >> 31; // Undo normalization and
247 // division of u by 2.
248 if (q0 != 0) // Make q0 correct or
249 q0 = q0 - 1; // too small by 1.
250 if ((u - q0 * v) >= v)
251 q0 = q0 + 1; // Now q0 is correct.
252
253 return (q0);
254 }
255 }
256 EXPORT_SYMBOL(__udivdi3);
257
258 /*
259 * Implementation of 64-bit signed division for 32-bit machines.
260 */
261 int64_t
262 __divdi3(int64_t u, int64_t v)
263 {
264 int64_t q, t;
265 q = __udivdi3(abs64(u), abs64(v));
266 t = (u ^ v) >> 63; // If u, v have different
267 return ((q ^ t) - t); // signs, negate q.
268 }
269 EXPORT_SYMBOL(__divdi3);
270
271 /*
272 * Implementation of 64-bit unsigned modulo for 32-bit machines.
273 */
274 uint64_t
275 __umoddi3(uint64_t dividend, uint64_t divisor)
276 {
277 return (dividend - (divisor * __udivdi3(dividend, divisor)));
278 }
279 EXPORT_SYMBOL(__umoddi3);
280
281 /*
282 * Implementation of 64-bit unsigned division/modulo for 32-bit machines.
283 */
284 uint64_t
285 __udivmoddi4(uint64_t n, uint64_t d, uint64_t *r)
286 {
287 uint64_t q = __udivdi3(n, d);
288 if (r)
289 *r = n - d * q;
290 return (q);
291 }
292 EXPORT_SYMBOL(__udivmoddi4);
293
294 /*
295 * Implementation of 64-bit signed division/modulo for 32-bit machines.
296 */
297 int64_t
298 __divmoddi4(int64_t n, int64_t d, int64_t *r)
299 {
300 int64_t q, rr;
301 boolean_t nn = B_FALSE;
302 boolean_t nd = B_FALSE;
303 if (n < 0) {
304 nn = B_TRUE;
305 n = -n;
306 }
307 if (d < 0) {
308 nd = B_TRUE;
309 d = -d;
310 }
311
312 q = __udivmoddi4(n, d, (uint64_t *)&rr);
313
314 if (nn != nd)
315 q = -q;
316 if (nn)
317 rr = -rr;
318 if (r)
319 *r = rr;
320 return (q);
321 }
322 EXPORT_SYMBOL(__divmoddi4);
323
324 #if defined(__arm) || defined(__arm__)
325 /*
326 * Implementation of 64-bit (un)signed division for 32-bit arm machines.
327 *
328 * Run-time ABI for the ARM Architecture (page 20). A pair of (unsigned)
329 * long longs is returned in {{r0, r1}, {r2,r3}}, the quotient in {r0, r1},
330 * and the remainder in {r2, r3}. The return type is specifically left
331 * set to 'void' to ensure the compiler does not overwrite these registers
332 * during the return. All results are in registers as per ABI
333 */
334 void
335 __aeabi_uldivmod(uint64_t u, uint64_t v)
336 {
337 uint64_t res;
338 uint64_t mod;
339
340 res = __udivdi3(u, v);
341 mod = __umoddi3(u, v);
342 {
343 register uint32_t r0 asm("r0") = (res & 0xFFFFFFFF);
344 register uint32_t r1 asm("r1") = (res >> 32);
345 register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF);
346 register uint32_t r3 asm("r3") = (mod >> 32);
347
348 /* BEGIN CSTYLED */
349 asm volatile(""
350 : "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
351 : "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
352 /* END CSTYLED */
353
354 return; /* r0; */
355 }
356 }
357 EXPORT_SYMBOL(__aeabi_uldivmod);
358
359 void
360 __aeabi_ldivmod(int64_t u, int64_t v)
361 {
362 int64_t res;
363 uint64_t mod;
364
365 res = __divdi3(u, v);
366 mod = __umoddi3(u, v);
367 {
368 register uint32_t r0 asm("r0") = (res & 0xFFFFFFFF);
369 register uint32_t r1 asm("r1") = (res >> 32);
370 register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF);
371 register uint32_t r3 asm("r3") = (mod >> 32);
372
373 /* BEGIN CSTYLED */
374 asm volatile(""
375 : "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
376 : "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
377 /* END CSTYLED */
378
379 return; /* r0; */
380 }
381 }
382 EXPORT_SYMBOL(__aeabi_ldivmod);
383 #endif /* __arm || __arm__ */
384 #endif /* BITS_PER_LONG */
385
386 /*
387 * NOTE: The strtoxx behavior is solely based on my reading of the Solaris
388 * ddi_strtol(9F) man page. I have not verified the behavior of these
389 * functions against their Solaris counterparts. It is possible that I
390 * may have misinterpreted the man page or the man page is incorrect.
391 */
392 int ddi_strtoul(const char *, char **, int, unsigned long *);
393 int ddi_strtol(const char *, char **, int, long *);
394 int ddi_strtoull(const char *, char **, int, unsigned long long *);
395 int ddi_strtoll(const char *, char **, int, long long *);
396
397 #define define_ddi_strtoux(type, valtype) \
398 int ddi_strtou##type(const char *str, char **endptr, \
399 int base, valtype *result) \
400 { \
401 valtype last_value, value = 0; \
402 char *ptr = (char *)str; \
403 int flag = 1, digit; \
404 \
405 if (strlen(ptr) == 0) \
406 return (EINVAL); \
407 \
408 /* Auto-detect base based on prefix */ \
409 if (!base) { \
410 if (str[0] == '0') { \
411 if (tolower(str[1]) == 'x' && isxdigit(str[2])) { \
412 base = 16; /* hex */ \
413 ptr += 2; \
414 } else if (str[1] >= '0' && str[1] < 8) { \
415 base = 8; /* octal */ \
416 ptr += 1; \
417 } else { \
418 return (EINVAL); \
419 } \
420 } else { \
421 base = 10; /* decimal */ \
422 } \
423 } \
424 \
425 while (1) { \
426 if (isdigit(*ptr)) \
427 digit = *ptr - '0'; \
428 else if (isalpha(*ptr)) \
429 digit = tolower(*ptr) - 'a' + 10; \
430 else \
431 break; \
432 \
433 if (digit >= base) \
434 break; \
435 \
436 last_value = value; \
437 value = value * base + digit; \
438 if (last_value > value) /* Overflow */ \
439 return (ERANGE); \
440 \
441 flag = 1; \
442 ptr++; \
443 } \
444 \
445 if (flag) \
446 *result = value; \
447 \
448 if (endptr) \
449 *endptr = (char *)(flag ? ptr : str); \
450 \
451 return (0); \
452 } \
453
454 #define define_ddi_strtox(type, valtype) \
455 int ddi_strto##type(const char *str, char **endptr, \
456 int base, valtype *result) \
457 { \
458 int rc; \
459 \
460 if (*str == '-') { \
461 rc = ddi_strtou##type(str + 1, endptr, base, result); \
462 if (!rc) { \
463 if (*endptr == str + 1) \
464 *endptr = (char *)str; \
465 else \
466 *result = -*result; \
467 } \
468 } else { \
469 rc = ddi_strtou##type(str, endptr, base, result); \
470 } \
471 \
472 return (rc); \
473 }
474
475 define_ddi_strtoux(l, unsigned long)
476 define_ddi_strtox(l, long)
477 define_ddi_strtoux(ll, unsigned long long)
478 define_ddi_strtox(ll, long long)
479
480 EXPORT_SYMBOL(ddi_strtoul);
481 EXPORT_SYMBOL(ddi_strtol);
482 EXPORT_SYMBOL(ddi_strtoll);
483 EXPORT_SYMBOL(ddi_strtoull);
484
485 int
486 ddi_copyin(const void *from, void *to, size_t len, int flags)
487 {
488 /* Fake ioctl() issued by kernel, 'from' is a kernel address */
489 if (flags & FKIOCTL) {
490 memcpy(to, from, len);
491 return (0);
492 }
493
494 return (copyin(from, to, len));
495 }
496 EXPORT_SYMBOL(ddi_copyin);
497
498 int
499 ddi_copyout(const void *from, void *to, size_t len, int flags)
500 {
501 /* Fake ioctl() issued by kernel, 'from' is a kernel address */
502 if (flags & FKIOCTL) {
503 memcpy(to, from, len);
504 return (0);
505 }
506
507 return (copyout(from, to, len));
508 }
509 EXPORT_SYMBOL(ddi_copyout);
510
511 /*
512 * Read the unique system identifier from the /etc/hostid file.
513 *
514 * The behavior of /usr/bin/hostid on Linux systems with the
515 * regular eglibc and coreutils is:
516 *
517 * 1. Generate the value if the /etc/hostid file does not exist
518 * or if the /etc/hostid file is less than four bytes in size.
519 *
520 * 2. If the /etc/hostid file is at least 4 bytes, then return
521 * the first four bytes [0..3] in native endian order.
522 *
523 * 3. Always ignore bytes [4..] if they exist in the file.
524 *
525 * Only the first four bytes are significant, even on systems that
526 * have a 64-bit word size.
527 *
528 * See:
529 *
530 * eglibc: sysdeps/unix/sysv/linux/gethostid.c
531 * coreutils: src/hostid.c
532 *
533 * Notes:
534 *
535 * The /etc/hostid file on Solaris is a text file that often reads:
536 *
537 * # DO NOT EDIT
538 * "0123456789"
539 *
540 * Directly copying this file to Linux results in a constant
541 * hostid of 4f442023 because the default comment constitutes
542 * the first four bytes of the file.
543 *
544 */
545
546 char *spl_hostid_path = HW_HOSTID_PATH;
547 module_param(spl_hostid_path, charp, 0444);
548 MODULE_PARM_DESC(spl_hostid_path, "The system hostid file (/etc/hostid)");
549
550 static int
551 hostid_read(uint32_t *hostid)
552 {
553 uint64_t size;
554 struct _buf *file;
555 uint32_t value = 0;
556 int error;
557
558 file = kobj_open_file(spl_hostid_path);
559 if (file == (struct _buf *)-1)
560 return (ENOENT);
561
562 error = kobj_get_filesize(file, &size);
563 if (error) {
564 kobj_close_file(file);
565 return (error);
566 }
567
568 if (size < sizeof (HW_HOSTID_MASK)) {
569 kobj_close_file(file);
570 return (EINVAL);
571 }
572
573 /*
574 * Read directly into the variable like eglibc does.
575 * Short reads are okay; native behavior is preserved.
576 */
577 error = kobj_read_file(file, (char *)&value, sizeof (value), 0);
578 if (error < 0) {
579 kobj_close_file(file);
580 return (EIO);
581 }
582
583 /* Mask down to 32 bits like coreutils does. */
584 *hostid = (value & HW_HOSTID_MASK);
585 kobj_close_file(file);
586
587 return (0);
588 }
589
590 /*
591 * Return the system hostid. Preferentially use the spl_hostid module option
592 * when set, otherwise use the value in the /etc/hostid file.
593 */
594 uint32_t
595 zone_get_hostid(void *zone)
596 {
597 uint32_t hostid;
598
599 ASSERT3P(zone, ==, NULL);
600
601 if (spl_hostid != 0)
602 return ((uint32_t)(spl_hostid & HW_HOSTID_MASK));
603
604 if (hostid_read(&hostid) == 0)
605 return (hostid);
606
607 return (0);
608 }
609 EXPORT_SYMBOL(zone_get_hostid);
610
611 static int
612 spl_kvmem_init(void)
613 {
614 int rc = 0;
615
616 rc = spl_kmem_init();
617 if (rc)
618 return (rc);
619
620 rc = spl_vmem_init();
621 if (rc) {
622 spl_kmem_fini();
623 return (rc);
624 }
625
626 return (rc);
627 }
628
629 /*
630 * We initialize the random number generator with 128 bits of entropy from the
631 * system random number generator. In the improbable case that we have a zero
632 * seed, we fallback to the system jiffies, unless it is also zero, in which
633 * situation we use a preprogrammed seed. We step forward by 2^64 iterations to
634 * initialize each of the per-cpu seeds so that the sequences generated on each
635 * CPU are guaranteed to never overlap in practice.
636 */
637 static void __init
638 spl_random_init(void)
639 {
640 uint64_t s[2];
641 int i;
642
643 get_random_bytes(s, sizeof (s));
644
645 if (s[0] == 0 && s[1] == 0) {
646 if (jiffies != 0) {
647 s[0] = jiffies;
648 s[1] = ~0 - jiffies;
649 } else {
650 (void) memcpy(s, "improbable seed", sizeof (s));
651 }
652 printk("SPL: get_random_bytes() returned 0 "
653 "when generating random seed. Setting initial seed to "
654 "0x%016llx%016llx.", cpu_to_be64(s[0]), cpu_to_be64(s[1]));
655 }
656
657 for_each_possible_cpu(i) {
658 uint64_t *wordp = per_cpu(spl_pseudo_entropy, i);
659
660 spl_rand_jump(s);
661
662 wordp[0] = s[0];
663 wordp[1] = s[1];
664 }
665 }
666
667 static void
668 spl_kvmem_fini(void)
669 {
670 spl_vmem_fini();
671 spl_kmem_fini();
672 }
673
674 static int __init
675 spl_init(void)
676 {
677 int rc = 0;
678
679 bzero(&p0, sizeof (proc_t));
680 spl_random_init();
681
682 if ((rc = spl_kvmem_init()))
683 goto out1;
684
685 if ((rc = spl_mutex_init()))
686 goto out2;
687
688 if ((rc = spl_rw_init()))
689 goto out3;
690
691 if ((rc = spl_tsd_init()))
692 goto out4;
693
694 if ((rc = spl_taskq_init()))
695 goto out5;
696
697 if ((rc = spl_kmem_cache_init()))
698 goto out6;
699
700 if ((rc = spl_vn_init()))
701 goto out7;
702
703 if ((rc = spl_proc_init()))
704 goto out8;
705
706 if ((rc = spl_kstat_init()))
707 goto out9;
708
709 if ((rc = spl_zlib_init()))
710 goto out10;
711
712 printk(KERN_NOTICE "SPL: Loaded module v%s-%s%s\n", SPL_META_VERSION,
713 SPL_META_RELEASE, SPL_DEBUG_STR);
714 return (rc);
715
716 out10:
717 spl_kstat_fini();
718 out9:
719 spl_proc_fini();
720 out8:
721 spl_vn_fini();
722 out7:
723 spl_kmem_cache_fini();
724 out6:
725 spl_taskq_fini();
726 out5:
727 spl_tsd_fini();
728 out4:
729 spl_rw_fini();
730 out3:
731 spl_mutex_fini();
732 out2:
733 spl_kvmem_fini();
734 out1:
735 printk(KERN_NOTICE "SPL: Failed to Load Solaris Porting Layer "
736 "v%s-%s%s, rc = %d\n", SPL_META_VERSION, SPL_META_RELEASE,
737 SPL_DEBUG_STR, rc);
738
739 return (rc);
740 }
741
742 static void __exit
743 spl_fini(void)
744 {
745 printk(KERN_NOTICE "SPL: Unloaded module v%s-%s%s\n",
746 SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR);
747 spl_zlib_fini();
748 spl_kstat_fini();
749 spl_proc_fini();
750 spl_vn_fini();
751 spl_kmem_cache_fini();
752 spl_taskq_fini();
753 spl_tsd_fini();
754 spl_rw_fini();
755 spl_mutex_fini();
756 spl_kvmem_fini();
757 }
758
759 module_init(spl_init);
760 module_exit(spl_fini);
761
762 MODULE_DESCRIPTION("Solaris Porting Layer");
763 MODULE_AUTHOR(SPL_META_AUTHOR);
764 MODULE_LICENSE(SPL_META_LICENSE);
765 MODULE_VERSION(SPL_META_VERSION "-" SPL_META_RELEASE);