On Tue, Jun 16, 2020 at 10:30:03PM +0000, Anchal Agarwal wrote: > On Tue, Jun 16, 2020 at 09:49:25PM +0000, Anchal Agarwal wrote: > > On Thu, Jun 04, 2020 at 09:05:48AM +0200, Roger Pau Monné wrote: > > > On Wed, Jun 03, 2020 at 11:33:52PM +0000, Agarwal, Anchal wrote: > > > > On Tue, May 19, 2020 at 11:27:50PM +0000, Anchal Agarwal wrote: > > > > > From: Munehisa Kamata <kamatam@xxxxxxxxxx> > > > > > + xenbus_dev_error(dev, err, "Freezing timed out;" > > > > > + "the device may become inconsistent state"); > > > > > > > > Leaving the device in this state is quite bad, as it's in a closed > > > > state and with the queues frozen. You should make an attempt to > > > > restore things to a working state. > > > > > > > > You mean if backend closed after timeout? Is there a way to know that? I understand it's not good to > > > > leave it in this state however, I am still trying to find if there is a good way to know if backend is still connected after timeout. > > > > Hence the message " the device may become inconsistent state". I didn't see a timeout not even once on my end so that's why > > > > I may be looking for an alternate perspective here. may be need to thaw everything back intentionally is one thing I could think of. > > > > > > You can manually force this state, and then check that it will behave > > > correctly. I would expect that on a failure to disconnect from the > > > backend you should switch the frontend to the 'Init' state in order to > > > try to reconnect to the backend when possible. > > > > > From what I understand forcing manually is, failing the freeze without > > disconnect and try to revive the connection by unfreezing the > > queues->reconnecting to backend [which never got diconnected]. May be even > > tearing down things manually because I am not sure what state will frontend > > see if backend fails to to disconnect at any point in time. I assumed connected. > > Then again if its "CONNECTED" I may not need to tear down everything and start > > from Initialising state because that may not work. > > > > So I am not so sure about backend's state so much, lets say if xen_blkif_disconnect fail, > > I don't see it getting handled in the backend then what will be backend's state? > > Will it still switch xenbus state to 'Closed'? If not what will frontend see, > > if it tries to read backend's state through xenbus_read_driver_state ? > > > > So the flow be like: > > Front end marks XenbusStateClosing > > Backend marks its state as XenbusStateClosing > > Frontend marks XenbusStateClosed > > Backend disconnects calls xen_blkif_disconnect > > Backend fails to disconnect, the above function returns EBUSY > > What will be state of backend here? > > Frontend did not tear down the rings if backend does not switches the > > state to 'Closed' in case of failure. > > > > If backend stays in CONNECTED state, then even if we mark it Initialised in frontend, backend > > won't be calling connect(). {From reading code in frontend_changed} > > IMU, Initialising will fail since backend dev->state != XenbusStateClosed plus > > we did not tear down anything so calling talk_to_blkback may not be needed > > > > Does that sound correct? > Send that too quickly, I also meant to add XenBusIntialised state should be ok > only if we expect backend will stay in "Connected" state. Also, I experimented > with that notion. I am little worried about the correctness here. > Can the backend come to an Unknown state somehow? Not really, there's no such thing as an Unknown state. There are no guarantees about what a backend can do really, so it could indeed switch to a not recognized state, but that would be a bug in the backend. Roger.