diff options
Diffstat (limited to 'fs/squashfs/block.c')
-rw-r--r-- | fs/squashfs/block.c | 74 |
1 files changed, 4 insertions, 70 deletions
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 2a7960310349..b8addfdc6094 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
30 | #include <linux/vfs.h> | 30 | #include <linux/vfs.h> |
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/mutex.h> | ||
33 | #include <linux/string.h> | 32 | #include <linux/string.h> |
34 | #include <linux/buffer_head.h> | 33 | #include <linux/buffer_head.h> |
35 | #include <linux/zlib.h> | 34 | #include <linux/zlib.h> |
@@ -153,72 +152,10 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, | |||
153 | } | 152 | } |
154 | 153 | ||
155 | if (compressed) { | 154 | if (compressed) { |
156 | int zlib_err = 0, zlib_init = 0; | 155 | length = squashfs_zlib_uncompress(msblk, buffer, bh, b, offset, |
157 | 156 | length, srclength, pages); | |
158 | /* | 157 | if (length < 0) |
159 | * Uncompress block. | 158 | goto read_failure; |
160 | */ | ||
161 | |||
162 | mutex_lock(&msblk->read_data_mutex); | ||
163 | |||
164 | msblk->stream.avail_out = 0; | ||
165 | msblk->stream.avail_in = 0; | ||
166 | |||
167 | bytes = length; | ||
168 | do { | ||
169 | if (msblk->stream.avail_in == 0 && k < b) { | ||
170 | avail = min(bytes, msblk->devblksize - offset); | ||
171 | bytes -= avail; | ||
172 | wait_on_buffer(bh[k]); | ||
173 | if (!buffer_uptodate(bh[k])) | ||
174 | goto release_mutex; | ||
175 | |||
176 | if (avail == 0) { | ||
177 | offset = 0; | ||
178 | put_bh(bh[k++]); | ||
179 | continue; | ||
180 | } | ||
181 | |||
182 | msblk->stream.next_in = bh[k]->b_data + offset; | ||
183 | msblk->stream.avail_in = avail; | ||
184 | offset = 0; | ||
185 | } | ||
186 | |||
187 | if (msblk->stream.avail_out == 0 && page < pages) { | ||
188 | msblk->stream.next_out = buffer[page++]; | ||
189 | msblk->stream.avail_out = PAGE_CACHE_SIZE; | ||
190 | } | ||
191 | |||
192 | if (!zlib_init) { | ||
193 | zlib_err = zlib_inflateInit(&msblk->stream); | ||
194 | if (zlib_err != Z_OK) { | ||
195 | ERROR("zlib_inflateInit returned" | ||
196 | " unexpected result 0x%x," | ||
197 | " srclength %d\n", zlib_err, | ||
198 | srclength); | ||
199 | goto release_mutex; | ||
200 | } | ||
201 | zlib_init = 1; | ||
202 | } | ||
203 | |||
204 | zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH); | ||
205 | |||
206 | if (msblk->stream.avail_in == 0 && k < b) | ||
207 | put_bh(bh[k++]); | ||
208 | } while (zlib_err == Z_OK); | ||
209 | |||
210 | if (zlib_err != Z_STREAM_END) { | ||
211 | ERROR("zlib_inflate error, data probably corrupt\n"); | ||
212 | goto release_mutex; | ||
213 | } | ||
214 | |||
215 | zlib_err = zlib_inflateEnd(&msblk->stream); | ||
216 | if (zlib_err != Z_OK) { | ||
217 | ERROR("zlib_inflate error, data probably corrupt\n"); | ||
218 | goto release_mutex; | ||
219 | } | ||
220 | length = msblk->stream.total_out; | ||
221 | mutex_unlock(&msblk->read_data_mutex); | ||
222 | } else { | 159 | } else { |
223 | /* | 160 | /* |
224 | * Block is uncompressed. | 161 | * Block is uncompressed. |
@@ -255,9 +192,6 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, | |||
255 | kfree(bh); | 192 | kfree(bh); |
256 | return length; | 193 | return length; |
257 | 194 | ||
258 | release_mutex: | ||
259 | mutex_unlock(&msblk->read_data_mutex); | ||
260 | |||
261 | block_release: | 195 | block_release: |
262 | for (; k < b; k++) | 196 | for (; k < b; k++) |
263 | put_bh(bh[k]); | 197 | put_bh(bh[k]); |