linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: Kill ASSERT() for damaged filesystem
@ 2019-07-03  7:24 WenRuo Qu
  2019-07-03 11:37 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: WenRuo Qu @ 2019-07-03  7:24 UTC (permalink / raw)
  To: linux-btrfs

For damaged filesystem like 'bko-155621-bad-block-group-offset.raw' from
fuzzed tests, there may be no valid METADATA blocks at all.

Thus we could hit the following ASSERT():
  extent-tree.c:2484: alloc_tree_block: Assertion `sinfo` failed, value 0
  btrfs(+0x20ef8)[0x555adf5b2ef8]
  btrfs(+0x2107b)[0x555adf5b307b]
  btrfs(+0x27e7e)[0x555adf5b9e7e]
  btrfs(btrfs_alloc_free_block+0x67)[0x555adf5ba097]
  btrfs(+0x61188)[0x555adf5f3188]
  btrfs(+0x70921)[0x555adf602921]
  btrfs(main+0x94)[0x555adf5a7168]
  /usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fbd4c658ee3]
  btrfs(_start+0x2e)[0x555adf5a6cee]

The ASSERT() expects that every filesystem has one METADATA block
groups, but btrfs-check can accept any damaged filesystem.

So kill the ASSERT(), and return -EUCLEAN with one error message.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
To David:
Please fold this tiny modification to the following patch:
a970af98a1eb ("btrfs-progs: Fix false ENOSPC alert by tracking used space
correctly").

Sorry for the inconvience.
---
 extent-tree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/extent-tree.c b/extent-tree.c
index 1ebdf71f..932af2c6 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2481,7 +2481,10 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
 		return -ENOMEM;
 
 	sinfo = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
-	ASSERT(sinfo);
+	if (!sinfo) {
+		error("Corrupted fs, no valid METADATA block group found");
+		return -EUCLEAN;
+	}
 	ret = btrfs_reserve_extent(trans, root, num_bytes, empty_size,
 				   hint_byte, search_end, ins, 0);
 	if (ret < 0)
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs-progs: Kill ASSERT() for damaged filesystem
  2019-07-03  7:24 [PATCH] btrfs-progs: Kill ASSERT() for damaged filesystem WenRuo Qu
@ 2019-07-03 11:37 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2019-07-03 11:37 UTC (permalink / raw)
  To: WenRuo Qu; +Cc: linux-btrfs

On Wed, Jul 03, 2019 at 07:24:42AM +0000, WenRuo Qu wrote:
> For damaged filesystem like 'bko-155621-bad-block-group-offset.raw' from
> fuzzed tests, there may be no valid METADATA blocks at all.
> 
> Thus we could hit the following ASSERT():
>   extent-tree.c:2484: alloc_tree_block: Assertion `sinfo` failed, value 0
>   btrfs(+0x20ef8)[0x555adf5b2ef8]
>   btrfs(+0x2107b)[0x555adf5b307b]
>   btrfs(+0x27e7e)[0x555adf5b9e7e]
>   btrfs(btrfs_alloc_free_block+0x67)[0x555adf5ba097]
>   btrfs(+0x61188)[0x555adf5f3188]
>   btrfs(+0x70921)[0x555adf602921]
>   btrfs(main+0x94)[0x555adf5a7168]
>   /usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fbd4c658ee3]
>   btrfs(_start+0x2e)[0x555adf5a6cee]
> 
> The ASSERT() expects that every filesystem has one METADATA block
> groups, but btrfs-check can accept any damaged filesystem.
> 
> So kill the ASSERT(), and return -EUCLEAN with one error message.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> To David:
> Please fold this tiny modification to the following patch:
> a970af98a1eb ("btrfs-progs: Fix false ENOSPC alert by tracking used space
> correctly").

Folded to the patch, thanks. The fuzz-tests have been enabled in the
continuous integration but due to other problems the status is red so I
did not notice. Once the CI situtation is resolved, we'll know sooner
that something regressed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-03 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03  7:24 [PATCH] btrfs-progs: Kill ASSERT() for damaged filesystem WenRuo Qu
2019-07-03 11:37 ` David Sterba

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