From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <dsterba@suse.cz>, <linux-btrfs@vger.kernel.org>,
Josef Bacik <jbacik@fb.com>, Chris Mason <clm@fb.com>
Subject: Re: [PATCH] btrfs: Don't continue mounting when superblock csum mismatches even generation is less than 10.
Date: Wed, 20 Aug 2014 09:16:20 +0800 [thread overview]
Message-ID: <53F3F6E4.6070406@cn.fujitsu.com> (raw)
In-Reply-To: <20140819171842.GC1553@twin.jikos.cz>
-------- Original Message --------
Subject: Re: [PATCH] btrfs: Don't continue mounting when superblock csum
mismatches even generation is less than 10.
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2014年08月20日 01:18
> On Thu, Aug 07, 2014 at 10:51:15AM +0800, Qu Wenruo wrote:
>> It seems that the patch is rejected in patchwork,
> It was not me :)
>
>> Could any one tell me the reason?
> I'd understand that the patch is no longer needed after the original
> problem went away, but it's not what you describe in your changelog.
> From that point the reason might not be compelling.
>
>>> Above commit will cause disaster if someone try to mount a newly created but
>>> later corrupted btrfs filesystem.
> The generation after mkfs is something like 4 or 5, this means that the
> corruption would have to happen in the first few transaction commits,
> this is unlikely and the filesystem will be probably fairly empty at
> that time.
>
> If the concern is about corrupted generation counter itself in the
> superblock, then yes this could hurt.
>
> It's still possible to compare the 1st superblock with the copies, the
> one at offset 64M is available in 99%, there are enough data to make a
> decision what's actually corrupted. This could catch more corruption
> than just the generation counter.
>
> From the output of btrfs-show-super:
>
> generation 56392
> chunk_root_generation 56392
> cache_generation 56392
> uuid_tree_generation 56392
>
> the generation is duplicated several times, so a minimal patch could be
> to do additional comparison with the others.
Thanks for the explaination.
But in fact, when investigating some bugs (not kernel bugzilla but
proprietary one), I found not only one but two
disk images whose superblock csum doesn't match and a lot of values go
crazy.
For example, num_devices goes to 871878361089 and serval bits diffs in
dev_item.fsid and fsid.
BTW, cache generation is also crazy.
Normally, such superblock should not be mountable since the csum doesn't
match.
But due to the mentioned commit, the generation (4) is below 10 and
kernel just ignore the csum error,
and finally, a kernel BUG is triggered, since a lot of things go wrong
anything is possible.
So I sent the patch and hope to avoid such problem.
Thanks,
Qu
>
>>> And before btrfs entered mainline, btrfs-progs has already superblock
>>> checksum. See btrfs-progs commit: 5ccd1715fa2eaad0b26037bb53706779c8c93b5f
>>> (superblock duplication by Yan Zheng).
> The superblock checksum was not calculated the same way as in kernel,
> but with the missing check this was not detected.
>
>>> Before commit 5ccd17, mkfs.btrfs uses 16K as super offset, while current btrfs
>>> uses 64K super offset, anyway old btrfs without super csum will not be
>>> mountable due to the change of super offset.
>>>
>>> So backward compatibility is not a problem.
> Superblocks at offset 16k are not supported anymore AFAICT.
next prev parent reply other threads:[~2014-08-20 1:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 8:49 [PATCH] btrfs: Don't continue mounting when superblock csum mismatches even generation is less than 10 Qu Wenruo
2014-08-07 2:51 ` Qu Wenruo
2014-08-19 17:18 ` David Sterba
2014-08-20 1:16 ` Qu Wenruo [this message]
2014-08-19 19:48 ` Chris Mason
2014-08-20 2:34 ` Qu Wenruo
2014-08-25 15:28 ` David Sterba
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=53F3F6E4.6070406@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=clm@fb.com \
--cc=dsterba@suse.cz \
--cc=jbacik@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.