.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Squashfs - a compressed read only filesystem for Linux |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2010 LG Electronics |
---|
5 | 6 | * Chan Jeong <chan.jeong@lge.com> |
---|
6 | 7 | * |
---|
7 | | - * This program is free software; you can redistribute it and/or |
---|
8 | | - * modify it under the terms of the GNU General Public License |
---|
9 | | - * as published by the Free Software Foundation; either version 2, |
---|
10 | | - * or (at your option) any later version. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | | - * |
---|
17 | | - * You should have received a copy of the GNU General Public License |
---|
18 | | - * along with this program; if not, write to the Free Software |
---|
19 | | - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | | - * |
---|
21 | 8 | * lzo_wrapper.c |
---|
22 | 9 | */ |
---|
23 | 10 | |
---|
24 | 11 | #include <linux/mutex.h> |
---|
25 | | -#include <linux/buffer_head.h> |
---|
| 12 | +#include <linux/bio.h> |
---|
26 | 13 | #include <linux/slab.h> |
---|
27 | 14 | #include <linux/vmalloc.h> |
---|
28 | 15 | #include <linux/lzo.h> |
---|
.. | .. |
---|
76 | 63 | |
---|
77 | 64 | |
---|
78 | 65 | static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm, |
---|
79 | | - struct buffer_head **bh, int b, int offset, int length, |
---|
| 66 | + struct bio *bio, int offset, int length, |
---|
80 | 67 | struct squashfs_page_actor *output) |
---|
81 | 68 | { |
---|
| 69 | + struct bvec_iter_all iter_all = {}; |
---|
| 70 | + struct bio_vec *bvec = bvec_init_iter_all(&iter_all); |
---|
82 | 71 | struct squashfs_lzo *stream = strm; |
---|
83 | 72 | void *buff = stream->input, *data; |
---|
84 | | - int avail, i, bytes = length, res; |
---|
| 73 | + int bytes = length, res; |
---|
85 | 74 | size_t out_len = output->length; |
---|
86 | 75 | |
---|
87 | | - for (i = 0; i < b; i++) { |
---|
88 | | - avail = min(bytes, msblk->devblksize - offset); |
---|
89 | | - memcpy(buff, bh[i]->b_data + offset, avail); |
---|
| 76 | + while (bio_next_segment(bio, &iter_all)) { |
---|
| 77 | + int avail = min(bytes, ((int)bvec->bv_len) - offset); |
---|
| 78 | + |
---|
| 79 | + data = page_address(bvec->bv_page) + bvec->bv_offset; |
---|
| 80 | + memcpy(buff, data + offset, avail); |
---|
90 | 81 | buff += avail; |
---|
91 | 82 | bytes -= avail; |
---|
92 | 83 | offset = 0; |
---|
93 | | - put_bh(bh[i]); |
---|
94 | 84 | } |
---|
95 | 85 | |
---|
96 | 86 | res = lzo1x_decompress_safe(stream->input, (size_t)length, |
---|