Root/
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 | .sync_page = block_sync_page, |
48 | }; |
49 | |
50 | inline void |
51 | vxfs_put_page(struct page *pp) |
52 | { |
53 | kunmap(pp); |
54 | page_cache_release(pp); |
55 | } |
56 | |
57 | /** |
58 | * vxfs_get_page - read a page into memory. |
59 | * @ip: inode to read from |
60 | * @n: page number |
61 | * |
62 | * Description: |
63 | * vxfs_get_page reads the @n th page of @ip into the pagecache. |
64 | * |
65 | * Returns: |
66 | * The wanted page on success, else a NULL pointer. |
67 | */ |
68 | struct page * |
69 | vxfs_get_page(struct address_space *mapping, u_long n) |
70 | { |
71 | struct page * pp; |
72 | |
73 | pp = read_mapping_page(mapping, n, NULL); |
74 | |
75 | if (!IS_ERR(pp)) { |
76 | kmap(pp); |
77 | /** if (!PageChecked(pp)) **/ |
78 | /** vxfs_check_page(pp); **/ |
79 | if (PageError(pp)) |
80 | goto fail; |
81 | } |
82 | |
83 | return (pp); |
84 | |
85 | fail: |
86 | vxfs_put_page(pp); |
87 | return ERR_PTR(-EIO); |
88 | } |
89 | |
90 | /** |
91 | * vxfs_bread - read buffer for a give inode,block tuple |
92 | * @ip: inode |
93 | * @block: logical block |
94 | * |
95 | * Description: |
96 | * The vxfs_bread function reads block no @block of |
97 | * @ip into the buffercache. |
98 | * |
99 | * Returns: |
100 | * The resulting &struct buffer_head. |
101 | */ |
102 | struct buffer_head * |
103 | vxfs_bread(struct inode *ip, int block) |
104 | { |
105 | struct buffer_head *bp; |
106 | daddr_t pblock; |
107 | |
108 | pblock = vxfs_bmap1(ip, block); |
109 | bp = sb_bread(ip->i_sb, pblock); |
110 | |
111 | return (bp); |
112 | } |
113 | |
114 | /** |
115 | * vxfs_get_block - locate buffer for given inode,block tuple |
116 | * @ip: inode |
117 | * @iblock: logical block |
118 | * @bp: buffer skeleton |
119 | * @create: %TRUE if blocks may be newly allocated. |
120 | * |
121 | * Description: |
122 | * The vxfs_get_block function fills @bp with the right physical |
123 | * block and device number to perform a lowlevel read/write on |
124 | * it. |
125 | * |
126 | * Returns: |
127 | * Zero on success, else a negativ error code (-EIO). |
128 | */ |
129 | static int |
130 | vxfs_getblk(struct inode *ip, sector_t iblock, |
131 | struct buffer_head *bp, int create) |
132 | { |
133 | daddr_t pblock; |
134 | |
135 | pblock = vxfs_bmap1(ip, iblock); |
136 | if (pblock != 0) { |
137 | map_bh(bp, ip->i_sb, pblock); |
138 | return 0; |
139 | } |
140 | |
141 | return -EIO; |
142 | } |
143 | |
144 | /** |
145 | * vxfs_readpage - read one page synchronously into the pagecache |
146 | * @file: file context (unused) |
147 | * @page: page frame to fill in. |
148 | * |
149 | * Description: |
150 | * The vxfs_readpage routine reads @page synchronously into the |
151 | * pagecache. |
152 | * |
153 | * Returns: |
154 | * Zero on success, else a negative error code. |
155 | * |
156 | * Locking status: |
157 | * @page is locked and will be unlocked. |
158 | */ |
159 | static int |
160 | vxfs_readpage(struct file *file, struct page *page) |
161 | { |
162 | return block_read_full_page(page, vxfs_getblk); |
163 | } |
164 | |
165 | /** |
166 | * vxfs_bmap - perform logical to physical block mapping |
167 | * @mapping: logical to physical mapping to use |
168 | * @block: logical block (relative to @mapping). |
169 | * |
170 | * Description: |
171 | * Vxfs_bmap find out the corresponding phsical block to the |
172 | * @mapping, @block pair. |
173 | * |
174 | * Returns: |
175 | * Physical block number on success, else Zero. |
176 | * |
177 | * Locking status: |
178 | * We are under the bkl. |
179 | */ |
180 | static sector_t |
181 | vxfs_bmap(struct address_space *mapping, sector_t block) |
182 | { |
183 | return generic_block_bmap(mapping, block, vxfs_getblk); |
184 | } |
185 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9