Print this page
XXXX give me a better summary

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/vm/vm_swap.c
          +++ new/usr/src/uts/common/vm/vm_swap.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
  23   24   */
  24   25  
  25   26  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  26   27  /*        All Rights Reserved   */
  27   28  
  28   29  /*
  29   30   * University Copyright- Copyright (c) 1982, 1986, 1988
  30   31   * The Regents of the University of California
  31   32   * All Rights Reserved
  32   33   *
↓ open down ↓ 94 lines elided ↑ open up ↑
 127  128  
 128  129  uint_t swapalloc_maxcontig;
 129  130  
 130  131  /*
 131  132   * Allocate a range of up to *lenp contiguous slots (page) from a physical
 132  133   * swap device. Flags are one of:
 133  134   *      SA_NOT  Must have a slot from a physical swap device other than the
 134  135   *              the one containing input (*vpp, *offp).
 135  136   * Less slots than requested may be returned. *lenp allocated slots are
 136  137   * returned starting at *offp on *vpp.
 137      - * Returns 1 for a successful allocation, 0 for couldn't allocate any slots.
      138 + * Returns 1 for a successful allocation, 0 for couldn't allocate any slots,
      139 + * and -1 when there are no swap devices on this system.
 138  140   */
 139  141  int
 140  142  swap_phys_alloc(
 141  143          struct vnode **vpp,
 142  144          u_offset_t *offp,
 143  145          size_t *lenp,
 144  146          uint_t flags)
 145  147  {
 146  148          struct swapinfo *sip;
 147  149          offset_t soff, noff;
 148  150          size_t len;
 149  151  
 150  152          mutex_enter(&swapinfo_lock);
      153 +        if (swapinfo == NULL) {
      154 +                /* NO SWAP DEVICES on this system currently. */
      155 +                mutex_exit(&swapinfo_lock);
      156 +                return (-1);
      157 +        }
 151  158          sip = silast;
 152  159  
 153  160          /* Find a desirable physical device and allocate from it. */
 154  161          do {
 155  162                  if (sip == NULL)
 156  163                          break;
 157  164                  if (!(sip->si_flags & ST_INDEL) &&
 158  165                      (spgcnt_t)sip->si_nfpgs > 0) {
 159  166                          /* Caller wants other than specified swap device */
 160  167                          if (flags & SA_NOT) {
↓ open down ↓ 1490 lines elided ↑ open up ↑
1651 1658  
1652 1659  /*
1653 1660   * Get contig physical backing store for vp, in the range
1654 1661   * [*offp, *offp + *lenp), May back a subrange of this, but must
1655 1662   * always include the requested offset or fail. Returns the offsets
1656 1663   * backed as [*offp, *offp + *lenp) and the physical offsets used to
1657 1664   * back them from *pvpp in the range [*pstartp, *pstartp + *lenp).
1658 1665   * Returns      0 for success
1659 1666   *              SE_NOANON -- no anon slot for requested paged
1660 1667   *              SE_NOSWAP -- no physical swap space available
     1668 + *              SE_NODEV -- no swap devices on this system
1661 1669   */
1662 1670  int
1663 1671  swap_newphysname(
1664 1672          struct vnode *vp,
1665 1673          u_offset_t offset,
1666 1674          u_offset_t *offp,
1667 1675          size_t *lenp,
1668 1676          struct vnode **pvpp,
1669 1677          u_offset_t *poffp)
1670 1678  {
↓ open down ↓ 2 lines elided ↑ open up ↑
1673 1681          struct vnode *pvp;
1674 1682          u_offset_t poff, pstart, prem;
1675 1683          size_t plen;
1676 1684          u_offset_t off, start;
1677 1685          kmutex_t *ahm;
1678 1686  
1679 1687          ASSERT(*offp <= offset && offset < *offp + *lenp);
1680 1688  
1681 1689          /* Get new physical swap slots. */
1682 1690          plen = *lenp;
1683      -        if (!swap_phys_alloc(&pvp, &pstart, &plen, 0)) {
     1691 +        error = swap_phys_alloc(&pvp, &pstart, &plen, 0);
     1692 +        if (error != 1) {
1684 1693                  /*
1685 1694                   * No swap available so return error unless requested
1686 1695                   * offset is already backed in which case return that.
1687 1696                   */
1688 1697                  ahm = AH_MUTEX(vp, offset);
1689 1698                  mutex_enter(ahm);
1690 1699                  if ((ap = swap_anon(vp, offset)) == NULL) {
1691 1700                          error = SE_NOANON;
1692 1701                          mutex_exit(ahm);
1693 1702                          return (error);
1694 1703                  }
1695      -                error = (ap->an_pvp ? 0 : SE_NOSWAP);
     1704 +                error = (ap->an_pvp ? 0 : (error == 0) ? SE_NOSWAP : SE_NODEV);
1696 1705                  *offp = offset;
1697 1706                  *lenp = PAGESIZE;
1698 1707                  *pvpp = ap->an_pvp;
1699 1708                  *poffp = ap->an_poff;
1700 1709                  mutex_exit(ahm);
1701 1710                  return (error);
1702 1711          }
1703 1712  
1704 1713          /*
1705 1714           * We got plen (<= *lenp) contig slots. Use these to back a
↓ open down ↓ 95 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX