Bug 807377

Summary: Problems with 2 identical DVD burners
Product: [openSUSE] openSUSE 12.2 Reporter: Klaus Zeitler <info>
Component: BasesystemAssignee: E-mail List <gnome-bugs>
Status: RESOLVED UPSTREAM QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: ncutler, paolo.roascio
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 12.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Fixes device recognition in case of same wwn or same serial/model

Description Klaus Zeitler 2013-03-04 22:14:46 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0

recently installed OpenSUSE 12.2 on a PC with 2 identical DVD SATA burners.
It seems Gnome has now problems in differentiating both DVDs.

For DVD1 I get an icon when I insert e.g. an audio disc. But when I click
on "Mount Volume" Gnome selects the wrong device (sr0), i.e. I see in
/run/user/klaus/gvfs:
cdda mount on sr0
but the directory is empty. When I select e.g. "eject", the try of the 2nd
DVD opens instead.
But if I now mount sr1 with "gvfs-mount cdda://sr1", I see the CDs tracks
in "/run/user/klaus/gvfs/cdda mount on sr1".

DVD2 is totally ignored by Gnome, i.e. I don't even get an icon on
the desktop when I insert an audio disc.


I have no idea if the problem is related to the GVFS or udev or whatever.
But it looks to me as if the mapping to /dev/sr0 and /dev/sr1 is messed up.

My first suspect was udev, but looking at the rules, I can't see anything
peculiar:

--- snip ---

$ cat /etc/udev/rules.d/70-persistent-cd.rules
# This file was automatically generated by the /lib/udev/write_cd_rules
# program, run by the cd-aliases-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and set the $GENERATED variable.

# HL-DT-ST_DVDRAM_GH24NS90 (pci-0000:00:11.0-scsi-4:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-4:0:0:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-4:0:0:0", SYMLINK+="cdrw", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-4:0:0:0", SYMLINK+="dvd", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-4:0:0:0", SYMLINK+="dvdrw", ENV{GENERATED}="1"

# HL-DT-ST_DVDRAM_GH24NS90 (pci-0000:00:11.0-scsi-2:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-2:0:0:0", SYMLINK+="cdrom1", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-2:0:0:0", SYMLINK+="cdrw1", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-2:0:0:0", SYMLINK+="dvd1", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:11.0-scsi-2:0:0:0", SYMLINK+="dvdrw1", ENV{GENERATED}="1"

--- snip ---

Then I tried to look into hwinfo and I'm astonished to see that both
DVDs use the same WWN under "Device Files" (hwinfo --cdrom):
/dev/disk/by-id/wwn-0x5001480000000000


And in /dev/disk/by-id I see a link to sr1 but no link to sr0:
ls -l /dev/disk/by-id/wwn-0x5001480000000000
lrwxrwxrwx 1 root root 9 Feb 13 23:41 /dev/disk/by-id/wwn-0x5001480000000000 -> ../../sr1


And similar "udevadm info --query=all --name=/dev/sr1" and
"udevadm info --query=all --name=/dev/sr0" also show the same ID
in DEVLINKS:
/dev/disk/by-id/wwn-0x5001480000000000


I thought that the ID must be unique. But then again I don't know much
about hardware, udev etc. Maybe the problem lies in the GVFS. Or what
else could cause this?

Just tried KDE and there both DVDs are usable. But I can't figure out
how/if KDE mounts the DVDs. I see that sr0 and sr1 are used.
I don't like KDE and prefer to use XFCE. But there as well as with Gnome
I have the problem I described.

I don't believe that it's a Gnome problem. To me the hwinfo output looks
as if udev already messed it up. As I already said, there's only one link
in /dev/disk/by-id:
wwn-0x5001480000000000 -> ../../sr1

I guess that the link for sr0 gets overwritten. When I change this link
to sr0, Gnome now recognizes the other DVD instead. This is evidence for
me that it has something to do with the WWN.

The output of "hwinfo --cdrom" looks odd to me,cause both DVDs show they same WWN and they also both show /dev/cdrom:

  Device Files: /dev/sr0, /dev/cdrom, /dev/cdrom1, /dev/cdrw1, /dev/disk/by-id/ata-HL-DT-ST_DVDRAM_GH24NS90_KGQBCF95545, /dev/disk/by-id/wwn-0x5001480000000000, /dev/disk/by-path/pci-0000:00:11.0-scsi-2:0:0:0, /dev/dvd1, /dev/dvdrw1

  Device Files: /dev/sr1, /dev/cdrom, /dev/cdrw, /dev/disk/by-id/ata-HL-DT-ST_DVDRAM_GH24NS90_K37C3OA2153, /dev/disk/by-id/wwn-0x5001480000000000, /dev/disk/by-path/pci-0000:00:11.0-scsi-4:0:0:0, /dev/dvd, /dev/dvdrw


Reproducible: Always

Steps to Reproduce:
1.boot, then use e.g. XFCE as session manager
2.insert a CD in DVD1, an icon appears on the desktop and all the other problems
  described above exist. DVD2 is ignored
3. Both DVDs are unusable
Comment 1 Paolo Roascio 2013-04-28 20:26:18 UTC
Hello, sorry for my bad english,

I had exactly the same problem in openSUSE 12.3 with two Sony OPTIARC AD-7261S:
only /dev/sr0 was linked in /dev/disk/by-id.

Despite this, kde was able to "use" both disks (if units are empty, information center reports only one device - sr1, but if i load two dvd, the "only one" device reports both disks - like a multitray unit). But worse, k3b only saw sr1...

Investigating a bit, i discovered that half problem is due to udisks and half to udev:

- undev reports, for my units, same ID_MODEL and ID_SERIAL, then, in udev rules, the latter overvrite the former in symlinking (this is the reason why in /dev/disk/by-id is present only sr1.

- udisks2 exports node data according to its order of preference: WWN, SERIAL, PATH. in case of optical units (at least mine), the WWN data is skipped to the SERIAL one, but, being identical, one unit is "skipped" and here too dbus based services can see only one device.

Googling around, i found this bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=887979

(related to a particular family of SSD units whith identical WWN, but different ID_SERIAL)

which pointed me in the right direction. Then i attach a patch which solves both problems: the solution for the SSD is explained in the bugreport and its attached patch (WWN data is expanded with SERIAL data), my (ugly) hack - i'm not a programmer - is: if WWN step is skipped, then process tries the SERIAL step, this is matched only if ID_SERIAL != ID_MODEL, otherwise process tries the PATH step.

I don't know if LG devices expose same ID_NAME and ID_SERIAL, but the patch covers both cases.

Maybe this is a workaround?

Acording to udevadm info -n /dev/sr[0,1], nodes that make them unique devices are - in my case - ID_PATH and MINOR, then, using %n should not be difficult to write a rule to differentiate symlinks in /dev/disk/by-id
Comment 2 Paolo Roascio 2013-04-29 14:47:10 UTC
Created attachment 537297 [details]
Fixes device recognition in case of same wwn or same serial/model
Comment 3 Nathan Cutler 2017-08-14 15:31:38 UTC
Aging bug against out-of-maintenance openSUSE 12.2. It might be more expedient to submit the patch to the upstream ("Udisks") project. Since the udisks2 package is regularly updated from upstream, the fix would reach openSUSE in due course.