From: Ratna Manoj <manoj.br@gmail.com>
To: Wouter Verhelst <w@uter.be>, Markus Pargmann <mpa@pengutronix.de>
Cc: nbd-general@lists.sourceforge.net,
Vinod Jayaraman <jv@portworx.com>,
jack@suse.cz, linux-kernel@vger.kernel.org,
Gou Rao <grao@portworx.com>,
pbonzini@redhat.com
Subject: Re: [Nbd] [PATCH] NBD: replace kill_bdev() with __invalidate_device()
Date: Fri, 29 Apr 2016 00:13:42 +0530 [thread overview]
Message-ID: <572259DE.7070600@gmail.com> (raw)
In-Reply-To: <20160428162734.GA3082@grep.be>
Hi,
On Thursday 28 April 2016 09:57 PM, Wouter Verhelst wrote:
> On Thu, Apr 28, 2016 at 11:00:20AM +0200, Markus Pargmann wrote:
>> Hi,
>>
>> On Saturday 23 April 2016 07:47:21 Ratna Manoj wrote:
>>> Thanks for the review.
>>>
>>> Atleast for ext4 this crash happens on a sys_umount() call, timing of
>>> which is not in control of block driver. Block driver cannot force the
>>> filesystems to be unmounted, and the file system does not expect
>>> buffers to get unmapped under it.
>> Yes the block driver can't force a clean umount.
>>
>>> Ext4 can be fixed with the this patch:
>>> http://www.spinics.net/lists/linux-ext4/msg51112.html
>>> It did not make to the kernel. It checks the state of the buffer head
>>> before committing.
>>>
>>> When we consider diskett/CD as user space thread that called NBD_DO_IT,
>>> this problem is analogous to changing disk with another or the same
>>> disk suddenly when the file system is still mounted.
>>>
>>> If we completely kill the block device we would loss some writes when
>>> same thread is reconnected.
>> I am not so sure about your exact use-case here.
>>
>> If the NBD_DO_IT thread returns I am considering the connection and
>> block device as dead and disconnected. Securing any data afterwards with
>> a new connection is potentially dangerous as it may be a different
>> server.
> Yes, from the kernel POV you're right.
>
> However, at some point I agreed with Paul (your predecessor) that when
> this happens due to an error condition (as opposed to it being due to an
> explicit disconnect), the kernel would block all reads from or writes to
> the device, and the client may try to reconnect *from the same
> PID* (i.e., it may not fork()). If that succeeds, the next NBD_DO_IT is
> assumed to be connected to the same server; if instead the process
> exits, then the block device is assumed to be dead, will be reset, and
> all pending reads or writes would error.
>
> In principle, this allows for a proper reconnect from userspace if it
> can be done. However, I'm not sure whether this ever worked well or
> whether it was documented, so it's probably fine if you think it should
> be replaced with something else.
>
> (obviously, userspace reconnecting the device to a different device is
> wrong and should not be done, but that's a case of "if you break it, you
> get to keep both pieces)
>
> At any rate, I think it makes sense for userspace to be given a chance
> to *attempt* to reconnect a device when the connection drops
> unexpectedly.
To summarize different options we have:
1. Wait for all the buffers to get cleaned:
a) ... at the time of disconnect:
Not possible, because we can neither force upper layers to do the required
(ext4 umount crash scenario), nor kill mapped buffers unconditionally.
b) ... after disconnect, fail next reconnect with EBUSY if bd_openers > 1:
This would prevent even harmless reconnects from same device along with
problematic different device reconnects.
2. Do not wait for all buffers to get cleaned:
a) This particular patch does this. Inconsistency with a different device
reconnect is its disadvantage.
We may want to give preference same device reconnects as it is not rare.
(For floppy/cdrom disk drivers also, changing disk with different disk in the
middle results in inconsistency, and they left this case as user responsibility
to not do it.)
-Ratna
next prev parent reply other threads:[~2016-04-28 18:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <56E711D1.9090708@gmail.com>
[not found] ` <2358965.KUbuAa1sts@adelgunde>
[not found] ` <56F34412.1050707@gmail.com>
2016-04-20 11:06 ` [PATCH] NBD: replace kill_bdev() with __invalidate_device() Markus Pargmann
2016-04-23 2:17 ` Ratna Manoj
2016-04-28 9:00 ` Markus Pargmann
2016-04-28 16:27 ` [Nbd] " Wouter Verhelst
2016-04-28 18:43 ` Ratna Manoj [this message]
2016-05-12 9:53 ` Markus Pargmann
2016-05-15 12:55 ` Wouter Verhelst
2016-05-19 6:35 ` Markus Pargmann
2016-05-24 15:17 ` Wouter Verhelst
2016-05-10 9:24 ` Paolo Bonzini
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=572259DE.7070600@gmail.com \
--to=manoj.br@gmail.com \
--cc=grao@portworx.com \
--cc=jack@suse.cz \
--cc=jv@portworx.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpa@pengutronix.de \
--cc=nbd-general@lists.sourceforge.net \
--cc=pbonzini@redhat.com \
--cc=w@uter.be \
/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.