From nox@jelal.kn-bremen.de  Sun Sep 13 21:19:46 2009
Return-Path: <nox@jelal.kn-bremen.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1E651106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Sep 2009 21:19:46 +0000 (UTC)
	(envelope-from nox@jelal.kn-bremen.de)
Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116])
	by mx1.freebsd.org (Postfix) with ESMTP id D322B8FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Sep 2009 21:19:45 +0000 (UTC)
Received: by smtp.kn-bremen.de (Postfix, from userid 10)
	id C32E61E005A8; Sun, 13 Sep 2009 23:04:38 +0200 (CEST)
Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1])
	by triton8.kn-bremen.de (8.14.3/8.14.3) with ESMTP id n8DL1GrX024919
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Sep 2009 23:01:16 +0200 (CEST)
	(envelope-from nox@triton8.kn-bremen.de)
Received: (from nox@localhost)
	by triton8.kn-bremen.de (8.14.3/8.14.3/Submit) id n8DL1GGJ024918;
	Sun, 13 Sep 2009 23:01:16 +0200 (CEST)
	(envelope-from nox)
Message-Id: <200909132101.n8DL1GGJ024918@triton8.kn-bremen.de>
Date: Sun, 13 Sep 2009 23:01:16 +0200 (CEST)
From: Juergen Lock <nox@jelal.kn-bremen.de>
Reply-To: Juergen Lock <nox@jelal.kn-bremen.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: cd(4) patch for drives/discs failing the 'read toc' command
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         138789
>Category:       kern
>Synopsis:       [cam] [patch] cd(4) patch for drives/discs failing the 'read toc' command
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    avg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 13 21:20:07 UTC 2009
>Closed-Date:    Fri Apr 23 16:26:24 UTC 2010
>Last-Modified:  Fri Apr 23 16:26:24 UTC 2010
>Originator:     Juergen Lock
>Release:        FreeBSD 8.0-BETA3 amd64
>Organization:
me?  organized??
>Environment:
System: FreeBSD triton8.kn-bremen.de 8.0-BETA3 FreeBSD 8.0-BETA3 #0: Fri Sep 4 20:25:37 CEST 2009 nox@triton8.kn-bremen.de:/usr/obj/data/home/nox/src-r8pb3b/src/sys/TRITON8 amd64


>Description:
	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 Sprlein 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.

>Fix:

Index: sys/cam/scsi/scsi_cd.c
@@ -2868,12 +2868,18 @@
 	}
 
 	softc->flags |= CD_FLAG_VALID_TOC;
+
+bailout:
 	softc->disk->d_maxsize = DFLTPHYS;
 	softc->disk->d_sectorsize = softc->params.blksize;
 	softc->disk->d_mediasize =
 	    (off_t)softc->params.blksize * softc->params.disksize;
 
+/* if
 bailout:
+ * is here read requests will fail when the toc cant be read although
+ * CD_FLAG_VALID_MEDIA is set.
+ */
 
 	/*
 	 * We unconditionally (re)set the blocksize each time the
>Release-Note:
>Audit-Trail:

From: Juergen Lock <nox@jelal.kn-bremen.de>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/138789: cd(4) patch for drives/discs failing the 'read
 toc' command
Date: Mon, 14 Sep 2009 00:18:29 +0200

 Clarification: drives accessed as /dev/cdX are affected, drives accessed
 as /dev/acdX are not.
Responsible-Changed-From-To: freebsd-bugs->freebsd-scsi 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Sep 15 00:45:18 UTC 2009 
Responsible-Changed-Why:  
Patch affects CAM. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138789 
State-Changed-From-To: open->analyzed 
State-Changed-By: jmg 
State-Changed-When: Sat Feb 20 02:26:32 UTC 2010 
State-Changed-Why:  
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. 


Responsible-Changed-From-To: freebsd-scsi->jmg 
Responsible-Changed-By: jmg 
Responsible-Changed-When: Sat Feb 20 02:26:32 UTC 2010 
Responsible-Changed-Why:  
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. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138789 

From: Andriy Gapon <avg@icyb.net.ua>
To: bug-followup@FreeBSD.org, Juergen Lock <nox@jelal.kn-bremen.de>,
        John-Mark Gurney <jmg@FreeBSD.org>
Cc:  
Subject: Re: kern/138789: [cam] [patch] cd(4) patch for drives/discs failing
 the 'read toc' command
Date: Thu, 08 Apr 2010 01:12:24 +0300

 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

From: Juergen Lock <nox@jelal.kn-bremen.de>
To: Andriy Gapon <avg@icyb.net.ua>
Cc: bug-followup@FreeBSD.org, Juergen Lock <nox@jelal.kn-bremen.de>,
        John-Mark Gurney <jmg@FreeBSD.org>
Subject: Re: kern/138789: [cam] [patch] cd(4) patch for drives/discs
 failing the 'read toc' command
Date: Thu, 8 Apr 2010 22:02:08 +0200

 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

From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= <uqs@spoerlein.net>
To: bug-followup@FreeBSD.org, nox@jelal.kn-bremen.de,
        Andriy Gapon <avg@icyb.net.ua>
Cc:  
Subject: Re: kern/138789: [cam] [patch] cd(4) patch for drives/discs
 failing the 'read toc' command
Date: Sat, 10 Apr 2010 13:16:48 +0200

 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!
Responsible-Changed-From-To: jmg->avg 
Responsible-Changed-By: avg 
Responsible-Changed-When: Thu Apr 15 08:17:10 UTC 2010 
Responsible-Changed-Why:  
I have an interest in this issue, so I am helping jmg here. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138789 
State-Changed-From-To: analyzed->patched 
State-Changed-By: avg 
State-Changed-When: Thu Apr 15 08:29:31 UTC 2010 
State-Changed-Why:  
A fix is applied in head. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138789 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/138789: commit references a PR
Date: Thu, 15 Apr 2010 09:22:27 +0000 (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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/138789: commit references a PR
Date: Thu, 22 Apr 2010 11:47:01 +0000 (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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/138789: commit references a PR
Date: Thu, 22 Apr 2010 12:13:06 +0000 (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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: avg 
State-Changed-When: Fri Apr 23 16:25:34 UTC 2010 
State-Changed-Why:  
This PR has been resolved in HEAD and supported stable branches. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138789 
>Unformatted:
