From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH v2 1/2] erofs-utils: don't reuse full mapped buffer blocks
Date: Sun, 14 Feb 2021 23:35:48 +0800 [thread overview]
Message-ID: <20210214153549.2454-1-hsiangkao@aol.com> (raw)
In-Reply-To: 20210214153549.2454-1-hsiangkao.ref@aol.com
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
next parent reply other threads:[~2021-02-14 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210214153549.2454-1-hsiangkao.ref@aol.com>
2021-02-14 15:35 ` Gao Xiang via Linux-erofs [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210214153549.2454-1-hsiangkao@aol.com \
--to=linux-erofs@lists.ozlabs.org \
--cc=hsiangkao@aol.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).