| .. | .. | 
|---|
|  | 1 | +// SPDX-License-Identifier: GPL-2.0-only | 
|---|
| 1 | 2 | /* | 
|---|
| 2 | 3 | * Copyright (c) 2013, 2014 | 
|---|
| 3 | 4 | * 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. | 
|---|
| 7 | 5 | */ | 
|---|
| 8 | 6 |  | 
|---|
| 9 |  | -#include <linux/buffer_head.h> | 
|---|
|  | 7 | +#include <linux/bio.h> | 
|---|
| 10 | 8 | #include <linux/mutex.h> | 
|---|
| 11 | 9 | #include <linux/slab.h> | 
|---|
| 12 | 10 | #include <linux/vmalloc.h> | 
|---|
| .. | .. | 
|---|
| 91 | 89 |  | 
|---|
| 92 | 90 |  | 
|---|
| 93 | 91 | 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, | 
|---|
| 95 | 93 | struct squashfs_page_actor *output) | 
|---|
| 96 | 94 | { | 
|---|
|  | 95 | +	struct bvec_iter_all iter_all = {}; | 
|---|
|  | 96 | +	struct bio_vec *bvec = bvec_init_iter_all(&iter_all); | 
|---|
| 97 | 97 | struct squashfs_lz4 *stream = strm; | 
|---|
| 98 | 98 | void *buff = stream->input, *data; | 
|---|
| 99 |  | -	int avail, i, bytes = length, res; | 
|---|
|  | 99 | +	int bytes = length, res; | 
|---|
| 100 | 100 |  | 
|---|
| 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); | 
|---|
| 104 | 106 | buff += avail; | 
|---|
| 105 | 107 | bytes -= avail; | 
|---|
| 106 | 108 | offset = 0; | 
|---|
| 107 |  | -		put_bh(bh[i]); | 
|---|
| 108 | 109 | } | 
|---|
| 109 | 110 |  | 
|---|
| 110 | 111 | res = LZ4_decompress_safe(stream->input, stream->output, | 
|---|