Print this page
5382 pvn_getpages handles lengths <= PAGESIZE just fine


   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 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.

  25  */
  26 
  27 /*
  28  * Vnode operations for the High Sierra filesystem
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/t_lock.h>
  33 #include <sys/param.h>
  34 #include <sys/time.h>
  35 #include <sys/systm.h>
  36 #include <sys/sysmacros.h>
  37 #include <sys/resource.h>
  38 #include <sys/signal.h>
  39 #include <sys/cred.h>
  40 #include <sys/user.h>
  41 #include <sys/buf.h>
  42 #include <sys/vfs.h>
  43 #include <sys/vfs_opreg.h>
  44 #include <sys/stat.h>


1558         }
1559 
1560         return (err);
1561 }
1562 
1563 /*ARGSUSED*/
1564 static int
1565 hsfs_getpage(
1566         struct vnode *vp,
1567         offset_t off,
1568         size_t len,
1569         uint_t *protp,
1570         struct page *pl[],
1571         size_t plsz,
1572         struct seg *seg,
1573         caddr_t addr,
1574         enum seg_rw rw,
1575         struct cred *cred,
1576         caller_context_t *ct)
1577 {
1578         int err;
1579         uint_t filsiz;
1580         struct hsfs *fsp;
1581         struct hsnode *hp;
1582 
1583         fsp = VFS_TO_HSFS(vp->v_vfsp);
1584         hp = VTOH(vp);
1585 
1586         /* does not support write */
1587         if (rw == S_WRITE) {
1588                 return (EROFS);
1589         }
1590 
1591         if (vp->v_flag & VNOMAP) {
1592                 return (ENOSYS);
1593         }
1594 
1595         ASSERT(off <= HS_MAXFILEOFF);
1596 
1597         /*
1598          * Determine file data size for EOF check.


1636                          */
1637                         if (hp->hs_ra_bytes > 0)
1638                                 hp->hs_ra_bytes -= PAGESIZE;
1639 
1640                         if (hp->hs_ra_bytes <= 0) {
1641                                 hp->hs_ra_bytes = 0;
1642                                 if (hp->hs_num_contig > 0)
1643                                         hp->hs_num_contig--;
1644                         }
1645                 }
1646                 /*
1647                  * Length must be rounded up to page boundary.
1648                  * since we read in units of pages.
1649                  */
1650                 hp->hs_prev_offset = off + roundup(len, PAGESIZE);
1651                 DTRACE_PROBE1(hsfs_compute_ra, struct hsnode *, hp);
1652         }
1653         if (protp != NULL)
1654                 *protp = PROT_ALL;
1655 
1656         if (len <= PAGESIZE)
1657                 err = hsfs_getapage(vp, (u_offset_t)off, len, protp, pl, plsz,
1658                     seg, addr, rw, cred);
1659         else
1660                 err = pvn_getpages(hsfs_getapage, vp, off, len, protp,
1661                     pl, plsz, seg, addr, rw, cred);
1662 
1663         return (err);
1664 }
1665 
1666 
1667 
1668 /*
1669  * This function should never be called. We need to have it to pass
1670  * it as an argument to other functions.
1671  */
1672 /*ARGSUSED*/
1673 int
1674 hsfs_putapage(
1675         vnode_t         *vp,
1676         page_t          *pp,
1677         u_offset_t      *offp,
1678         size_t          *lenp,
1679         int             flags,
1680         cred_t          *cr)
1681 {
1682         /* should never happen - just destroy it */
1683         cmn_err(CE_NOTE, "hsfs_putapage: dirty HSFS page");




   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 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  26  */
  27 
  28 /*
  29  * Vnode operations for the High Sierra filesystem
  30  */
  31 
  32 #include <sys/types.h>
  33 #include <sys/t_lock.h>
  34 #include <sys/param.h>
  35 #include <sys/time.h>
  36 #include <sys/systm.h>
  37 #include <sys/sysmacros.h>
  38 #include <sys/resource.h>
  39 #include <sys/signal.h>
  40 #include <sys/cred.h>
  41 #include <sys/user.h>
  42 #include <sys/buf.h>
  43 #include <sys/vfs.h>
  44 #include <sys/vfs_opreg.h>
  45 #include <sys/stat.h>


1559         }
1560 
1561         return (err);
1562 }
1563 
1564 /*ARGSUSED*/
1565 static int
1566 hsfs_getpage(
1567         struct vnode *vp,
1568         offset_t off,
1569         size_t len,
1570         uint_t *protp,
1571         struct page *pl[],
1572         size_t plsz,
1573         struct seg *seg,
1574         caddr_t addr,
1575         enum seg_rw rw,
1576         struct cred *cred,
1577         caller_context_t *ct)
1578 {

1579         uint_t filsiz;
1580         struct hsfs *fsp;
1581         struct hsnode *hp;
1582 
1583         fsp = VFS_TO_HSFS(vp->v_vfsp);
1584         hp = VTOH(vp);
1585 
1586         /* does not support write */
1587         if (rw == S_WRITE) {
1588                 return (EROFS);
1589         }
1590 
1591         if (vp->v_flag & VNOMAP) {
1592                 return (ENOSYS);
1593         }
1594 
1595         ASSERT(off <= HS_MAXFILEOFF);
1596 
1597         /*
1598          * Determine file data size for EOF check.


1636                          */
1637                         if (hp->hs_ra_bytes > 0)
1638                                 hp->hs_ra_bytes -= PAGESIZE;
1639 
1640                         if (hp->hs_ra_bytes <= 0) {
1641                                 hp->hs_ra_bytes = 0;
1642                                 if (hp->hs_num_contig > 0)
1643                                         hp->hs_num_contig--;
1644                         }
1645                 }
1646                 /*
1647                  * Length must be rounded up to page boundary.
1648                  * since we read in units of pages.
1649                  */
1650                 hp->hs_prev_offset = off + roundup(len, PAGESIZE);
1651                 DTRACE_PROBE1(hsfs_compute_ra, struct hsnode *, hp);
1652         }
1653         if (protp != NULL)
1654                 *protp = PROT_ALL;
1655 
1656         return (pvn_getpages(hsfs_getapage, vp, off, len, protp, pl, plsz,
1657             seg, addr, rw, cred));






1658 }
1659 
1660 
1661 
1662 /*
1663  * This function should never be called. We need to have it to pass
1664  * it as an argument to other functions.
1665  */
1666 /*ARGSUSED*/
1667 int
1668 hsfs_putapage(
1669         vnode_t         *vp,
1670         page_t          *pp,
1671         u_offset_t      *offp,
1672         size_t          *lenp,
1673         int             flags,
1674         cred_t          *cr)
1675 {
1676         /* should never happen - just destroy it */
1677         cmn_err(CE_NOTE, "hsfs_putapage: dirty HSFS page");