linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization
Date: Sun, 14 Feb 2021 23:35:49 +0800	[thread overview]
Message-ID: <20210214153549.2454-2-hsiangkao@aol.com> (raw)
In-Reply-To: <20210214153549.2454-1-hsiangkao@aol.com>

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


  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 ` [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 [this message]
2021-02-28 13:21     ` [PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization 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-2-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).