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 2/2] erofs-utils: more sanity check for buffer allocation optimization
Date: Wed, 10 Feb 2021 03:13:22 +0800	[thread overview]
Message-ID: <20210209191322.8902-2-hsiangkao@aol.com> (raw)
In-Reply-To: <20210209191322.8902-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>
---
 lib/cache.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/cache.c b/lib/cache.c
index e8840ac5dd31..c4851168ede7 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -186,8 +186,13 @@ 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);
 
 		ret = __erofs_battach(cur, NULL, size, alignsize,
 				      required_ext + inline_ext, true);
-- 
2.24.0


      reply	other threads:[~2021-02-09 19:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210209191322.8902-1-hsiangkao.ref@aol.com>
2021-02-09 19:13 ` [PATCH 1/2] erofs-utils: don't reuse full mapped buffer blocks Gao Xiang via Linux-erofs
2021-02-09 19:13   ` Gao Xiang via Linux-erofs [this message]

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=20210209191322.8902-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).