Bug 675449

Summary: growisofs fails: CD_ROM_MEDIA_CHANGED, Inappropriate ioctl for device
Product: [Fedora] Fedora Reporter: John Reiser <jreiser>
Component: dvd+rw-toolsAssignee: Honza Horak <hhorak>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: hhorak
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-03-01 11:34:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description John Reiser 2011-02-05 17:57:45 UTC
Description of problem: growisofs fails for new .iso onto DVD+RW with existing contents.


Version-Release number of selected component (if applicable):
dvd+rw-tools-7.1-5.fc14.x86_64
kernel-2.6.38-0.rc3.git4.1.fc15.x86_64

How reproducible: every time


Steps to Reproduce:
1.growisofs -dvd-compat -Z /dev/dvd=foo.iso
2.
3.
  
Actual results: Error exit with:
-----
:-( /dev/dvd: CD_ROM_MEDIA_CHANGED... Inappropriate ioctl for device
-----

Expected results: successful write


Additional info:
Always fails    for every 2.6.38 kernel so far.
Always succeeds for any   2.6.37 kernel.

Hardware is commodity MMC3 DVD writer with SATA interface.

The relevant info from an strace on failing 2.6.38 kernel is:
-----
1338  open("/dev/dvd", O_RDONLY)        = 4
1338  fstat(4, {st_mode=S_IFBLK|0660, st_rdev=makedev(11, 0), ...}) = 0
1338  open("/dev/dvd", O_RDWR|O_NONBLOCK) = 5
1338  fstat(5, {st_mode=S_IFBLK|0660, st_rdev=makedev(11, 0), ...}) = 0
1338  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=0, flags=0x3, data[36]=["\5\200\0052[\0\0\0Optiarc DVD RW AD-7240S "...], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=0, info=0}) = 0
1338  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[46, 00, 00, 00, 00, 00, 00, 00, 08, 00], mx_sb_len=64, iovec_count=0, dxfer_len=8, timeout=0, flags=0x3, data[8]=["\0\0\1P\0\0\0\32"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=4, info=0}) = 0
1338  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[51, 00, 00, 00, 00, 00, 00, 00, 20, 00], mx_sb_len=64, iovec_count=0, dxfer_len=32, timeout=0, flags=0x3, data[32]=["\0 \36\1\1\1\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=1, info=0}) = 0
1338  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[23, 00, 00, 00, 00, 00, 00, 00, 0c, 00], mx_sb_len=64, iovec_count=0, dxfer_len=12, timeout=0, flags=0x3, data[12]=["\0\0\0\20\0\35d \2\0\10\0"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=0, info=0}) = 0
1338  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[23, 00, 00, 00, 00, 00, 00, 00, 14, 00], mx_sb_len=64, iovec_count=0, dxfer_len=20, timeout=0, flags=0x3, data[20]=["\0\0\0\20\0\35d \2\0\10\0\0#\5@\230\0\0\0"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=0, info=0}) = 0
1338  ioctl(5, CDROM_MEDIA_CHANGED, 0x7fffffff) = -1 ENOTTY (Inappropriate ioctl for device)
1338  write(2, ":-( /dev/dvd: CD_ROM_MEDIA_CHANG"..., 49) = 49
1338  write(2, "Inappropriate ioctl for device\n", 31) = 31
1338  exit_group(153)                   = ?
----

whereas a 2.6.37 kernel succeeds with:
-----
1357  open("/dev/dvd", O_RDONLY)        = 4
1357  fstat(4, {st_mode=S_IFBLK|0660, st_rdev=makedev(11, 0), ...}) = 0
1357  open("/dev/dvd", O_RDWR|O_NONBLOCK) = 5
1357  fstat(5, {st_mode=S_IFBLK|0660, st_rdev=makedev(11, 0), ...}) = 0
1357  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], mx_sb_len=64, iovec_count=0, dxfer_len=36, timeout=0, flags=0x3, data[36]=["\5\200\0052[\0\0\0Optiarc DVD RW AD-7240S "...], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=0, info=0}) = 0
1357  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[46, 00, 00, 00, 00, 00, 00, 00, 08, 00], mx_sb_len=64, iovec_count=0, dxfer_len=8, timeout=0, flags=0x3, data[8]=["\0\0\1P\0\0\0\32"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=4, info=0}) = 0
1357  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[51, 00, 00, 00, 00, 00, 00, 00, 20, 00], mx_sb_len=64, iovec_count=0, dxfer_len=32, timeout=0, flags=0x3, data[32]=["\0 \36\1\1\1\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=1, info=0}) = 0
1357  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[23, 00, 00, 00, 00, 00, 00, 00, 0c, 00], mx_sb_len=64, iovec_count=0, dxfer_len=12, timeout=0, flags=0x3, data[12]=["\0\0\0\20\0\35d \2\0\10\0"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=1, info=0}) = 0
1357  ioctl(5, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[23, 00, 00, 00, 00, 00, 00, 00, 14, 00], mx_sb_len=64, iovec_count=0, dxfer_len=20, timeout=0, flags=0x3, data[20]=["\0\0\0\20\0\35d \2\0\10\0\0#\5@\230\0\0\0"], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=1, info=0}) = 0
1357  ioctl(5, CDROM_MEDIA_CHANGED, 0x7fffffff) = 1
  <<snip>>
-----

Comment 1 John Reiser 2011-02-05 19:35:53 UTC
The difference is "duration=1" vs "duration=0";
key:
  < 2.6.37
  > 2.6.38

-----
23c23
< sb[0]=[], host_status=0, driver_status=0, resid=0, duration=1, info=0}) = 0
---
> sb[0]=[], host_status=0, driver_status=0, resid=0, duration=0, info=0}) = 0
28,29c28,34
< duration=1, info=0}) = 0
< ioctl(5, CDROM_MEDIA_CHANGED, 0x7fffffff) = 1
---
> duration=0, info=0}) = 0
> ioctl(5, CDROM_MEDIA_CHANGED, 0x7fffffff) = -1 ENOTTY (Inappropriate
> ioctl for device)
-----

Comment 2 Honza Horak 2011-03-01 11:34:28 UTC
This failure is caused by kernel bug, which is already fixed in kernel upstream (since kernel-2.6.38-0.rc5). 

More info about the bug can be found here: http://groups.google.com/group/linux.kernel/browse_thread/thread/3a2540ba1d3aa992/5be0ac436c899291?lnk=raot&fwc=1

After I installed kernel-2.6.38-0.rc5, growisofs is working properly again. A new kernel is available here: http://koji.fedoraproject.org/koji/buildinfo?buildID=229138