decompressor.c (4f2c0a4acffbec01079c28f839422e64ddeff004) | decompressor.c (3acea5fc335420ba7ef53947cf2d98d07fac39f7) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2019 HUAWEI, Inc. 4 * https://www.huawei.com/ 5 */ 6#include "compress.h" 7#include <linux/module.h> 8#include <linux/lz4.h> --- 28 unchanged lines hidden (view full) --- 37 return -EINVAL; 38 } 39 distance = le16_to_cpu(lz4->max_distance); 40 41 sbi->lz4.max_pclusterblks = le16_to_cpu(lz4->max_pclusterblks); 42 if (!sbi->lz4.max_pclusterblks) { 43 sbi->lz4.max_pclusterblks = 1; /* reserved case */ 44 } else if (sbi->lz4.max_pclusterblks > | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2019 HUAWEI, Inc. 4 * https://www.huawei.com/ 5 */ 6#include "compress.h" 7#include <linux/module.h> 8#include <linux/lz4.h> --- 28 unchanged lines hidden (view full) --- 37 return -EINVAL; 38 } 39 distance = le16_to_cpu(lz4->max_distance); 40 41 sbi->lz4.max_pclusterblks = le16_to_cpu(lz4->max_pclusterblks); 42 if (!sbi->lz4.max_pclusterblks) { 43 sbi->lz4.max_pclusterblks = 1; /* reserved case */ 44 } else if (sbi->lz4.max_pclusterblks > |
45 Z_EROFS_PCLUSTER_MAX_SIZE / EROFS_BLKSIZ) { | 45 erofs_blknr(sb, Z_EROFS_PCLUSTER_MAX_SIZE)) { |
46 erofs_err(sb, "too large lz4 pclusterblks %u", 47 sbi->lz4.max_pclusterblks); 48 return -EINVAL; 49 } 50 } else { 51 distance = le16_to_cpu(dsb->u1.lz4_max_distance); 52 sbi->lz4.max_pclusterblks = 1; 53 } --- 162 unchanged lines hidden (view full) --- 216 DBG_BUGON(*rq->in == NULL); 217 headpage = kmap_atomic(*rq->in); 218 219 /* LZ4 decompression inplace is only safe if zero_padding is enabled */ 220 if (erofs_sb_has_zero_padding(EROFS_SB(rq->sb))) { 221 support_0padding = true; 222 ret = z_erofs_fixup_insize(rq, headpage + rq->pageofs_in, 223 min_t(unsigned int, rq->inputsize, | 46 erofs_err(sb, "too large lz4 pclusterblks %u", 47 sbi->lz4.max_pclusterblks); 48 return -EINVAL; 49 } 50 } else { 51 distance = le16_to_cpu(dsb->u1.lz4_max_distance); 52 sbi->lz4.max_pclusterblks = 1; 53 } --- 162 unchanged lines hidden (view full) --- 216 DBG_BUGON(*rq->in == NULL); 217 headpage = kmap_atomic(*rq->in); 218 219 /* LZ4 decompression inplace is only safe if zero_padding is enabled */ 220 if (erofs_sb_has_zero_padding(EROFS_SB(rq->sb))) { 221 support_0padding = true; 222 ret = z_erofs_fixup_insize(rq, headpage + rq->pageofs_in, 223 min_t(unsigned int, rq->inputsize, |
224 EROFS_BLKSIZ - rq->pageofs_in)); | 224 rq->sb->s_blocksize - rq->pageofs_in)); |
225 if (ret) { 226 kunmap_atomic(headpage); 227 return ret; 228 } 229 may_inplace = !((rq->pageofs_in + rq->inputsize) & | 225 if (ret) { 226 kunmap_atomic(headpage); 227 return ret; 228 } 229 may_inplace = !((rq->pageofs_in + rq->inputsize) & |
230 (EROFS_BLKSIZ - 1)); | 230 (rq->sb->s_blocksize - 1)); |
231 } 232 233 inputmargin = rq->pageofs_in; 234 src = z_erofs_lz4_handle_overlap(ctx, headpage, &inputmargin, 235 &maptype, may_inplace); 236 if (IS_ERR(src)) 237 return PTR_ERR(src); 238 --- 153 unchanged lines hidden --- | 231 } 232 233 inputmargin = rq->pageofs_in; 234 src = z_erofs_lz4_handle_overlap(ctx, headpage, &inputmargin, 235 &maptype, may_inplace); 236 if (IS_ERR(src)) 237 return PTR_ERR(src); 238 --- 153 unchanged lines hidden --- |