hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/squashfs/lz4_wrapper.c
....@@ -1,12 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2013, 2014
34 * Phillip Lougher <phillip@squashfs.org.uk>
4
- *
5
- * This work is licensed under the terms of the GNU GPL, version 2. See
6
- * the COPYING file in the top-level directory.
75 */
86
9
-#include <linux/buffer_head.h>
7
+#include <linux/bio.h>
108 #include <linux/mutex.h>
119 #include <linux/slab.h>
1210 #include <linux/vmalloc.h>
....@@ -91,20 +89,23 @@
9189
9290
9391 static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm,
94
- struct buffer_head **bh, int b, int offset, int length,
92
+ struct bio *bio, int offset, int length,
9593 struct squashfs_page_actor *output)
9694 {
95
+ struct bvec_iter_all iter_all = {};
96
+ struct bio_vec *bvec = bvec_init_iter_all(&iter_all);
9797 struct squashfs_lz4 *stream = strm;
9898 void *buff = stream->input, *data;
99
- int avail, i, bytes = length, res;
99
+ int bytes = length, res;
100100
101
- for (i = 0; i < b; i++) {
102
- avail = min(bytes, msblk->devblksize - offset);
103
- memcpy(buff, bh[i]->b_data + offset, avail);
101
+ while (bio_next_segment(bio, &iter_all)) {
102
+ int avail = min(bytes, ((int)bvec->bv_len) - offset);
103
+
104
+ data = page_address(bvec->bv_page) + bvec->bv_offset;
105
+ memcpy(buff, data + offset, avail);
104106 buff += avail;
105107 bytes -= avail;
106108 offset = 0;
107
- put_bh(bh[i]);
108109 }
109110
110111 res = LZ4_decompress_safe(stream->input, stream->output,