]> git.proxmox.com Git - mirror_spl.git/blob - module/spl/spl-vmem.c
e177988a7e2d06a509c1815058fc701e89914307
[mirror_spl.git] / module / spl / spl-vmem.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
25 #include <sys/debug.h>
26 #include <sys/vmem.h>
27 #include <linux/mm_compat.h>
28 #include <linux/module.h>
29
30 vmem_t *heap_arena = NULL;
31 EXPORT_SYMBOL(heap_arena);
32
33 vmem_t *zio_alloc_arena = NULL;
34 EXPORT_SYMBOL(zio_alloc_arena);
35
36 vmem_t *zio_arena = NULL;
37 EXPORT_SYMBOL(zio_arena);
38
39 size_t
40 vmem_size(vmem_t *vmp, int typemask)
41 {
42 ASSERT3P(vmp, ==, NULL);
43 ASSERT3S(typemask & VMEM_ALLOC, ==, VMEM_ALLOC);
44 ASSERT3S(typemask & VMEM_FREE, ==, VMEM_FREE);
45
46 return (VMALLOC_TOTAL);
47 }
48 EXPORT_SYMBOL(vmem_size);
49
50 /*
51 * Public vmem_alloc(), vmem_zalloc() and vmem_free() interfaces.
52 */
53 void *
54 spl_vmem_alloc(size_t size, int flags, const char *func, int line)
55 {
56 ASSERT0(flags & ~KM_PUBLIC_MASK);
57
58 flags |= KM_VMEM;
59
60 #if !defined(DEBUG_KMEM)
61 return (spl_kmem_alloc_impl(size, flags, NUMA_NO_NODE));
62 #elif !defined(DEBUG_KMEM_TRACKING)
63 return (spl_kmem_alloc_debug(size, flags, NUMA_NO_NODE));
64 #else
65 return (spl_kmem_alloc_track(size, flags, func, line, NUMA_NO_NODE));
66 #endif
67 }
68 EXPORT_SYMBOL(spl_vmem_alloc);
69
70 void *
71 spl_vmem_zalloc(size_t size, int flags, const char *func, int line)
72 {
73 ASSERT0(flags & ~KM_PUBLIC_MASK);
74
75 flags |= (KM_VMEM | KM_ZERO);
76
77 #if !defined(DEBUG_KMEM)
78 return (spl_kmem_alloc_impl(size, flags, NUMA_NO_NODE));
79 #elif !defined(DEBUG_KMEM_TRACKING)
80 return (spl_kmem_alloc_debug(size, flags, NUMA_NO_NODE));
81 #else
82 return (spl_kmem_alloc_track(size, flags, func, line, NUMA_NO_NODE));
83 #endif
84 }
85 EXPORT_SYMBOL(spl_vmem_zalloc);
86
87 void
88 spl_vmem_free(const void *buf, size_t size)
89 {
90 #if !defined(DEBUG_KMEM)
91 return (spl_kmem_free_impl(buf, size));
92 #elif !defined(DEBUG_KMEM_TRACKING)
93 return (spl_kmem_free_debug(buf, size));
94 #else
95 return (spl_kmem_free_track(buf, size));
96 #endif
97 }
98 EXPORT_SYMBOL(spl_vmem_free);
99
100 int
101 spl_vmem_init(void)
102 {
103 return (0);
104 }
105
106 void
107 spl_vmem_fini(void)
108 {
109 }