From Andre.Albsmeier@siemens.com  Thu Apr 13 17:33:38 2006
Return-Path: <Andre.Albsmeier@siemens.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 44F5616A401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2006 17:33:38 +0000 (UTC)
	(envelope-from Andre.Albsmeier@siemens.com)
Received: from david.siemens.de (david.siemens.de [192.35.17.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 938F643D45
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2006 17:33:36 +0000 (GMT)
	(envelope-from Andre.Albsmeier@siemens.com)
Received: from mail1.siemens.de (localhost [127.0.0.1])
	by david.siemens.de (8.12.6/8.12.6) with ESMTP id k3DHXZwc025091
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2006 19:33:35 +0200
Received: from ims.mchp.siemens.de (ims.mchp.siemens.de [139.25.31.39])
	by mail1.siemens.de (8.12.6/8.12.6) with ESMTP id k3DHXZDW027131
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2006 19:33:35 +0200
Received: from mail-ct.mchp.siemens.de (mail-ct.mchp.siemens.de [139.25.31.51])
				by ims.mchp.siemens.de  with ESMTP id k3DHXYJQ023350
				for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2006 19:33:34 +0200 (MEST)
Received: from curry.mchp.siemens.de (curry [139.25.40.130])
	by mail-ct.mchp.siemens.de (8.12.11/8.12.11) with ESMTP id k3DHXYeS003912
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2006 19:33:34 +0200 (MEST)
Received: (from localhost)
	by curry.mchp.siemens.de (8.13.6/8.13.6) id k3DHXY99086872
	for FreeBSD-gnats-submit@freebsd.org; Thu, 13 Apr 2006 19:33:34 +0200 (CEST)
Message-Id: <200604131733.k3DHXYIG004744@curry.mchp.siemens.de>
Date: Thu, 13 Apr 2006 19:33:34 +0200 (CEST)
From: Andre Albsmeier <Andre.Albsmeier@siemens.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: PATCH: iostat's transfer rate for cdroms is wrong
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         95707
>Category:       kern
>Synopsis:       [cam] [patch] iostat's transfer rate for cdroms is wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 13 17:40:17 GMT 2006
>Closed-Date:    Mon May 01 19:53:07 GMT 2006
>Last-Modified:  Mon May  1 20:00:34 GMT 2006
>Originator:     Andre Albsmeier
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
>Environment:

System: FreeBSD 5.4-STABLE Tue Mar 7 21:56:34 CET 2006

>Description:

The transfer rate of cdroms shown by iostat is wrong (exactly
twice as big as it should be).

>How-To-Repeat:

Copy a big file from cd (cd0 in this case) to an idle disk
(da0 in this case) on an otherwise idle system. In another
window run iostat for the two devices and compare the results:

andre@voyager:~>iostat -d cd0 da0 1
             da0              cd0
  KB/t tps  MB/s   KB/t tps  MB/s
  5.74  23  0.13   0.00   0  0.00
  6.24  17  0.10   0.00   0  0.00
 66.26  35  2.24  64.00  73  4.58
 11.08 247  2.67  64.00  30  1.86
115.63  30  3.35  64.00  93  5.82
123.20  25  2.98  64.00  95  5.94
 77.72  40  3.01  64.00  95  5.94
107.14  29  3.00  64.00  95  5.94
119.70  27  3.12  64.00  97  6.06
 65.98  49  3.13  64.00  97  6.06
107.30  30  3.11  64.00  99  6.19
 86.63  38  3.18  64.00  99  6.19
 58.17  59  3.37  64.00  99  6.19
108.19  31  3.24  64.00 101  6.31
111.45  29  3.13  64.00 101  6.31
 77.29  45  3.36  64.00 103  6.44
 73.47  47  3.34  64.00 103  6.44
 63.23  55  3.42  64.00 103  6.44
...

If the cd is full and the read process reaches the outer
(faster) areas of the cd, the cd0 transfer rate shown
climbs up to 12MB/sec. This would mean my Plextor PX-40
reads at 80x speed :-).

>Fix:

[Don't know if this is correct...]

When reading cdroms, devstat_end_transaction_bio() is called
twice at the end of each transfer. One time from g_disk_done()
in geom_disk.c and another time from biofinish() in vfs_bio.c
which in turn was called from cddone() in scsi_cd.c.

We can avoid accounting in the second case by passing NULL to
biofinish() as devstat*:

--- sys/cam/scsi/scsi_cd.c.ORI	Mon Nov 28 06:57:04 2005
+++ sys/cam/scsi/scsi_cd.c	Thu Apr 13 16:03:49 2006
@@ -1669,7 +1669,7 @@
 		if (softc->flags & CD_FLAG_CHANGER)
 			cdchangerschedule(softc);
 
-		biofinish(bp, softc->disk->d_devstat, 0);
+		biofinish(bp, NULL, 0);
 		break;
 	}
 	case CD_CCB_PROBE:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-scsi 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Apr 13 18:05:20 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95707 
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Mon Apr 17 09:13:22 UTC 2006 
State-Changed-Why:  
Fixed in HEAD.  Thanks for the patch! 


Responsible-Changed-From-To: freebsd-scsi->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Mon Apr 17 09:13:22 UTC 2006 
Responsible-Changed-Why:  
Feedbacks trap. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95707 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Mon May 1 19:52:42 UTC 2006 
State-Changed-Why:  
MFC'ed to RELENG_6 and RELENG_6_1. 

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

From: Maxim Konovalov <maxim@macomnet.ru>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/95707: [cam] [patch] iostat's transfer rate for cdroms is
 wrong
Date: Mon, 1 May 2006 23:58:17 +0400 (MSD)

 On Mon, 1 May 2006, 19:53-0000, Maxim Konovalov wrote:
 
 > Synopsis: [cam] [patch] iostat's transfer rate for cdroms is wrong
 >
 > State-Changed-From-To: patched->closed
 > State-Changed-By: maxim
 > State-Changed-When: Mon May 1 19:52:42 UTC 2006
 > State-Changed-Why:
 > MFC'ed to RELENG_6 and RELENG_6_1.
 
 And RELENG_5.
 
 -- 
 Maxim Konovalov
>Unformatted:
