From: Qu Wenruo <wqu@suse.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3] btrfs: Do super block verification before writing it to disk
Date: Thu, 19 Apr 2018 07:24:43 +0800 [thread overview]
Message-ID: <55dd6f1f-c45f-ca91-f959-0d625129f5de@suse.com> (raw)
In-Reply-To: <20180418220432.GV21272@twin.jikos.cz>
[-- Attachment #1.1: Type: text/plain, Size: 1588 bytes --]
On 2018年04月19日 06:04, David Sterba wrote:
> On Tue, Apr 17, 2018 at 09:47:19AM +0800, Qu Wenruo wrote:
>> @@ -2680,7 +2681,7 @@ int open_ctree(struct super_block *sb,
>>
>> memcpy(fs_info->fsid, fs_info->super_copy->fsid, BTRFS_FSID_SIZE);
>>
>> - ret = btrfs_check_super_valid(fs_info);
>> + ret = btrfs_check_super_valid(fs_info, fs_info->super_copy);
>> if (ret) {
>> btrfs_err(fs_info, "superblock contains fatal errors");
>> err = -EINVAL;
>> @@ -3310,6 +3311,27 @@ static int write_dev_supers(struct btrfs_device *device,
>
> This is in write_dev_supers, so the superblock is checked
> number-of-devices times. The caller write_all_supers rewrites the device
> item so it matches the device it's going to write to. But,
> btrfs_check_super_valid does not validate the dev_item so all the
> validation does not bring much benefit, as it repeatedly checks the same
> data.
>
> So, what if the validation is done only once in write_all_supers? Lock
> the devices, validate, if it fails, report that and unlock devices and
> go readonly.
Makes sense.
I'll update btrfs_check_super_valid() to cooperate with that in next update.
Thanks,
Qu
>
> There's a differnce to what you implemented: if the in-memory superblock
> corruption happens between writing to the devices, there are some left
> with the new superblock and some with the old.
>
> Although this sounds quite improbable, I think that doing the check in
> advance would save some trouble if that happens. The superblocks on all
> devices will match.
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2018-04-18 23:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 1:47 [PATCH v3] btrfs: Do super block verification before writing it to disk Qu Wenruo
2018-04-17 9:05 ` [PATCH] " Anand Jain
2018-04-17 9:58 ` Qu Wenruo
2018-04-17 14:32 ` Anand Jain
2018-04-17 14:44 ` Qu Wenruo
2018-04-18 22:04 ` [PATCH v3] " David Sterba
2018-04-18 23:24 ` Qu Wenruo [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=55dd6f1f-c45f-ca91-f959-0d625129f5de@suse.com \
--to=wqu@suse.com \
--cc=dsterba@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox