Bug 138789

Summary: [cam] [patch] cd(4) patch for drives/discs failing the 'read toc' command
Product: Base System Reporter: Juergen Lock <nox>
Component: kernAssignee: Andriy Gapon <avg>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 8.0-BETA3   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Juergen Lock 2009-09-13 22:20:07 UTC
	As mentioned earlier on -current, cd(4), unlike acd(4), won't read
	a disc (returns 0 bytes) when the drive returned a proper disc size
	but failed the 'read toc' command.  Observed here with a bluray
	data disc and, as mentioned later in the thread, also by
	Ulrich Spörlein with an external usb/1394 dvd drive and regular
	`pressed' dvd data discs.

	Thread is here:
	http://lists.freebsd.org/pipermail/freebsd-current/2009-August/010316.html

How-To-Repeat: 	Burn a bluray data disc (mine was ~15GB) using e.g. growisofs from
	/usr/ports/sysutils/dvd+rw-tools and then try to read it via a
	cd(4) device as provided by atapicam(4), ahci(4), or siis(4).
	Verify the same disc/drive on an acd(4) device reads just fine.
Comment 1 Juergen Lock 2009-09-13 23:18:29 UTC
Clarification: drives accessed as /dev/cdX are affected, drives accessed
as /dev/acdX are not.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2009-09-15 01:45:18 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-scsi

Patch affects CAM.
Comment 3 John-Mark Gurney freebsd_committer freebsd_triage 2010-02-20 02:26:32 UTC
State Changed
From-To: open->analyzed

I will take over this PR...  The problem is that the scsi-cd.c driver 
attempts to read the LEADOUT track of the disc, and if it can't, assumes 
the disc is not valid..  For some Blu-Ray drives, they, per the spec, do 
not allow reading of the LEADOUT track...  I also have a drive that fails.. 

I am currently working on a patch to not read the LEADOUT track, but 
keep the original behavior as a sysctl incase it breaks older cd-rom 
drives. 


Comment 4 John-Mark Gurney freebsd_committer freebsd_triage 2010-02-20 02:26:32 UTC
Responsible Changed
From-To: freebsd-scsi->jmg

I will take over this PR...  The problem is that the scsi-cd.c driver 
attempts to read the LEADOUT track of the disc, and if it can't, assumes 
the disc is not valid..  For some Blu-Ray drives, they, per the spec, do 
not allow reading of the LEADOUT track...  I also have a drive that fails.. 

I am currently working on a patch to not read the LEADOUT track, but 
keep the original behavior as a sysctl incase it breaks older cd-rom 
drives.
Comment 5 Andriy Gapon 2010-04-07 23:12:24 UTC
It seems that I completely missed this problem and the PR and the patch, and
while looking into a similar issue I came up with the same conclusions and with
a somewhat similar patch:
http://docs.freebsd.org/cgi/mid.cgi?4BBCFE30.2010709

Juergen,
could you please give a try to my patch as well?

John-Mark,
I can take over the PR if you are busy at the moment.

Thanks!
-- 
Andriy Gapon
Comment 6 Juergen Lock 2010-04-08 21:02:08 UTC
On Thu, Apr 08, 2010 at 01:12:24AM +0300, Andriy Gapon wrote:
> 
> It seems that I completely missed this problem and the PR and the patch, and
> while looking into a similar issue I came up with the same conclusions and with
> a somewhat similar patch:
> http://docs.freebsd.org/cgi/mid.cgi?4BBCFE30.2010709
> 
> Juergen,
> could you please give a try to my patch as well?

Just did, and found that patch fixes my issue as well.

 Thanx, :)
	Juergen
Comment 7 Ulrich Spoerlein 2010-04-10 12:16:48 UTC
I have a Plextor CD-RW drive, where reading "mastered" DVDs via cd(4) is
failing (via acd(4) it's working fine) and the patch proposed initially
solved this. Please give me a day or two to test the second patch.
Thanks!
Comment 8 Andriy Gapon freebsd_committer freebsd_triage 2010-04-15 09:17:10 UTC
Responsible Changed
From-To: jmg->avg

I have an interest in this issue, so I am helping jmg here.
Comment 9 Andriy Gapon freebsd_committer freebsd_triage 2010-04-15 09:29:31 UTC
State Changed
From-To: analyzed->patched

A fix is applied in head.
Comment 10 dfilter service freebsd_committer freebsd_triage 2010-04-15 10:22:27 UTC
Author: avg
Date: Thu Apr 15 09:22:14 2010
New Revision: 206651
URL: http://svn.freebsd.org/changeset/base/206651

Log:
  scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set d_sectorsize and
  d_mediasize
  
  [Forced commit to correct PR number.]
  CD_FLAG_VALID_TOC is not required for setting those media properties.
  
  PR:		kern/138789
  Submitted by:	Juergen Lock <nox@jelal.kn-bremen.de>
  		a slightly different version
  Tested by:	Pavel Sukhoy <sukhoy@ripn.net>,
  		Markus Wild <m.wild@cybernet.ch>,
  		Juergen Lock <nox@jelal.kn-bremen.de>,
  		uqs
  MFC after:	1 week

Modified:
  head/sys/cam/scsi/scsi_cd.c

Modified: head/sys/cam/scsi/scsi_cd.c
==============================================================================
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 11 dfilter service freebsd_committer freebsd_triage 2010-04-22 12:47:01 UTC
Author: avg
Date: Thu Apr 22 11:46:42 2010
New Revision: 207059
URL: http://svn.freebsd.org/changeset/base/207059

Log:
  MFC r206648,206651: scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set
  d_sectorsize and d_mediasize
  
  PR:		kern/138789

Modified:
  stable/8/sys/cam/scsi/scsi_cd.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/cam/scsi/scsi_cd.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_cd.c	Thu Apr 22 09:30:02 2010	(r207058)
+++ stable/8/sys/cam/scsi/scsi_cd.c	Thu Apr 22 11:46:42 2010	(r207059)
@@ -2777,8 +2777,12 @@ cdcheckmedia(struct cam_periph *periph)
 		softc->flags &= ~(CD_FLAG_VALID_MEDIA|CD_FLAG_VALID_TOC);
 		cdprevent(periph, PR_ALLOW);
 		return (error);
-	} else
+	} else {
 		softc->flags |= CD_FLAG_VALID_MEDIA;
+		softc->disk->d_sectorsize = softc->params.blksize;
+		softc->disk->d_mediasize =
+		    (off_t)softc->params.blksize * softc->params.disksize;
+	}
 
 	/*
 	 * Now we check the table of contents.  This (currently) is only
@@ -2867,9 +2871,6 @@ cdcheckmedia(struct cam_periph *periph)
 	}
 
 	softc->flags |= CD_FLAG_VALID_TOC;
-	softc->disk->d_sectorsize = softc->params.blksize;
-	softc->disk->d_mediasize =
-	    (off_t)softc->params.blksize * softc->params.disksize;
 
 bailout:
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 12 dfilter service freebsd_committer freebsd_triage 2010-04-22 13:13:06 UTC
Author: avg
Date: Thu Apr 22 12:12:52 2010
New Revision: 207060
URL: http://svn.freebsd.org/changeset/base/207060

Log:
  MFC r206648,206651: scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set
  d_sectorsize and d_mediasize
  
  Note that there is a redundant assignment of d_maxsize.
  
  PR:		kern/138789

Modified:
  stable/7/sys/cam/scsi/scsi_cd.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/cam/scsi/scsi_cd.c
==============================================================================
--- stable/7/sys/cam/scsi/scsi_cd.c	Thu Apr 22 11:46:42 2010	(r207059)
+++ stable/7/sys/cam/scsi/scsi_cd.c	Thu Apr 22 12:12:52 2010	(r207060)
@@ -2773,8 +2773,12 @@ cdcheckmedia(struct cam_periph *periph)
 		softc->flags &= ~(CD_FLAG_VALID_MEDIA|CD_FLAG_VALID_TOC);
 		cdprevent(periph, PR_ALLOW);
 		return (error);
-	} else
+	} else {
 		softc->flags |= CD_FLAG_VALID_MEDIA;
+		softc->disk->d_sectorsize = softc->params.blksize;
+		softc->disk->d_mediasize =
+		    (off_t)softc->params.blksize * softc->params.disksize;
+	}
 
 	/*
 	 * Now we check the table of contents.  This (currently) is only
@@ -2864,9 +2868,6 @@ cdcheckmedia(struct cam_periph *periph)
 
 	softc->flags |= CD_FLAG_VALID_TOC;
 	softc->disk->d_maxsize = DFLTPHYS;
-	softc->disk->d_sectorsize = softc->params.blksize;
-	softc->disk->d_mediasize =
-	    (off_t)softc->params.blksize * softc->params.disksize;
 
 bailout:
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 13 Andriy Gapon freebsd_committer freebsd_triage 2010-04-23 17:25:34 UTC
State Changed
From-To: patched->closed

This PR has been resolved in HEAD and supported stable branches.