All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: "Qu Wenruo" <quwenruo.btrfs@gmx.com>, "Qu Wenruo" <wqu@suse.com>,
	"Luca Béla Palkovics" <luca.bela.palkovics@gmail.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: repair super block num_devices automatically
Date: Wed, 20 Apr 2022 17:42:00 +0200	[thread overview]
Message-ID: <20220420154200.GG1513@twin.jikos.cz> (raw)
In-Reply-To: <c8009e2d-7569-4dec-3745-e9c3718ec57c@oracle.com>

On Mon, Feb 28, 2022 at 08:51:30PM +0800, Anand Jain wrote:
> >>> I didn't get your point.
> >>> What do you want to get from this patch?
> >>>
> >>> Isn't this already the behavior of this patch?
> >>
> >>   Let me clarify - we don't need this patch if we fix the actual bug as
> >> above. IMO.
> > 
> > Big NO NO.
> > 
> > The damage is already done, we must be responsible for whatever damage
> > we caused, especially the damage has already reached disk.
> > 
> > Just fixing the cause and call it a day is definitely not a responsible 
> > way.
> > 
> > Especially when the damage is done, you have no way to mount it, just
> > like the reporter.
> > 
> > You dare to say the same thing to the end user?
> 
> You have a btrfs-progs patch to recover from that situation. Right?
> Plus, I suppose you are sending a kernel patch for the actual bug
> which is causing this corruption. No?

Normally we'd have just the repair code in check, but this is sometimes
difficult to run eg. on a root filesystem, or if the boot fails because
some mount fails and ends up in the rescue environment with limited
options.

> This patch is the reporter side fix. I don't encourage fixing the
> reporter because a similar corruption might happen for reasons unknown
> yet. For example, raid1 split-brain? Which is not yet completely
> analyzed and test-cased yet.

So that's a valid question if the auto-repair should be done or not in
kernel. But an offline repair would do the same thing, read number of
device items and set the num_devices. The decision on kernel side at
mount or by user when running btrfs check has the same amount of
information, so forcing user to do offline repair is a bit less
convenient.

The num_devices is basically a cached value of the number of device
items, used in many places as a shortcut so we don't have to count them
each time. Once we make sure that the numbers are in sync, it's the
correct stat. We know about one scenario where it would get out of sync,
now fixed, so the simple auto repair is IMHO safe.

For the raid1 split brain, I can't tell and if you say it's not analyzed
properly we'd have to rely on other mechanisms to catch the
inconsistency. Eg. a missing physical device would be recognized and
would require degraded mount, but it's unrelated to the value of
num_devices.

  parent reply	other threads:[~2022-04-20 15:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28  7:05 [PATCH v2] btrfs: repair super block num_devices automatically Qu Wenruo
2022-02-28  8:00 ` Anand Jain
2022-02-28  8:54   ` Qu Wenruo
2022-02-28  9:01     ` Anand Jain
2022-02-28  9:21       ` Qu Wenruo
2022-02-28 12:51         ` Anand Jain
2022-02-28 13:03           ` Qu Wenruo
2022-02-28 13:13             ` Luca Béla Palkovics
2022-02-28 13:29               ` Qu Wenruo
2022-04-20 15:42           ` David Sterba [this message]
2022-04-25 17:07             ` Anand Jain

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=20220420154200.GG1513@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=luca.bela.palkovics@gmail.com \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=wqu@suse.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 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.