Skip to content

Commit 1bbb19b

Browse files
committed
Merge tag 'erofs-for-6.8-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: - fix an infinite loop issue of sub-page compressed data support found with lengthy stress tests on a 64k-page arm64 VM - optimize the temporary buffer allocation for low-memory scenarios, which can reduce 20.21% on average under a heavy multi-app launch benchmark workload - get rid of unnecessary GFP_NOFS * tag 'erofs-for-6.8-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: relaxed temporary buffers allocation on readahead erofs: fix infinite loop due to a race of filling compressed_bvecs erofs: get rid of unneeded GFP_NOFS
2 parents 2a6526c + d928166 commit 1bbb19b

File tree

8 files changed

+87
-63
lines changed

8 files changed

+87
-63
lines changed

fs/erofs/compress.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
struct z_erofs_decompress_req {
1212
struct super_block *sb;
1313
struct page **in, **out;
14-
1514
unsigned short pageofs_in, pageofs_out;
1615
unsigned int inputsize, outputsize;
1716

18-
/* indicate the algorithm will be used for decompression */
19-
unsigned int alg;
17+
unsigned int alg; /* the algorithm for decompression */
2018
bool inplace_io, partial_decoding, fillgaps;
19+
gfp_t gfp; /* allocation flags for extra temporary buffers */
2120
};
2221

2322
struct z_erofs_decompressor {

fs/erofs/decompressor.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ static int z_erofs_lz4_prepare_dstpages(struct z_erofs_lz4_decompress_ctx *ctx,
111111
victim = availables[--top];
112112
get_page(victim);
113113
} else {
114-
victim = erofs_allocpage(pagepool,
115-
GFP_KERNEL | __GFP_NOFAIL);
114+
victim = erofs_allocpage(pagepool, rq->gfp);
115+
if (!victim)
116+
return -ENOMEM;
116117
set_page_private(victim, Z_EROFS_SHORTLIVED_PAGE);
117118
}
118119
rq->out[i] = victim;

fs/erofs/decompressor_deflate.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int z_erofs_load_deflate_config(struct super_block *sb,
9595
}
9696

9797
int z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
98-
struct page **pagepool)
98+
struct page **pgpl)
9999
{
100100
const unsigned int nrpages_out =
101101
PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -158,8 +158,12 @@ int z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
158158
strm->z.avail_out = min_t(u32, outsz, PAGE_SIZE - pofs);
159159
outsz -= strm->z.avail_out;
160160
if (!rq->out[no]) {
161-
rq->out[no] = erofs_allocpage(pagepool,
162-
GFP_KERNEL | __GFP_NOFAIL);
161+
rq->out[no] = erofs_allocpage(pgpl, rq->gfp);
162+
if (!rq->out[no]) {
163+
kout = NULL;
164+
err = -ENOMEM;
165+
break;
166+
}
163167
set_page_private(rq->out[no],
164168
Z_EROFS_SHORTLIVED_PAGE);
165169
}
@@ -211,8 +215,11 @@ int z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
211215

212216
DBG_BUGON(erofs_page_is_managed(EROFS_SB(sb),
213217
rq->in[j]));
214-
tmppage = erofs_allocpage(pagepool,
215-
GFP_KERNEL | __GFP_NOFAIL);
218+
tmppage = erofs_allocpage(pgpl, rq->gfp);
219+
if (!tmppage) {
220+
err = -ENOMEM;
221+
goto failed;
222+
}
216223
set_page_private(tmppage, Z_EROFS_SHORTLIVED_PAGE);
217224
copy_highpage(tmppage, rq->in[j]);
218225
rq->in[j] = tmppage;
@@ -230,7 +237,7 @@ int z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
230237
break;
231238
}
232239
}
233-
240+
failed:
234241
if (zlib_inflateEnd(&strm->z) != Z_OK && !err)
235242
err = -EIO;
236243
if (kout)

fs/erofs/decompressor_lzma.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int z_erofs_load_lzma_config(struct super_block *sb,
148148
}
149149

150150
int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
151-
struct page **pagepool)
151+
struct page **pgpl)
152152
{
153153
const unsigned int nrpages_out =
154154
PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -215,8 +215,11 @@ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
215215
PAGE_SIZE - pageofs);
216216
outlen -= strm->buf.out_size;
217217
if (!rq->out[no] && rq->fillgaps) { /* deduped */
218-
rq->out[no] = erofs_allocpage(pagepool,
219-
GFP_KERNEL | __GFP_NOFAIL);
218+
rq->out[no] = erofs_allocpage(pgpl, rq->gfp);
219+
if (!rq->out[no]) {
220+
err = -ENOMEM;
221+
break;
222+
}
220223
set_page_private(rq->out[no],
221224
Z_EROFS_SHORTLIVED_PAGE);
222225
}
@@ -258,8 +261,11 @@ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
258261

259262
DBG_BUGON(erofs_page_is_managed(EROFS_SB(rq->sb),
260263
rq->in[j]));
261-
tmppage = erofs_allocpage(pagepool,
262-
GFP_KERNEL | __GFP_NOFAIL);
264+
tmppage = erofs_allocpage(pgpl, rq->gfp);
265+
if (!tmppage) {
266+
err = -ENOMEM;
267+
goto failed;
268+
}
263269
set_page_private(tmppage, Z_EROFS_SHORTLIVED_PAGE);
264270
copy_highpage(tmppage, rq->in[j]);
265271
rq->in[j] = tmppage;
@@ -277,6 +283,7 @@ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
277283
break;
278284
}
279285
}
286+
failed:
280287
if (no < nrpages_out && strm->buf.out)
281288
kunmap(rq->out[no]);
282289
if (ni < nrpages_in)

fs/erofs/fscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ static struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb
459459

460460
inode->i_size = OFFSET_MAX;
461461
inode->i_mapping->a_ops = &erofs_fscache_meta_aops;
462-
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
462+
mapping_set_gfp_mask(inode->i_mapping, GFP_KERNEL);
463463
inode->i_blkbits = EROFS_SB(sb)->blkszbits;
464464
inode->i_private = ctx;
465465

fs/erofs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void *erofs_read_inode(struct erofs_buf *buf,
6060
} else {
6161
const unsigned int gotten = sb->s_blocksize - *ofs;
6262

63-
copied = kmalloc(vi->inode_isize, GFP_NOFS);
63+
copied = kmalloc(vi->inode_isize, GFP_KERNEL);
6464
if (!copied) {
6565
err = -ENOMEM;
6666
goto err_out;

fs/erofs/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct erofs_workgroup *erofs_insert_workgroup(struct super_block *sb,
8181
repeat:
8282
xa_lock(&sbi->managed_pslots);
8383
pre = __xa_cmpxchg(&sbi->managed_pslots, grp->index,
84-
NULL, grp, GFP_NOFS);
84+
NULL, grp, GFP_KERNEL);
8585
if (pre) {
8686
if (xa_is_err(pre)) {
8787
pre = ERR_PTR(xa_err(pre));

0 commit comments

Comments
 (0)