From Andre.Albsmeier@siemens.com  Thu Nov 15 11:34:03 2007
Return-Path: <Andre.Albsmeier@siemens.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2AD1716A419
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Nov 2007 11:34:03 +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 AE16013C461
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Nov 2007 11:34:02 +0000 (UTC)
	(envelope-from Andre.Albsmeier@siemens.com)
Received: from mail3.siemens.de (localhost [127.0.0.1])
	by david.siemens.de (8.12.6/8.12.6) with ESMTP id lAFACvLD029998
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Nov 2007 11:12:58 +0100
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130])
	by mail3.siemens.de (8.12.6/8.12.6) with ESMTP id lAFACvaU021779
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Nov 2007 11:12:57 +0100
Received: (from localhost)
	by curry.mchp.siemens.de (8.14.2/8.14.2) id lAFACvQS068268
	for FreeBSD-gnats-submit@freebsd.org; Thu, 15 Nov 2007 11:12:57 +0100 (CET)
Message-Id: <200711151012.lAFACvbr024366@curry.mchp.siemens.de>
Date: Thu, 15 Nov 2007 11:12:57 +0100 (CET)
From: Andre Albsmeier <Andre.Albsmeier@siemens.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] camcontrol should be able to leave device specific data alone when editing mode pages
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         118069
>Category:       bin
>Synopsis:       [patch] camcontrol(8) should be able to leave device specific data alone when editing mode pages
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 15 11:40:01 UTC 2007
>Closed-Date:    
>Last-Modified:  Tue Feb 23 15:03:52 UTC 2010
>Originator:     Andre Albsmeier
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
>Environment:

System: FreeBSD 6.2-STABLE #0: Wed Oct 31 16:26:40 CET 2007
with a Quantum SDLT drive attached.


>Description:

On SDLT drives bits 4-6 of byte 2 of the Mode Parameter Header define
the so called "Buffered Mode". From the SCSI spec of a SDLT drive:

Buffered Mode. Set to 1 by default.
The drive implements immediate reporting on WRITE commands through
its buffered mode. With Buffered Mode set to 1, the drive reports
GOOD status on WRITE commands as soon as the data block has been
transferred to the buffer. If this field is set to 0, the drive
does not report GOOD status on WRITE commands until it writes the
data blocks to tape. When Buffered Mode is not used, the drive
suffers significant performance and capacity degradation.

When using camcontrol to edit mode pages it gets the current values
with MODE SENSE, modifies the data, and writes them back with MODE
SELECT. However, the device specific data always gets cleared before
performing MODE SELECT. For SDLT drives this results in disabling
the Buffered Mode which leads to serious performance issues (in
my case write speed dropped from 20MB/sec to 20kB/sec).


>How-To-Repeat:

Take a SLDT drive (sa0 in our case), insert a tape and wait
for the unit to become ready.

Run
camcontrol cmd sa0 -v -t 3 -c "1a 8 f 0 3 0" -i 3 "*i2 *b1 b3 *b4"
and check the result. If it is != 0, Buffered Mode is enabled
(the default).

Write data to the tape and observe the write speed using iostat.

Do something like:
echo "Data Compression Enabled: 0" | camcontrol modepage sa0 -m 15 -P 0 -e
echo "Data Compression Enabled: 1" | camcontrol modepage sa0 -m 15 -P 0 -e

Run
camcontrol cmd sa0 -v -t 3 -c "1a 8 f 0 3 0" -i 3 "*i2 *b1 b3 *b4"
and check the result. Now it should be 0 which means Buffered Mode
has been disabled.

Write data to the tape and observe the write speed using iostat.


>Fix:

We can simply leave the device specific data alone after
running MODE SENSE and before MODE SELECT:

--- sbin/camcontrol/modeedit.c.ORI	2006-04-12 09:03:39.000000000 +0200
+++ sbin/camcontrol/modeedit.c	2007-11-15 10:33:43.000000000 +0100
@@ -592,7 +592,9 @@
 
 	/* Recalculate headers & offsets. */
 	mh->blk_desc_len = 0;		/* No block descriptors. */
+#if 0
 	mh->dev_spec = 0;		/* Clear device-specific parameters. */
+#endif
 	mph = MODE_PAGE_HEADER(mh);
 	mode_pars = MODE_PAGE_DATA(mph);
 

This way, the same data gets written as it has been retrieved
with MODE SENSE. If this must not be done unconditionally a
command line option might help.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->thomas 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Nov 15 18:41:29 UTC 2007 
Responsible-Changed-Why:  
Hi Thomas can you have a look at this? 

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

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Andre Albsmeier <Andre.Albsmeier@siemens.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/118069: [PATCH] camcontrol should be able to leave device
	specific data alone when editing mode pages
Date: Sun, 9 Dec 2007 22:53:04 +0100

 * Andre Albsmeier, 2007-11-15 :
 
 > We can simply leave the device specific data alone after
 > running MODE SENSE and before MODE SELECT:
 
 This should clearly be offered as an option to the user. I prefer the idea
 of having this controlled by a command line switch. I am preparing a
 patch and will send it to freebsd-scsi for review.
 
 Thomas.
 
Responsible-Changed-From-To: thomas->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Feb 23 15:03:36 UTC 2010 
Responsible-Changed-Why:  
thomas' commit bit has been taken for safeskeeping per his request. 

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