The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/freevxfs/vxfs_subr.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2001 Christoph Hellwig.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions, and the following disclaimer,
   10  *    without modification.
   11  * 2. The name of the author may not be used to endorse or promote products
   12  *    derived from this software without specific prior written permission.
   13  *
   14  * Alternatively, this software may be distributed under the terms of the
   15  * GNU General Public License ("GPL").
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
   21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  */
   29 
   30 #ident "$Id: vxfs_subr.c,v 1.8 2001/12/28 20:50:47 hch Exp hch $"
   31 
   32 /*
   33  * Veritas filesystem driver - shared subroutines.
   34  */
   35 #include <linux/fs.h>
   36 #include <linux/kernel.h>
   37 #include <linux/slab.h>
   38 #include <linux/pagemap.h>
   39 
   40 #include "vxfs_kcompat.h"
   41 #include "vxfs_extern.h"
   42 
   43 
   44 static int              vxfs_readpage(struct file *, struct page *);
   45 static int              vxfs_bmap(struct address_space *, long);
   46 
   47 struct address_space_operations vxfs_aops = {
   48         .readpage =             vxfs_readpage,
   49         .bmap =                 vxfs_bmap,
   50         .sync_page =            block_sync_page,
   51 };
   52 
   53 
   54 /**
   55  * vxfs_get_page - read a page into memory.
   56  * @ip:         inode to read from
   57  * @n:          page number
   58  *
   59  * Description:
   60  *   vxfs_get_page reads the @n th page of @ip into the pagecache.
   61  *
   62  * Returns:
   63  *   The wanted page on success, else a NULL pointer.
   64  */
   65 struct page *
   66 vxfs_get_page(struct address_space *mapping, u_long n)
   67 {
   68         struct page *                   pp;
   69 
   70         pp = read_cache_page(mapping, n,
   71                         (filler_t*)mapping->a_ops->readpage, NULL);
   72 
   73         if (!IS_ERR(pp)) {
   74                 wait_on_page(pp);
   75                 kmap(pp);
   76                 if (!Page_Uptodate(pp))
   77                         goto fail;
   78                 /** if (!PageChecked(pp)) **/
   79                         /** vxfs_check_page(pp); **/
   80                 if (PageError(pp))
   81                         goto fail;
   82         }
   83         
   84         return (pp);
   85                  
   86 fail:
   87         vxfs_put_page(pp);
   88         return ERR_PTR(-EIO);
   89 }
   90 
   91 __inline__ void
   92 vxfs_put_page(struct page *pp)
   93 {
   94         kunmap(pp);
   95         page_cache_release(pp);
   96 }
   97 
   98 /**
   99  * vxfs_bread - read buffer for a give inode,block tuple
  100  * @ip:         inode
  101  * @block:      logical block
  102  *
  103  * Description:
  104  *   The vxfs_bread function reads block no @block  of
  105  *   @ip into the buffercache.
  106  *
  107  * Returns:
  108  *   The resulting &struct buffer_head.
  109  */
  110 struct buffer_head *
  111 vxfs_bread(struct inode *ip, int block)
  112 {
  113         struct buffer_head      *bp;
  114         daddr_t                 pblock;
  115 
  116         pblock = vxfs_bmap1(ip, block);
  117         bp = sb_bread(ip->i_sb, pblock);
  118 
  119         return (bp);
  120 }
  121 
  122 /**
  123  * vxfs_get_block - locate buffer for given inode,block tuple 
  124  * @ip:         inode
  125  * @iblock:     logical block
  126  * @bp:         buffer skeleton
  127  * @create:     %TRUE if blocks may be newly allocated.
  128  *
  129  * Description:
  130  *   The vxfs_get_block function fills @bp with the right physical
  131  *   block and device number to perform a lowlevel read/write on
  132  *   it.
  133  *
  134  * Returns:
  135  *   Zero on success, else a negativ error code (-EIO).
  136  */
  137 static int
  138 vxfs_getblk(struct inode *ip, sector_t iblock,
  139             struct buffer_head *bp, int create)
  140 {
  141         daddr_t                 pblock;
  142 
  143         pblock = vxfs_bmap1(ip, iblock);
  144         if (pblock != 0) {
  145                 map_bh(bp, ip->i_sb, pblock);
  146                 return 0;
  147         }
  148 
  149         return -EIO;
  150 }
  151 
  152 /**
  153  * vxfs_readpage - read one page synchronously into the pagecache
  154  * @file:       file context (unused)
  155  * @page:       page frame to fill in.
  156  *
  157  * Description:
  158  *   The vxfs_readpage routine reads @page synchronously into the
  159  *   pagecache.
  160  *
  161  * Returns:
  162  *   Zero on success, else a negative error code.
  163  *
  164  * Locking status:
  165  *   @page is locked and will be unlocked.
  166  */
  167 static int
  168 vxfs_readpage(struct file *file, struct page *page)
  169 {
  170         return block_read_full_page(page, vxfs_getblk);
  171 }
  172  
  173 /**
  174  * vxfs_bmap - perform logical to physical block mapping
  175  * @mapping:    logical to physical mapping to use
  176  * @block:      logical block (relative to @mapping).
  177  *
  178  * Description:
  179  *   Vxfs_bmap find out the corresponding phsical block to the
  180  *   @mapping, @block pair.
  181  *
  182  * Returns:
  183  *   Physical block number on success, else Zero.
  184  *
  185  * Locking status:
  186  *   We are under the bkl.
  187  */
  188 static int
  189 vxfs_bmap(struct address_space *mapping, long block)
  190 {
  191         return generic_block_bmap(mapping, block, vxfs_getblk);
  192 }

Cache object: 8487bdc09e16109d98a13d481479612a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.