erofs: fold in z_erofs_decompress()
Yue Hu
reviewerPATCH 1/1 erofs: fold in z_erofs_decompress()
From: Yue Hu <[email protected]>
No need this helper since it's just a simple wrapper for decompress method and only one caller. So, let's fold in directly instead.
Signed-off-by Yue Hu <[email protected]>
--- fs/erofs/compress.h | 3 +-- fs/erofs/decompressor.c | 8 +------- fs/erofs/zdata.c | 4 +++- 3 files changed, 5 insertions(+), 10 deletions(-)
fs/erofs/compress.h +1 -2
@@ -89,8 +89,7 @@ static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,int z_erofs_fixup_insize (struct z_erofs_decompress_req *rq,const char *padbuf,unsigned int padbufsize); -int z_erofs_decompress (struct z_erofs_decompress_req *rq, -struct page **pagepool); +extern const struct z_erofs_decompressor decompressors[];/* prototypes for specific algorithms */ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
fs/erofs/decompressor.c +1 -7
@@ -363,7 +363,7 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,return 0 ; } -static struct z_erofs_decompressor decompressors[] = { +const struct z_erofs_decompressor decompressors[] = { [Z_EROFS_COMPRESSION_SHIFTED ] = { .decompress = z_erofs_transform_plain, .name ="shifted"
@@ -383,9 +383,3 @@ static struct z_erofs_decompressor decompressors[] = { },#endif }; - -int z_erofs_decompress (struct z_erofs_decompress_req *rq, -struct page **pagepool) -{ -return decompressors[rq->alg].decompress (rq, pagepool); -}
fs/erofs/zdata.c +3 -1
@@ -1290,6 +1290,8 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,struct erofs_sb_info *const sbi =EROFS_SB (be->sb);struct z_erofs_pcluster *pcl = be->pcl;unsigned int pclusterpages =z_erofs_pclusterpages (pcl); +struct z_erofs_decompressor decompressor = + decompressors[pcl->algorithmformat];unsigned int i, inputsize;int err2;struct page *page;
@@ -1333,7 +1335,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,else inputsize = pclusterpages *PAGE_SIZE ; - err = z_erofs_decompress(&(struct z_erofs_decompress_req) { + err = decompressor.decompress(&(struct z_erofs_decompress_req) { .sb = be->sb, .in = be->compressed_pages, .out = be->decompressed_pages,
Signature · 1 line
2.17.1
Quoted 31 lines · Yue Hu
From: Yue Hu <[email protected]>
No need this helper since it's just a simple wrapper for decompress method and only one caller. So, let's fold in directly instead.
Signed-off-by Yue Hu <[email protected]>--- fs/erofs/compress.h | 3 +-- fs/erofs/decompressor.c | 8 +------- fs/erofs/zdata.c | 4 +++- 3 files changed, 5 insertions(+), 10 deletions(-)fs/erofs/compress.h +1
-2@@ -89,8 +89,7 @@ static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,int z_erofs_fixup_insize (struct z_erofs_decompress_req *rq,const char *padbuf,unsigned int padbufsize); -int z_erofs_decompress (struct z_erofs_decompress_req *rq, -struct page **pagepool); +extern const struct z_erofs_decompressor decompressors[];/* prototypes for specific algorithms */ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,fs/erofs/decompressor.c +0
-0
fs/erofs/decompressor.c static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq, · line 366
Quoted 5 lines
fs/erofs/decompressor.c +1
-1@@ -363,7 +363,7 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,return 0 ; } -static struct z_erofs_decompressor decompressors[] = { +const struct z_erofs_decompressor decompressors[] = {
Please help rename it as erofs_decompressors.
Quoted 18 lines
fs/erofs/decompressor.c +0
-6[Z_EROFS_COMPRESSION_SHIFTED] = { .decompress = z_erofs_transform_plain, .name ="shifted" @@ -383,9 +383,3 @@ static struct z_erofs_decompressor decompressors[] = { },#endif }; - -int z_erofs_decompress (struct z_erofs_decompress_req *rq, -struct page **pagepool) -{ -return decompressors[rq->alg].decompress (rq, pagepool); -}fs/erofs/zdata.c +0
-0
fs/erofs/zdata.c static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, · line 1294
Quoted 5 lines
fs/erofs/zdata.c +2
-0@@ -1290,6 +1290,8 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,struct erofs_sb_info *const sbi =EROFS_SB (be->sb);struct z_erofs_pcluster *pcl = be->pcl;unsigned int pclusterpages =z_erofs_pclusterpages (pcl); +struct z_erofs_decompressor decompressor = + decompressors[pcl->algorithmformat];
Do you really need copy the struct item?
struct z_erofs_decompressor *dec = erofs_decompressors[pcl->algorithmformat];
Otherwise it looks good to me.
Thanks,
Gao Xiang
Quoted 12 lines
fs/erofs/zdata.c +1
-1unsigned int i, inputsize;int err2;struct page *page;@@ -1333,7 +1335,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,else inputsize = pclusterpages *PAGE_SIZE ; - err = z_erofs_decompress(&(struct z_erofs_decompress_req) { + err = decompressor.decompress(&(struct z_erofs_decompress_req) { .sb = be->sb, .in = be->compressed_pages, .out = be->decompressed_pages,