.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2013 |
---|
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 | 7 | #include <linux/types.h> |
---|
10 | 8 | #include <linux/slab.h> |
---|
11 | 9 | #include <linux/percpu.h> |
---|
12 | 10 | #include <linux/buffer_head.h> |
---|
| 11 | +#include <linux/local_lock.h> |
---|
13 | 12 | |
---|
14 | 13 | #include "squashfs_fs.h" |
---|
15 | 14 | #include "squashfs_fs_sb.h" |
---|
.. | .. |
---|
22 | 21 | */ |
---|
23 | 22 | |
---|
24 | 23 | struct squashfs_stream { |
---|
25 | | - void *stream; |
---|
| 24 | + void *stream; |
---|
| 25 | + local_lock_t lock; |
---|
26 | 26 | }; |
---|
27 | 27 | |
---|
28 | 28 | void *squashfs_decompressor_create(struct squashfs_sb_info *msblk, |
---|
.. | .. |
---|
43 | 43 | err = PTR_ERR(stream->stream); |
---|
44 | 44 | goto out; |
---|
45 | 45 | } |
---|
| 46 | + local_lock_init(&stream->lock); |
---|
46 | 47 | } |
---|
47 | 48 | |
---|
48 | 49 | kfree(comp_opts); |
---|
.. | .. |
---|
74 | 75 | } |
---|
75 | 76 | } |
---|
76 | 77 | |
---|
77 | | -int squashfs_decompress(struct squashfs_sb_info *msblk, struct buffer_head **bh, |
---|
78 | | - int b, int offset, int length, struct squashfs_page_actor *output) |
---|
| 78 | +int squashfs_decompress(struct squashfs_sb_info *msblk, struct bio *bio, |
---|
| 79 | + int offset, int length, struct squashfs_page_actor *output) |
---|
79 | 80 | { |
---|
80 | | - struct squashfs_stream __percpu *percpu = |
---|
81 | | - (struct squashfs_stream __percpu *) msblk->stream; |
---|
82 | | - struct squashfs_stream *stream = get_cpu_ptr(percpu); |
---|
83 | | - int res = msblk->decompressor->decompress(msblk, stream->stream, bh, b, |
---|
84 | | - offset, length, output); |
---|
85 | | - put_cpu_ptr(stream); |
---|
| 81 | + struct squashfs_stream *stream; |
---|
| 82 | + int res; |
---|
| 83 | + |
---|
| 84 | + local_lock(&msblk->stream->lock); |
---|
| 85 | + stream = this_cpu_ptr(msblk->stream); |
---|
| 86 | + |
---|
| 87 | + res = msblk->decompressor->decompress(msblk, stream->stream, bio, |
---|
| 88 | + offset, length, output); |
---|
| 89 | + |
---|
| 90 | + local_unlock(&msblk->stream->lock); |
---|
86 | 91 | |
---|
87 | 92 | if (res < 0) |
---|
88 | 93 | ERROR("%s decompression failed, data probably corrupt\n", |
---|