diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/freevxfs/vxfs_subr.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'fs/freevxfs/vxfs_subr.c')
-rw-r--r-- | fs/freevxfs/vxfs_subr.c | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/fs/freevxfs/vxfs_subr.c b/fs/freevxfs/vxfs_subr.c new file mode 100644 index 000000000000..5e305612054a --- /dev/null +++ b/fs/freevxfs/vxfs_subr.c | |||
@@ -0,0 +1,190 @@ | |||
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/slab.h> | ||
37 | #include <linux/pagemap.h> | ||
38 | |||
39 | #include "vxfs_kcompat.h" | ||
40 | #include "vxfs_extern.h" | ||
41 | |||
42 | |||
43 | static int vxfs_readpage(struct file *, struct page *); | ||
44 | static sector_t vxfs_bmap(struct address_space *, sector_t); | ||
45 | |||
46 | struct address_space_operations vxfs_aops = { | ||
47 | .readpage = vxfs_readpage, | ||
48 | .bmap = vxfs_bmap, | ||
49 | .sync_page = block_sync_page, | ||
50 | }; | ||
51 | |||
52 | inline void | ||
53 | vxfs_put_page(struct page *pp) | ||
54 | { | ||
55 | kunmap(pp); | ||
56 | page_cache_release(pp); | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * vxfs_get_page - read a page into memory. | ||
61 | * @ip: inode to read from | ||
62 | * @n: page number | ||
63 | * | ||
64 | * Description: | ||
65 | * vxfs_get_page reads the @n th page of @ip into the pagecache. | ||
66 | * | ||
67 | * Returns: | ||
68 | * The wanted page on success, else a NULL pointer. | ||
69 | */ | ||
70 | struct page * | ||
71 | vxfs_get_page(struct address_space *mapping, u_long n) | ||
72 | { | ||
73 | struct page * pp; | ||
74 | |||
75 | pp = read_cache_page(mapping, n, | ||
76 | (filler_t*)mapping->a_ops->readpage, NULL); | ||
77 | |||
78 | if (!IS_ERR(pp)) { | ||
79 | wait_on_page_locked(pp); | ||
80 | kmap(pp); | ||
81 | if (!PageUptodate(pp)) | ||
82 | goto fail; | ||
83 | /** if (!PageChecked(pp)) **/ | ||
84 | /** vxfs_check_page(pp); **/ | ||
85 | if (PageError(pp)) | ||
86 | goto fail; | ||
87 | } | ||
88 | |||
89 | return (pp); | ||
90 | |||
91 | fail: | ||
92 | vxfs_put_page(pp); | ||
93 | return ERR_PTR(-EIO); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * vxfs_bread - read buffer for a give inode,block tuple | ||
98 | * @ip: inode | ||
99 | * @block: logical block | ||
100 | * | ||
101 | * Description: | ||
102 | * The vxfs_bread function reads block no @block of | ||
103 | * @ip into the buffercache. | ||
104 | * | ||
105 | * Returns: | ||
106 | * The resulting &struct buffer_head. | ||
107 | */ | ||
108 | struct buffer_head * | ||
109 | vxfs_bread(struct inode *ip, int block) | ||
110 | { | ||
111 | struct buffer_head *bp; | ||
112 | daddr_t pblock; | ||
113 | |||
114 | pblock = vxfs_bmap1(ip, block); | ||
115 | bp = sb_bread(ip->i_sb, pblock); | ||
116 | |||
117 | return (bp); | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * vxfs_get_block - locate buffer for given inode,block tuple | ||
122 | * @ip: inode | ||
123 | * @iblock: logical block | ||
124 | * @bp: buffer skeleton | ||
125 | * @create: %TRUE if blocks may be newly allocated. | ||
126 | * | ||
127 | * Description: | ||
128 | * The vxfs_get_block function fills @bp with the right physical | ||
129 | * block and device number to perform a lowlevel read/write on | ||
130 | * it. | ||
131 | * | ||
132 | * Returns: | ||
133 | * Zero on success, else a negativ error code (-EIO). | ||
134 | */ | ||
135 | static int | ||
136 | vxfs_getblk(struct inode *ip, sector_t iblock, | ||
137 | struct buffer_head *bp, int create) | ||
138 | { | ||
139 | daddr_t pblock; | ||
140 | |||
141 | pblock = vxfs_bmap1(ip, iblock); | ||
142 | if (pblock != 0) { | ||
143 | map_bh(bp, ip->i_sb, pblock); | ||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | return -EIO; | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * vxfs_readpage - read one page synchronously into the pagecache | ||
152 | * @file: file context (unused) | ||
153 | * @page: page frame to fill in. | ||
154 | * | ||
155 | * Description: | ||
156 | * The vxfs_readpage routine reads @page synchronously into the | ||
157 | * pagecache. | ||
158 | * | ||
159 | * Returns: | ||
160 | * Zero on success, else a negative error code. | ||
161 | * | ||
162 | * Locking status: | ||
163 | * @page is locked and will be unlocked. | ||
164 | */ | ||
165 | static int | ||
166 | vxfs_readpage(struct file *file, struct page *page) | ||
167 | { | ||
168 | return block_read_full_page(page, vxfs_getblk); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * vxfs_bmap - perform logical to physical block mapping | ||
173 | * @mapping: logical to physical mapping to use | ||
174 | * @block: logical block (relative to @mapping). | ||
175 | * | ||
176 | * Description: | ||
177 | * Vxfs_bmap find out the corresponding phsical block to the | ||
178 | * @mapping, @block pair. | ||
179 | * | ||
180 | * Returns: | ||
181 | * Physical block number on success, else Zero. | ||
182 | * | ||
183 | * Locking status: | ||
184 | * We are under the bkl. | ||
185 | */ | ||
186 | static sector_t | ||
187 | vxfs_bmap(struct address_space *mapping, sector_t block) | ||
188 | { | ||
189 | return generic_block_bmap(mapping, block, vxfs_getblk); | ||
190 | } | ||