hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/squashfs/lzo_wrapper.c
....@@ -1,28 +1,15 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Squashfs - a compressed read only filesystem for Linux
34 *
45 * Copyright (c) 2010 LG Electronics
56 * Chan Jeong <chan.jeong@lge.com>
67 *
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
- *
218 * lzo_wrapper.c
229 */
2310
2411 #include <linux/mutex.h>
25
-#include <linux/buffer_head.h>
12
+#include <linux/bio.h>
2613 #include <linux/slab.h>
2714 #include <linux/vmalloc.h>
2815 #include <linux/lzo.h>
....@@ -76,21 +63,24 @@
7663
7764
7865 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,
8067 struct squashfs_page_actor *output)
8168 {
69
+ struct bvec_iter_all iter_all = {};
70
+ struct bio_vec *bvec = bvec_init_iter_all(&iter_all);
8271 struct squashfs_lzo *stream = strm;
8372 void *buff = stream->input, *data;
84
- int avail, i, bytes = length, res;
73
+ int bytes = length, res;
8574 size_t out_len = output->length;
8675
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);
9081 buff += avail;
9182 bytes -= avail;
9283 offset = 0;
93
- put_bh(bh[i]);
9484 }
9585
9686 res = lzo1x_decompress_safe(stream->input, (size_t)length,