3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Joyent, Inc.
24 */
25
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <sys/sysmacros.h>
29 #include <sys/kmem.h>
30 #include <sys/time.h>
31 #include <sys/pathname.h>
32 #include <sys/vfs.h>
33 #include <sys/vfs_opreg.h>
34 #include <sys/vnode.h>
35 #include <sys/stat.h>
36 #include <sys/uio.h>
37 #include <sys/stat.h>
38 #include <sys/errno.h>
39 #include <sys/cmn_err.h>
40 #include <sys/cred.h>
41 #include <sys/statvfs.h>
42 #include <sys/mount.h>
140 return (mod_info(&modlinkage, modinfop));
141 }
142
143 /*
144 * The following are patchable variables limiting the amount of system
145 * resources tmpfs can use.
146 *
147 * tmpfs_maxkmem limits the amount of kernel kmem_alloc memory
148 * tmpfs can use for it's data structures (e.g. tmpnodes, directory entries)
149 * It is not determined by setting a hard limit but rather as a percentage of
150 * physical memory which is determined when tmpfs is first used in the system.
151 *
152 * tmpfs_minfree is the minimum amount of swap space that tmpfs leaves for
153 * the rest of the system. In other words, if the amount of free swap space
154 * in the system (i.e. anoninfo.ani_free) drops below tmpfs_minfree, tmpfs
155 * anon allocations will fail.
156 *
157 * There is also a per mount limit on the amount of swap space
158 * (tmount.tm_anonmax) settable via a mount option.
159 */
160 size_t tmpfs_maxkmem = 0;
161 size_t tmpfs_minfree = 0;
162 size_t tmp_kmemspace; /* bytes of kernel heap used by all tmpfs */
163
164 static major_t tmpfs_major;
165 static minor_t tmpfs_minor;
166 static kmutex_t tmpfs_minor_lock;
167
168 /*
169 * initialize global tmpfs locks and such
170 * called when loading tmpfs module
171 */
172 static int
173 tmpfsinit(int fstype, char *name)
174 {
175 static const fs_operation_def_t tmp_vfsops_template[] = {
176 VFSNAME_MOUNT, { .vfs_mount = tmp_mount },
177 VFSNAME_UNMOUNT, { .vfs_unmount = tmp_unmount },
178 VFSNAME_ROOT, { .vfs_root = tmp_root },
179 VFSNAME_STATVFS, { .vfs_statvfs = tmp_statvfs },
180 VFSNAME_VGET, { .vfs_vget = tmp_vget },
181 NULL, NULL
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2015 Joyent, Inc.
25 */
26
27 #include <sys/types.h>
28 #include <sys/param.h>
29 #include <sys/sysmacros.h>
30 #include <sys/kmem.h>
31 #include <sys/time.h>
32 #include <sys/pathname.h>
33 #include <sys/vfs.h>
34 #include <sys/vfs_opreg.h>
35 #include <sys/vnode.h>
36 #include <sys/stat.h>
37 #include <sys/uio.h>
38 #include <sys/stat.h>
39 #include <sys/errno.h>
40 #include <sys/cmn_err.h>
41 #include <sys/cred.h>
42 #include <sys/statvfs.h>
43 #include <sys/mount.h>
141 return (mod_info(&modlinkage, modinfop));
142 }
143
144 /*
145 * The following are patchable variables limiting the amount of system
146 * resources tmpfs can use.
147 *
148 * tmpfs_maxkmem limits the amount of kernel kmem_alloc memory
149 * tmpfs can use for it's data structures (e.g. tmpnodes, directory entries)
150 * It is not determined by setting a hard limit but rather as a percentage of
151 * physical memory which is determined when tmpfs is first used in the system.
152 *
153 * tmpfs_minfree is the minimum amount of swap space that tmpfs leaves for
154 * the rest of the system. In other words, if the amount of free swap space
155 * in the system (i.e. anoninfo.ani_free) drops below tmpfs_minfree, tmpfs
156 * anon allocations will fail.
157 *
158 * There is also a per mount limit on the amount of swap space
159 * (tmount.tm_anonmax) settable via a mount option.
160 */
161 volatile size_t tmpfs_maxkmem = 0;
162 volatile size_t tmpfs_minfree = 0;
163 size_t tmp_kmemspace; /* bytes of kernel heap used by all tmpfs */
164
165 static major_t tmpfs_major;
166 static minor_t tmpfs_minor;
167 static kmutex_t tmpfs_minor_lock;
168
169 /*
170 * initialize global tmpfs locks and such
171 * called when loading tmpfs module
172 */
173 static int
174 tmpfsinit(int fstype, char *name)
175 {
176 static const fs_operation_def_t tmp_vfsops_template[] = {
177 VFSNAME_MOUNT, { .vfs_mount = tmp_mount },
178 VFSNAME_UNMOUNT, { .vfs_unmount = tmp_unmount },
179 VFSNAME_ROOT, { .vfs_root = tmp_root },
180 VFSNAME_STATVFS, { .vfs_statvfs = tmp_statvfs },
181 VFSNAME_VGET, { .vfs_vget = tmp_vget },
182 NULL, NULL
|