Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

erofs: rename some generic methods in decompressor

Previously, some LZ4 methods were named with `generic'. However, while
evaluating the effective LZMA approach, it seems they aren't quite
generic at all (e.g. no need preparing dstpages for most LZMA cases.)

Avoid such naming instead.

Link: https://lore.kernel.org/r/20211010213145.17462-7-xiang@kernel.org
Acked-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

+30 -33
+30 -33
fs/erofs/decompressor.c
··· 17 17 #endif 18 18 19 19 struct z_erofs_decompressor { 20 - /* 21 - * if destpages have sparsed pages, fill them with bounce pages. 22 - * it also check whether destpages indicate continuous physical memory. 23 - */ 24 - int (*prepare_destpages)(struct z_erofs_decompress_req *rq, 25 - struct list_head *pagepool); 26 - int (*decompress)(struct z_erofs_decompress_req *rq, u8 *out); 20 + int (*decompress)(struct z_erofs_decompress_req *rq, 21 + struct list_head *pagepool); 27 22 char *name; 28 23 }; 29 24 ··· 58 63 return erofs_pcpubuf_growsize(sbi->lz4.max_pclusterblks); 59 64 } 60 65 61 - static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq, 62 - struct list_head *pagepool) 66 + /* 67 + * Fill all gaps with bounce pages if it's a sparse page list. Also check if 68 + * all physical pages are consecutive, which can be seen for moderate CR. 69 + */ 70 + static int z_erofs_lz4_prepare_dstpages(struct z_erofs_decompress_req *rq, 71 + struct list_head *pagepool) 63 72 { 64 73 const unsigned int nr = 65 74 PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; ··· 118 119 return kaddr ? 1 : 0; 119 120 } 120 121 121 - static void *z_erofs_handle_inplace_io(struct z_erofs_decompress_req *rq, 122 + static void *z_erofs_lz4_handle_inplace_io(struct z_erofs_decompress_req *rq, 122 123 void *inpage, unsigned int *inputmargin, int *maptype, 123 124 bool support_0padding) 124 125 { ··· 188 189 return src; 189 190 } 190 191 191 - static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) 192 + static int z_erofs_lz4_decompress_mem(struct z_erofs_decompress_req *rq, 193 + u8 *out) 192 194 { 193 195 unsigned int inputmargin; 194 196 u8 *headpage, *src; ··· 216 216 } 217 217 218 218 rq->inputsize -= inputmargin; 219 - src = z_erofs_handle_inplace_io(rq, headpage, &inputmargin, &maptype, 220 - support_0padding); 219 + src = z_erofs_lz4_handle_inplace_io(rq, headpage, &inputmargin, 220 + &maptype, support_0padding); 221 221 if (IS_ERR(src)) 222 222 return PTR_ERR(src); 223 223 ··· 259 259 return ret; 260 260 } 261 261 262 - static struct z_erofs_decompressor decompressors[] = { 263 - [Z_EROFS_COMPRESSION_SHIFTED] = { 264 - .name = "shifted" 265 - }, 266 - [Z_EROFS_COMPRESSION_LZ4] = { 267 - .prepare_destpages = z_erofs_lz4_prepare_destpages, 268 - .decompress = z_erofs_lz4_decompress, 269 - .name = "lz4" 270 - }, 271 - }; 272 - 273 - static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq, 274 - struct list_head *pagepool) 262 + static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, 263 + struct list_head *pagepool) 275 264 { 276 265 const unsigned int nrpages_out = 277 266 PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; 278 - const struct z_erofs_decompressor *alg = decompressors + rq->alg; 279 267 unsigned int dst_maptype; 280 268 void *dst; 281 269 int ret; ··· 277 289 } 278 290 279 291 /* general decoding path which can be used for all cases */ 280 - ret = alg->prepare_destpages(rq, pagepool); 292 + ret = z_erofs_lz4_prepare_dstpages(rq, pagepool); 281 293 if (ret < 0) 282 294 return ret; 283 295 if (ret) { ··· 292 304 dst_maptype = 2; 293 305 294 306 dstmap_out: 295 - ret = alg->decompress(rq, dst + rq->pageofs_out); 307 + ret = z_erofs_lz4_decompress_mem(rq, dst + rq->pageofs_out); 296 308 297 309 if (!dst_maptype) 298 310 kunmap_atomic(dst); ··· 301 313 return ret; 302 314 } 303 315 304 - static int z_erofs_shifted_transform(const struct z_erofs_decompress_req *rq, 316 + static int z_erofs_shifted_transform(struct z_erofs_decompress_req *rq, 305 317 struct list_head *pagepool) 306 318 { 307 319 const unsigned int nrpages_out = ··· 340 352 return 0; 341 353 } 342 354 355 + static struct z_erofs_decompressor decompressors[] = { 356 + [Z_EROFS_COMPRESSION_SHIFTED] = { 357 + .decompress = z_erofs_shifted_transform, 358 + .name = "shifted" 359 + }, 360 + [Z_EROFS_COMPRESSION_LZ4] = { 361 + .decompress = z_erofs_lz4_decompress, 362 + .name = "lz4" 363 + }, 364 + }; 365 + 343 366 int z_erofs_decompress(struct z_erofs_decompress_req *rq, 344 367 struct list_head *pagepool) 345 368 { 346 - if (rq->alg == Z_EROFS_COMPRESSION_SHIFTED) 347 - return z_erofs_shifted_transform(rq, pagepool); 348 - return z_erofs_decompress_generic(rq, pagepool); 369 + return decompressors[rq->alg].decompress(rq, pagepool); 349 370 }