From owner-freebsd-scsi@FreeBSD.ORG Tue Jan 4 14:05:16 2005 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7CF416A4CE for ; Tue, 4 Jan 2005 14:05:16 +0000 (GMT) Received: from eagle.uvm.edu (eagle.uvm.edu [132.198.101.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id 494F943D39 for ; Tue, 4 Jan 2005 14:05:16 +0000 (GMT) (envelope-from jflemer@uvm.edu) Received: from [192.168.2.15] (c-24-9-89-237.client.comcast.net [24.9.89.237]) (authenticated bits=0) by eagle.uvm.edu (8.12.11/8.12.11) with ESMTP id j04E5Dsa022940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Jan 2005 09:05:15 -0500 Message-ID: <41DAA2C8.7030303@uvm.edu> Date: Tue, 04 Jan 2005 07:06:00 -0700 From: "James E. Flemer" User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040918) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-scsi@freebsd.org References: <41DA2475.90509@uvm.edu> <7579f7fb05010323457bab1899@mail.gmail.com> In-Reply-To: <7579f7fb05010323457bab1899@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: James Flemer Subject: Re: mtio/sa device response to bad blocks X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jan 2005 14:05:16 -0000 I am using fixed block mode. Why is it that errors cannot propagate for fixed block? After a little more looking in the code, perhaps this patch in saerror() will do what I want. I have not tried this patch yet though, since I compiled SCSI into the kernel (not module) and cannot reboot the box at the moment. -James --- sys/cam/scsi/scsi_sa.c 16 Jun 2004 09:46:31 -0000 1.101 +++ sys/cam/scsi/scsi_sa.c 4 Jan 2005 13:56:50 -0000 @@ -2415,6 +2415,8 @@ } else { error = EIO; } + } else if (sense_key == SSD_KEY_MEDIUM_ERROR) { + error = EIO; } else if (sense->flags & SSD_FILEMARK) { if (softc->flags & SA_FLAG_FIXED) { error = -1; Matthew Jacob wrote: > Are you using fixed block or variable block mode? I believe that > errors propagate correctly for variable but can't for fixed block > mode. > > > On Mon, 03 Jan 2005 22:07:01 -0700, James E. Flemer wrote: > >>I have a SCSI DAT drive and have had some problems reading tapes with >>bad blocks. It seems that a read(2) from the sa device returns 0 when a >>bad block is read from the tape. Note that read(2) also correctly >>returns 0 when a filemark is read. A userland application (see below) >>can tell the difference between a filemark and a read error by looking >>at the io_sense part of the scsi_tape_errors struct (via the >>MTIOCERRSTAT ioctl). However this is cumbersome and requires the >>knowledge of the scsi_sense_data struct. It would seem more appropriate >>for the read to return -1 and set errno to EIO when a bad block is read. >> With such a change "dd conv=noerror,sync" could be used to dump a tape >>with bad blocks. Unfortunately, I'm not familiar enough with the >>SCSI/CAM layers to know where make this change, could someone point me >>where to look? >> >>Thanks, >>-James >> >>/* This code will check the real reason for read to return 0 >> * and change the return code to -1 and set errno to EIO if there >> * was a MEDIUM_ERROR. Other non-SSD_FILEMARK/SSD_EOM flags >> * should probably also be handled via -1/errno. >> */ >>num_read = read(mtfd, buf, blk_size); >>if (num_read == 0) { >> ioctl(mtfd, MTIOCERRSTAT, &tape_err); >> sense_data = (struct scsi_sense_data *)&tape_err.io_sense; >> if (sense_data->flags & SSD_KEY_MEDIUM_ERROR) { >> num_read = -1; >> errno = EIO; >> } >>} >>_______________________________________________ >>freebsd-scsi@freebsd.org mailing list >>http://lists.freebsd.org/mailman/listinfo/freebsd-scsi >>To unsubscribe, send any mail to "freebsd-scsi-unsubscribe@freebsd.org" >>