/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/vfs_opreg.h>
#include <sys/sysmacros.h>
#include <sys/mem_config.h>
extern const fs_operation_def_t swap_vnodeops_template[];
/*
* swapfs_minfree is the amount of physical memory (actually remaining
* availrmem) that we want to keep free for the rest of the system. This
* means that swapfs can only grow to availrmem - swapfs_minfree. This
* can be set as just constant value or a certain percentage of installed
* physical memory. It is set in swapinit().
*
* Users who want to change the amount of memory that can be used as swap
* space should do so by setting swapfs_desfree at boot time,
* not swapfs_minfree.
*/
#ifdef SWAPFS_DEBUG
int swapfs_debug;
#endif /* SWAPFS_DEBUG */
static int swapfs_vpcount;
static void swap_init_mem_config(void);
static void
{
}
static int
{
if (new_swapfs_desfree == 0)
if (new_swapfs_minfree == 0) {
/*
* We set this lower than we'd like here, 2Mb, because we
* always boot on swapfs. It's up to a safer value,
* in swapadd(). Users who want to change the amount of
* memory that can be used as swap space should do so by
* setting swapfs_desfree at boot time, not swapfs_minfree.
* However, swapfs_minfree is tunable by install as a
* workaround for bugid 1147463.
*/
}
/*
* priv processes can reserve memory as swap as long as availrmem
* remains greater than swapfs_minfree; in the case of non-priv
* processes, memory can be reserved as swap only if availrmem
* doesn't fall below (swapfs_minfree + swapfs_reserve). Thus,
* swapfs_reserve amount of memswap is not available to non-priv
* processes. This protects daemons such as automounter dying
* as a result of application processes eating away almost entire
* membased swap. This safeguard becomes useless if apps are run
* with root access.
*
* set swapfs_reserve to a minimum of 4Mb or 1/128 of physmem whichever
* is greater up to the limit of 128 MB.
*/
if (new_swapfs_reserve == 0)
/* Test basic numeric viability. */
if (new_swapfs_minfree > pgs)
return (0);
/* Equivalent test to anon_resvmem() check. */
if (availrmem < new_swapfs_minfree) {
/*
* If ism pages are being used, then there must be agreement
* between these two policies.
*/
} else {
return (0);
}
}
return (1);
}
/*ARGSUSED1*/
int
{ /* reserve for mp */
int i, error;
};
KM_SLEEP);
if (!swapfs_recalc(physmem))
/*
* Arrange for a callback on memory size change.
*/
sw_ar = (struct async_reqs *)
if (error != 0) {
return (error);
}
if (error != 0) {
(void) vfs_freevfsops_by_type(fstype);
return (error);
}
sw_freelist = sw_ar;
for (i = 0; i < sw_freelist_size - 1; i++)
return (0);
}
/*
* Get a swapfs vnode corresponding to the specified identifier.
*/
struct vnode *
{
if (vp) {
return (vp);
}
}
return (vp);
}
int swap_lo;
/*ARGSUSED*/
static int
{
int i;
return (1);
/*
* assumes that we are the only one left to access this so that
* no need to use swapfs_lock (since it's staticly defined)
*/
for (i = 0; i < MAX_SWAP_VNODES; i++) {
vp = swap_vnodes[i];
if (vp) {
}
}
return (0);
}
extern int sw_pending_size;
/*
* Take an async request off the pending queue
*/
struct async_reqs *
{
arg = sw_pendlist;
if (arg) {
}
ASSERT(sw_pending_size >= 0);
return (arg);
}
/*
* Put an async request on the pending queue
*/
void
{
/* Hold onto it */
sw_pendlist = arg;
}
/*
* Put an async request back on the pending queue
*/
void
{
sw_pendlist = arg;
}
/*
* Take an async request structure off the free list
*/
struct async_reqs *
{
arg = sw_freelist;
if (arg) {
}
return (arg);
}
/*
* Put an async request structure on the free list
*/
void
{
/* Release our hold - should have locked the page by now */
sw_freelist = arg;
}
/*ARGSUSED*/
static void
void *arg,
{
}
/*ARGSUSED*/
static int
void *arg,
{
/*
* Tidy-up is done by the call to post_del which
* is always made.
*/
"doesn't deadlock due to excessive consumption by swapfs.");
return (EBUSY);
}
return (0);
}
/*ARGSUSED*/
static void
void *arg,
int cancelled)
{
}
};
static void
swap_init_mem_config(void)
{
int ret;
}