hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/fs/squashfs/decompressor_multi_percpu.c
....@@ -1,15 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2013
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
97 #include <linux/types.h>
108 #include <linux/slab.h>
119 #include <linux/percpu.h>
1210 #include <linux/buffer_head.h>
11
+#include <linux/local_lock.h>
1312
1413 #include "squashfs_fs.h"
1514 #include "squashfs_fs_sb.h"
....@@ -22,7 +21,8 @@
2221 */
2322
2423 struct squashfs_stream {
25
- void *stream;
24
+ void *stream;
25
+ local_lock_t lock;
2626 };
2727
2828 void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
....@@ -43,6 +43,7 @@
4343 err = PTR_ERR(stream->stream);
4444 goto out;
4545 }
46
+ local_lock_init(&stream->lock);
4647 }
4748
4849 kfree(comp_opts);
....@@ -74,15 +75,19 @@
7475 }
7576 }
7677
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)
7980 {
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);
8691
8792 if (res < 0)
8893 ERROR("%s decompression failed, data probably corrupt\n",