From owner-svn-src-head@FreeBSD.ORG Thu Jan 8 00:45:48 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 136D2106566C; Thu, 8 Jan 2009 00:45:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 02AEC8FC12; Thu, 8 Jan 2009 00:45:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n080jlwr004299; Thu, 8 Jan 2009 00:45:47 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n080jlfQ004298; Thu, 8 Jan 2009 00:45:47 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200901080045.n080jlfQ004298@svn.freebsd.org> From: Warner Losh Date: Thu, 8 Jan 2009 00:45:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186882 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 00:45:48 -0000 Author: imp Date: Thu Jan 8 00:45:47 2009 New Revision: 186882 URL: http://svn.freebsd.org/changeset/base/186882 Log: Make it possible to override the number of retries for the CD media. When trying to read scratched or damaged CDs and DVDs, the default mechanism is sub-optimal. Programs like ddrescue do much better if you turn off retries entirely, since their algorithms are designed scan big areas fast, then winnow the areas down. Turning off retries speeds these programs up by as much as 20x, since the drive is able to 'stream past' many small errors... The sysctl/tunable kern.cam.cd.retry_count controls this. That defaults to '4' (for a total of 5 attempts). Setting to 0 turns off all retry attempts. Reviewed by: scottl@ Modified: head/sys/cam/scsi/scsi_cd.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Thu Jan 8 00:31:48 2009 (r186881) +++ head/sys/cam/scsi/scsi_cd.c Thu Jan 8 00:45:47 2009 (r186882) @@ -292,6 +292,9 @@ static struct periph_driver cddriver = PERIPHDRIVER_DECLARE(cd, cddriver); +#ifndef CD_DEFAULT_RETRY +#define CD_DEFAULT_RETRY 4 +#endif #ifndef CHANGER_MIN_BUSY_SECONDS #define CHANGER_MIN_BUSY_SECONDS 5 #endif @@ -299,11 +302,15 @@ PERIPHDRIVER_DECLARE(cd, cddriver); #define CHANGER_MAX_BUSY_SECONDS 15 #endif +static int cd_retry_count = CD_DEFAULT_RETRY; static int changer_min_busy_seconds = CHANGER_MIN_BUSY_SECONDS; static int changer_max_busy_seconds = CHANGER_MAX_BUSY_SECONDS; SYSCTL_NODE(_kern_cam, OID_AUTO, cd, CTLFLAG_RD, 0, "CAM CDROM driver"); SYSCTL_NODE(_kern_cam_cd, OID_AUTO, changer, CTLFLAG_RD, 0, "CD Changer"); +SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RW, + &cd_retry_count, 0, "Normal I/O retry count"); +TUNABLE_INT("kern.cam.cd.retry_count", &cd_retry_count); SYSCTL_INT(_kern_cam_cd_changer, OID_AUTO, min_busy_seconds, CTLFLAG_RW, &changer_min_busy_seconds, 0, "Minimum changer scheduling quantum"); TUNABLE_INT("kern.cam.cd.changer.min_busy_seconds", &changer_min_busy_seconds); @@ -1454,7 +1461,7 @@ cdstart(struct cam_periph *periph, union devstat_start_transaction_bio(softc->disk->d_devstat, bp); scsi_read_write(&start_ccb->csio, - /*retries*/4, + /*retries*/cd_retry_count, /* cbfcnp */ cddone, MSG_SIMPLE_Q_TAG, /* read */bp->bio_cmd == BIO_READ,