From: Andrei Borzenkov <arvidjaar@gmail.com>
To: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>,
	Chris Murphy <lists@colorremedies.com>,
	Nikolaus Rath <Nikolaus@rath.org>
Cc: Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: fsck: to repair or not to repair
Date: Mon, 16 May 2016 14:34:05 +0300	[thread overview]
Message-ID: <5739B02D.2020203@gmail.com> (raw)
In-Reply-To: <60824d00-56c4-8f83-34e2-07fc99ca3c8b@gmail.com>
16.05.2016 14:17, Austin S. Hemmelgarn пишет:
> On 2016-05-13 17:35, Chris Murphy wrote:
>> On Fri, May 13, 2016 at 9:28 AM, Nikolaus Rath <Nikolaus@rath.org> wrote:
>>> On May 13 2016, Duncan <1i5t5.duncan@cox.net> wrote:
>>>> Because btrfs can be multi-device, it needs some way to track which
>>>> devices belong to each filesystem, and it uses filesystem UUID for this
>>>> purpose.
>>>>
>>>> If you clone a filesystem (for instance using dd or lvm snapshotting,
>>>> doesn't matter how) and then trigger a btrfs device scan, say by
>>>> plugging
>>>> in some other device with btrfs on it so udev triggers a scan, and the
>>>> kernel sees multiple devices with the same filesystem UUID as a result,
>>>> and one of those happens to be mounted, you can corrupt both copies as
>>>> the kernel btrfs won't be able to tell them apart and may write updates
>>>> to the wrong one.
>>>
>>> That seems like a rather odd design. Why isn't btrfs refusing to mount
>>> in this situation? In the face of ambiguity, guessing is generally bad
>>> idea (at least for a computer program).
>>
>> The logic  you describe requires code. It's the absence of code rather
>> than an intentional design that's the cause of the current behavior.
>> And yes, it'd be nice if Btrfs weren't stepping on its own tail in
>> this situation. It could be as simple as refusing to mount anytime
>> there's an ambiguity, but that's sorta user hostile if there isn't a
>> message that goes along with it to help the user figure out a way to
>> resolve the problem. And that too could be fraught with peril if the
>> user makes a mistake. So, really what's the right way to do this is
>> part of the problem but I agree it's better to be hostile and refuse
>> to mount a given volume UUID at all when too many devices are found,
>> than corrupt the file system.
>>
> FWIW, the behavior I'd expect from a sysadmin perspective would be:
> 1. If and only if a correct number of device= options have been passed
> to mount, use those devices (and only those devices), and log a warning
> if extra devices are detected.
First, how do you know that devices, passed as device= options, are
correct? Is it possible to detect stale copy?
Second, today udev rules will run equivalent of "btrfs device ready" for
each device that is part of btrfs. So you still need to handle the
situation when device(s) appear and disappear after initial mount and
have some way to distinguish between two copies.
Third, what exactly "extra devices detected" means? Who is responsible
for detection? Where this information is kept? How can mount query this
information?
> 2. Otherwise, refuse to mount and log a warning.
So no way to mount degraded redundant filesystem?
next prev parent reply	other threads:[~2016-05-16 11:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 21:10 fsck: to repair or not to repair Nikolaus Rath
2016-05-12 17:02 ` Henk Slager
2016-05-12 17:35   ` Nikolaus Rath
2016-05-12 17:55     ` Ashish Samant
2016-05-13  6:36   ` Duncan
2016-05-13 15:28     ` Nikolaus Rath
2016-05-13 21:35       ` Chris Murphy
2016-05-16 11:17         ` Austin S. Hemmelgarn
2016-05-16 11:34           ` Andrei Borzenkov [this message]
2016-05-16 11:48             ` Austin S. Hemmelgarn
2016-06-10  3:40 ` Nikolaus Rath
2016-06-10 11:05   ` Austin S. Hemmelgarn
2016-06-10 15:54     ` Nikolaus Rath
2016-06-10 16:50       ` Adam Borowski
2016-06-10 16:55         ` Nikolaus Rath
2016-06-10 17:12         ` Austin S. Hemmelgarn
2016-06-10 17:22           ` Adam Borowski
2016-06-10 17:39             ` Austin S. Hemmelgarn
2016-06-10 17:40             ` Henk Slager
2016-06-10 15:55     ` Nikolaus Rath
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=5739B02D.2020203@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=Nikolaus@rath.org \
    --cc=ahferroin7@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.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 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).