Print this page
XXXX give me a better summary

@@ -18,10 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
  */
 
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*        All Rights Reserved   */
 

@@ -132,11 +133,12 @@
  * swap device. Flags are one of:
  *      SA_NOT  Must have a slot from a physical swap device other than the
  *              the one containing input (*vpp, *offp).
  * Less slots than requested may be returned. *lenp allocated slots are
  * returned starting at *offp on *vpp.
- * Returns 1 for a successful allocation, 0 for couldn't allocate any slots.
+ * Returns 1 for a successful allocation, 0 for couldn't allocate any slots,
+ * and -1 when there are no swap devices on this system.
  */
 int
 swap_phys_alloc(
         struct vnode **vpp,
         u_offset_t *offp,

@@ -146,10 +148,15 @@
         struct swapinfo *sip;
         offset_t soff, noff;
         size_t len;
 
         mutex_enter(&swapinfo_lock);
+        if (swapinfo == NULL) {
+                /* NO SWAP DEVICES on this system currently. */
+                mutex_exit(&swapinfo_lock);
+                return (-1);
+        }
         sip = silast;
 
         /* Find a desirable physical device and allocate from it. */
         do {
                 if (sip == NULL)

@@ -1656,10 +1663,11 @@
  * backed as [*offp, *offp + *lenp) and the physical offsets used to
  * back them from *pvpp in the range [*pstartp, *pstartp + *lenp).
  * Returns      0 for success
  *              SE_NOANON -- no anon slot for requested paged
  *              SE_NOSWAP -- no physical swap space available
+ *              SE_NODEV -- no swap devices on this system
  */
 int
 swap_newphysname(
         struct vnode *vp,
         u_offset_t offset,

@@ -1678,11 +1686,12 @@
 
         ASSERT(*offp <= offset && offset < *offp + *lenp);
 
         /* Get new physical swap slots. */
         plen = *lenp;
-        if (!swap_phys_alloc(&pvp, &pstart, &plen, 0)) {
+        error = swap_phys_alloc(&pvp, &pstart, &plen, 0);
+        if (error != 1) {
                 /*
                  * No swap available so return error unless requested
                  * offset is already backed in which case return that.
                  */
                 ahm = AH_MUTEX(vp, offset);

@@ -1690,11 +1699,11 @@
                 if ((ap = swap_anon(vp, offset)) == NULL) {
                         error = SE_NOANON;
                         mutex_exit(ahm);
                         return (error);
                 }
-                error = (ap->an_pvp ? 0 : SE_NOSWAP);
+                error = (ap->an_pvp ? 0 : (error == 0) ? SE_NOSWAP : SE_NODEV);
                 *offp = offset;
                 *lenp = PAGESIZE;
                 *pvpp = ap->an_pvp;
                 *poffp = ap->an_poff;
                 mutex_exit(ahm);