* [PATCH v2 1/2] erofs-utils: don't reuse full mapped buffer blocks [not found] <20210214153549.2454-1-hsiangkao.ref@aol.com> @ 2021-02-14 15:35 ` Gao Xiang via Linux-erofs 2021-02-14 15:35 ` [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization Gao Xiang via Linux-erofs 0 siblings, 1 reply; 3+ messages in thread From: Gao Xiang via Linux-erofs @ 2021-02-14 15:35 UTC (permalink / raw) To: linux-erofs From: Gao Xiang <hsiangkao@aol.com> Full mapped buffer blocks aren't the targets for reusing. Fixes: 185b0bcdef4b ("erofs-utils: optimize buffer allocation logic") Signed-off-by: Gao Xiang <hsiangkao@aol.com> --- changes since v1: - update commit message since "erofs-utils: fix battach on full buffer blocks" has been considered in advance. lib/cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cache.c b/lib/cache.c index e3327c3f1586..6ae2b202e67b 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -155,8 +155,8 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size, struct erofs_buffer_block **bbp) { struct erofs_buffer_block *cur, *bb; - unsigned int used0, usedmax, used; - int used_before, ret; + unsigned int used0, used_before, usedmax, used; + int ret; used0 = (size + required_ext) % EROFS_BLKSIZ + inline_ext; /* inline data should be in the same fs block */ @@ -177,7 +177,7 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size, used_before = rounddown(EROFS_BLKSIZ - (size + required_ext + inline_ext), alignsize); - do { + for (; used_before; --used_before) { struct list_head *bt = mapped_buckets[type] + used_before; if (list_empty(bt)) @@ -203,7 +203,7 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size, bb = cur; usedmax = used; break; - } while (--used_before > 0); + } skip_mapped: /* try to start from the last mapped one, which can be expended */ -- 2.24.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization 2021-02-14 15:35 ` [PATCH v2 1/2] erofs-utils: don't reuse full mapped buffer blocks Gao Xiang via Linux-erofs @ 2021-02-14 15:35 ` Gao Xiang via Linux-erofs 2021-02-28 13:21 ` Li GuiFu via Linux-erofs 0 siblings, 1 reply; 3+ messages in thread From: Gao Xiang via Linux-erofs @ 2021-02-14 15:35 UTC (permalink / raw) To: linux-erofs From: Gao Xiang <hsiangkao@aol.com> In case that new buffer allocation optimization logic is potentially broken. Signed-off-by: Gao Xiang <hsiangkao@aol.com> --- changes since v1: - add a more check "used_before != cur->buffers.off % EROFS_BLKSIZ" lib/cache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cache.c b/lib/cache.c index 6ae2b202e67b..340dcdd76ce3 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -186,8 +186,14 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size, mapped_list); /* last mapped block can be expended, don't handle it here */ - if (cur == last_mapped_block) + if (list_next_entry(cur, list)->blkaddr == NULL_ADDR) { + DBG_BUGON(cur != last_mapped_block); continue; + } + + DBG_BUGON(cur->type != type); + DBG_BUGON(cur->blkaddr == NULL_ADDR); + DBG_BUGON(used_before != cur->buffers.off % EROFS_BLKSIZ); ret = __erofs_battach(cur, NULL, size, alignsize, required_ext + inline_ext, true); -- 2.24.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization 2021-02-14 15:35 ` [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization Gao Xiang via Linux-erofs @ 2021-02-28 13:21 ` Li GuiFu via Linux-erofs 0 siblings, 0 replies; 3+ messages in thread From: Li GuiFu via Linux-erofs @ 2021-02-28 13:21 UTC (permalink / raw) To: Gao Xiang, linux-erofs On 2021/2/14 23:35, Gao Xiang via Linux-erofs wrote: > From: Gao Xiang <hsiangkao@aol.com> > > In case that new buffer allocation optimization logic is > potentially broken. > > Signed-off-by: Gao Xiang <hsiangkao@aol.com> > --- It looks good Reviewed-by: Li Guifu <bluce.lee@aliyun.com> Thanks, ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-28 13:22 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20210214153549.2454-1-hsiangkao.ref@aol.com> 2021-02-14 15:35 ` [PATCH v2 1/2] erofs-utils: don't reuse full mapped buffer blocks Gao Xiang via Linux-erofs 2021-02-14 15:35 ` [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization Gao Xiang via Linux-erofs 2021-02-28 13:21 ` Li GuiFu via Linux-erofs
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).