2 * Copyright (c) 2000-2001 Christoph Hellwig.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
14 * Alternatively, this software may be distributed under the terms of the
15 * GNU General Public License ("GPL").
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
30 #ident "$Id: vxfs_subr.c,v 1.8 2001/12/28 20:50:47 hch Exp hch $"
33 * Veritas filesystem driver - shared subroutines.
36 #include <linux/kernel.h>
37 #include <linux/slab.h>
38 #include <linux/pagemap.h>
40 #include "vxfs_kcompat.h"
41 #include "vxfs_extern.h"
44 static int vxfs_readpage(struct file *, struct page *);
45 static int vxfs_bmap(struct address_space *, long);
47 struct address_space_operations vxfs_aops = {
48 .readpage = vxfs_readpage,
50 .sync_page = block_sync_page,
54 vxfs_put_page(struct page *pp)
57 page_cache_release(pp);
61 * vxfs_get_page - read a page into memory.
62 * @ip: inode to read from
66 * vxfs_get_page reads the @n th page of @ip into the pagecache.
69 * The wanted page on success, else a NULL pointer.
72 vxfs_get_page(struct address_space *mapping, u_long n)
76 pp = read_cache_page(mapping, n,
77 (filler_t*)mapping->a_ops->readpage, NULL);
82 if (!Page_Uptodate(pp))
84 /** if (!PageChecked(pp)) **/
85 /** vxfs_check_page(pp); **/
98 * vxfs_bread - read buffer for a give inode,block tuple
100 * @block: logical block
103 * The vxfs_bread function reads block no @block of
104 * @ip into the buffercache.
107 * The resulting &struct buffer_head.
110 vxfs_bread(struct inode *ip, int block)
112 struct buffer_head *bp;
115 pblock = vxfs_bmap1(ip, block);
116 bp = sb_bread(ip->i_sb, pblock);
122 * vxfs_get_block - locate buffer for given inode,block tuple
124 * @iblock: logical block
125 * @bp: buffer skeleton
126 * @create: %TRUE if blocks may be newly allocated.
129 * The vxfs_get_block function fills @bp with the right physical
130 * block and device number to perform a lowlevel read/write on
134 * Zero on success, else a negativ error code (-EIO).
137 vxfs_getblk(struct inode *ip, sector_t iblock,
138 struct buffer_head *bp, int create)
142 pblock = vxfs_bmap1(ip, iblock);
144 map_bh(bp, ip->i_sb, pblock);
152 * vxfs_readpage - read one page synchronously into the pagecache
153 * @file: file context (unused)
154 * @page: page frame to fill in.
157 * The vxfs_readpage routine reads @page synchronously into the
161 * Zero on success, else a negative error code.
164 * @page is locked and will be unlocked.
167 vxfs_readpage(struct file *file, struct page *page)
169 return block_read_full_page(page, vxfs_getblk);
173 * vxfs_bmap - perform logical to physical block mapping
174 * @mapping: logical to physical mapping to use
175 * @block: logical block (relative to @mapping).
178 * Vxfs_bmap find out the corresponding phsical block to the
179 * @mapping, @block pair.
182 * Physical block number on success, else Zero.
185 * We are under the bkl.
188 vxfs_bmap(struct address_space *mapping, long block)
190 return generic_block_bmap(mapping, block, vxfs_getblk);