~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/freevxfs/vxfs_subr.c

Version: ~ [ linux-5.5-rc1 ] ~ [ linux-5.4.2 ] ~ [ linux-5.3.15 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.88 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 /*
 31  * Veritas filesystem driver - shared subroutines.
 32  */
 33 #include <linux/fs.h>
 34 #include <linux/buffer_head.h>
 35 #include <linux/kernel.h>
 36 #include <linux/pagemap.h>
 37 
 38 #include "vxfs_extern.h"
 39 
 40 
 41 static int              vxfs_readpage(struct file *, struct page *);
 42 static sector_t         vxfs_bmap(struct address_space *, sector_t);
 43 
 44 const struct address_space_operations vxfs_aops = {
 45         .readpage =             vxfs_readpage,
 46         .bmap =                 vxfs_bmap,
 47 };
 48 
 49 inline void
 50 vxfs_put_page(struct page *pp)
 51 {
 52         kunmap(pp);
 53         page_cache_release(pp);
 54 }
 55 
 56 /**
 57  * vxfs_get_page - read a page into memory.
 58  * @ip:         inode to read from
 59  * @n:          page number
 60  *
 61  * Description:
 62  *   vxfs_get_page reads the @n th page of @ip into the pagecache.
 63  *
 64  * Returns:
 65  *   The wanted page on success, else a NULL pointer.
 66  */
 67 struct page *
 68 vxfs_get_page(struct address_space *mapping, u_long n)
 69 {
 70         struct page *                   pp;
 71 
 72         pp = read_mapping_page(mapping, n, NULL);
 73 
 74         if (!IS_ERR(pp)) {
 75                 kmap(pp);
 76                 /** if (!PageChecked(pp)) **/
 77                         /** vxfs_check_page(pp); **/
 78                 if (PageError(pp))
 79                         goto fail;
 80         }
 81         
 82         return (pp);
 83                  
 84 fail:
 85         vxfs_put_page(pp);
 86         return ERR_PTR(-EIO);
 87 }
 88 
 89 /**
 90  * vxfs_bread - read buffer for a give inode,block tuple
 91  * @ip:         inode
 92  * @block:      logical block
 93  *
 94  * Description:
 95  *   The vxfs_bread function reads block no @block  of
 96  *   @ip into the buffercache.
 97  *
 98  * Returns:
 99  *   The resulting &struct buffer_head.
100  */
101 struct buffer_head *
102 vxfs_bread(struct inode *ip, int block)
103 {
104         struct buffer_head      *bp;
105         daddr_t                 pblock;
106 
107         pblock = vxfs_bmap1(ip, block);
108         bp = sb_bread(ip->i_sb, pblock);
109 
110         return (bp);
111 }
112 
113 /**
114  * vxfs_get_block - locate buffer for given inode,block tuple 
115  * @ip:         inode
116  * @iblock:     logical block
117  * @bp:         buffer skeleton
118  * @create:     %TRUE if blocks may be newly allocated.
119  *
120  * Description:
121  *   The vxfs_get_block function fills @bp with the right physical
122  *   block and device number to perform a lowlevel read/write on
123  *   it.
124  *
125  * Returns:
126  *   Zero on success, else a negativ error code (-EIO).
127  */
128 static int
129 vxfs_getblk(struct inode *ip, sector_t iblock,
130             struct buffer_head *bp, int create)
131 {
132         daddr_t                 pblock;
133 
134         pblock = vxfs_bmap1(ip, iblock);
135         if (pblock != 0) {
136                 map_bh(bp, ip->i_sb, pblock);
137                 return 0;
138         }
139 
140         return -EIO;
141 }
142 
143 /**
144  * vxfs_readpage - read one page synchronously into the pagecache
145  * @file:       file context (unused)
146  * @page:       page frame to fill in.
147  *
148  * Description:
149  *   The vxfs_readpage routine reads @page synchronously into the
150  *   pagecache.
151  *
152  * Returns:
153  *   Zero on success, else a negative error code.
154  *
155  * Locking status:
156  *   @page is locked and will be unlocked.
157  */
158 static int
159 vxfs_readpage(struct file *file, struct page *page)
160 {
161         return block_read_full_page(page, vxfs_getblk);
162 }
163  
164 /**
165  * vxfs_bmap - perform logical to physical block mapping
166  * @mapping:    logical to physical mapping to use
167  * @block:      logical block (relative to @mapping).
168  *
169  * Description:
170  *   Vxfs_bmap find out the corresponding phsical block to the
171  *   @mapping, @block pair.
172  *
173  * Returns:
174  *   Physical block number on success, else Zero.
175  *
176  * Locking status:
177  *   We are under the bkl.
178  */
179 static sector_t
180 vxfs_bmap(struct address_space *mapping, sector_t block)
181 {
182         return generic_block_bmap(mapping, block, vxfs_getblk);
183 }
184 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp