[solid] Notify when interface to mounted fs is lost
AbandonedPublic

Authored by anthonyfieroni on Jul 3 2018, 2:39 PM.

Details

Summary

Mostly mounted directory are empty when they are umounted

CCBUG: 394348

Test Plan

Not tested, it's kid of idea. hope someone can share better experience.

Diff Detail

Repository
R245 Solid
Lint
Lint Skipped
Unit
Unit Tests Skipped
anthonyfieroni created this revision.Jul 3 2018, 2:39 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJul 3 2018, 2:39 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
anthonyfieroni requested review of this revision.Jul 3 2018, 2:39 PM
anthonyfieroni edited the summary of this revision. (Show Details)

Add loop interface

aacid resigned from this revision.Jul 3 2018, 10:06 PM

Removing myself i don't think i know much/anything about solid, sorry

bruns added a subscriber: bruns.Jul 4 2018, 12:12 AM
bruns added inline comments.
src/solid/devices/backends/udisks2/udisksmanager.cpp
220

This code needs some restructuring, and with the additional conditions, some comments ...

  1. if (udi.isEmpty()) return;
  2. you are whitelisting a lot of conditions (... || .. || ...) - are the any cases left where the signal is not emitted?
  1. Return early when path is empty
  2. Don't check for empty interfaces
src/solid/devices/backends/udisks2/udisksmanager.cpp
220

According to docs, https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager, interfaces should not be empty but a dict of looses ones.

I don't think this is the right approach, technically the device isn't gone but filtered by the client (KFilePlacesModel and Device Notifier use a predicate to show only matching devices).
This probably needs some "device changed" signal, or even cooler, in Solid::Predicate a tracker that signals "the devices that match this predicate changed" but this is probably quite difficult to achieve

So if KFilePlacesModel wants to hide, i don't see how this will break things, it only notify when udisk2 loose interface to mounted fs.

Sure, but the device isn't "removed", so emitting a remove signal for something that is still there, is wrong, isn't it? Perhaps we could signal a removal if the device lost *all* its interfaces? But it probably doesn't in the unmount case.

So about docs when interface is added it will notify again for mounting, i think that's the idea behind interfaces.

bruns added a comment.Jul 4 2018, 3:05 PM

Sure, but the device isn't "removed", so emitting a remove signal for something that is still there, is wrong, isn't it? Perhaps we could signal a removal if the device lost *all* its interfaces? But it probably doesn't in the unmount case.

a valid device/dbus object has at least the org.freedesktop.DBus.Properties interface, so this signal is already emitted when the device is removed (== last interface removed).

I think the code needs some overhauling - AFAIK it was written when UDisks2 had a much more simplistic interface. The whole properties cache is quite broken ("something has changed - throw away the cache - fetch everything again" , "we don't know the property - lets fetch it again"), we are doing to many roundtrips.

The list of properties is announced in the DBus introspection data for each interface. There is no need for the "negative" cache. We are mixing properties from different interfaces (e.g. size, a filesystem size may differ from the partition size).

While the intention of the patch is right, I don't think its the right way to do it. I would favor a solution which signals changes in the Predicate matches. This is definitely more work, but otherwise we are papering over one issue after the other.

anthonyfieroni added a comment.EditedJul 4 2018, 3:55 PM

I'm aware that does not have an idea, what is the purpose of Predicate. What should i search in Solid::Predicate::matches?

Predicates are Solid's query language for searching for only the devices you are interested in.

First tests looks good, i'll make more later

anthonyfieroni added a comment.EditedJul 22 2018, 4:02 PM
Performing working tests

- mount -o loop xxx.iso /mnt/xxx

- mount xxx.iso /mnt/xxx

- Add Android phone

- Add second phone, first become inactive, second works
anthonyfieroni added a comment.EditedJul 23 2018, 4:42 AM

Mounting by cdemu also works as expected, not without patch as is described in bug report.

bruns added inline comments.Jul 23 2018, 11:37 AM
src/solid/devices/backends/udisks2/udisksmanager.cpp
220

This does not answer my question. What I need from you is:

  • which interfaces are in interfaces
  • which interfaces are in device.interfaces()

so the exact case where the patched code triggers, but the old does not.

src/solid/devices/backends/udisks2/udisksmanager.cpp
220

Old code is complete broken, about me, it does not check any interface except that it's empty.

src/solid/devices/backends/udisks2/udisksmanager.cpp
220

In which cases what you to know the interfaces?

bruns added inline comments.Jul 23 2018, 11:49 AM
src/solid/devices/backends/udisks2/udisksmanager.cpp
220

Can you please just answer the question?

anthonyfieroni added a comment.EditedJul 23 2018, 11:57 AM

mount mini.iso /mnt/mini/
umount /mnt/mini
Device(udi).interfaces() ("org.freedesktop.UDisks2.Loop", "org.freedesktop.UDisks2.Block")
interfaces ("org.freedesktop.UDisks2.Filesystem")

Ping, anything unclear ?

ngraham added a subscriber: ngraham.Aug 5 2018, 4:07 AM

FWIW, we got a thumbs up from someone in https://bugs.kde.org/show_bug.cgi?id=394348:

Nick Stefanov 2018-08-02 06:59:28 MDT

I get the Antony's patch from here:
https://phabricator.kde.org/D13869
I use it two weeks already and so far I haven't any problems at all. The patch works flawlessly for me.
Kudos to anthonyfieroni for providing fix for this annoying problem.

bruns requested changes to this revision.Aug 5 2018, 3:54 PM

The change needs a proper commit message. A reference to the bug tracker is not sufficient.

The commit message should (at least) include:

  • Description of the setup
    • The UDI of the relevant Solid device
    • The UDIs of its parents
    • Relevant Solid attributes of the devices, e.g. from solid-hardware details
  • Description of the actions done
  • Old and new behaviour

Think of what happens if anyone changes the code later. The person must be able to replicate the setup, to check if any further changes break the code.

src/solid/devices/backends/udisks2/udisksmanager.cpp
222 ↗(On Diff #37108)

According to your description (which is hard to follow, because you refrain from writing complete sentences), what triggers here is the removal of the o.f.U2.FileSystem interface. There is no reasoning why the Loop interface matters here.

This revision now requires changes to proceed.Aug 5 2018, 3:54 PM
bruns added a comment.Aug 5 2018, 3:59 PM

FWIW, we got a thumbs up from someone in https://bugs.kde.org/show_bug.cgi?id=394348:

A thumbs up is nice, but this does not catch the thumbs down of all the persons who are exposed to the changed code later, having a different setup. We have seen this in solid several times lately, because every change was only checked to "fix" a non-working case, but omitted all the other cases.

Every change should both be checked in a real setup, and have a sound reasoning behind it why it is correct.

anthonyfieroni added a comment.EditedAug 5 2018, 5:11 PM

Since you make question to new code I make for old one, did you know why Device interfaces is ever used, it's look wrong and why interfaces should be empty, after all my tests, it's easy to see that they are never empty.

anthonyfieroni added a comment.EditedAug 5 2018, 5:22 PM

About loop device it should present as well
http://storaged.org/doc/udisks2-api/2.6.3/gdbus-org.freedesktop.UDisks2.Loop.html
After all you have ony hypothetical arguments, if you know case that this code not work let's discuss, till then this is right approach.

bruns added a comment.Aug 5 2018, 5:56 PM

About loop device it should present as well
http://storaged.org/doc/udisks2-api/2.6.3/gdbus-org.freedesktop.UDisks2.Loop.html
After all you have ony hypothetical arguments, if you know case that this code not work let's discuss, till then this is right approach.

Of course it is present for a loop device, but this is about removed aka lost interfaces.

These are not hypothetical arguments, but practical arguments.

bruns added a comment.Aug 5 2018, 6:23 PM

Since you make question to new code I make for old one, did you know why Device interfaces is ever used, it's look wrong and why interfaces should be empty, after all my tests, it's easy to see that they are never empty.

Thats trivial - remove the device if *all* interfaces have been removed. And thats correct, otherwise you can no longer call any solid method on the device.

And thinking about it, this very likely makes your code wrong. Have you tried mounting a filesystem again after unmounting it, using via any mean implemented via solid? That is, "solid-hardware mount ...", the device notifier, ...

And thinking about it, this very likely makes your code wrong. Have you tried mounting a filesystem again after unmounting it, using via any mean implemented via solid? That is, "solid-hardware mount ...", the device notifier, ...

So write an example with commands, mounting, umounting flash drive, which is a filesystem, works.