[PATCH v2 2/2] erofs-utils: more sanity check for buffer allocation optimization
Gao Xiang
hsiangkao at aol.com
Mon Feb 15 02:35:49 AEDT 2021
From: Gao Xiang <hsiangkao at aol.com>
In case that new buffer allocation optimization logic is
potentially broken.
Signed-off-by: Gao Xiang <hsiangkao at 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
More information about the Linux-erofs
mailing list