From cjohnson@neunacht.netgsi.com  Wed Feb  4 00:28:00 1998
Received: from neunacht.netgsi.com (neunacht.netgsi.com [192.55.203.37])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA11606
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 Feb 1998 00:27:59 -0800 (PST)
          (envelope-from cjohnson@neunacht.netgsi.com)
Received: (from cjohnson@localhost)
	by neunacht.netgsi.com (8.8.8/8.8.6) id DAA00475;
	Wed, 4 Feb 1998 03:27:58 -0500 (EST)
Message-Id: <199802040827.DAA00475@neunacht.netgsi.com>
Date: Wed, 4 Feb 1998 03:27:58 -0500 (EST)
From: "Christopher T. Johnson" <cjohnson@neunacht.netgsi.com>
Reply-To: cjohnson@neunacht.netgsi.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: NCR 810/815 do not handle rewind correctly
X-Send-Pr-Version: 3.2

>Number:         5643
>Category:       kern
>Synopsis:       NCR 810/815 do not handle rewind correctly
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    jesper
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb  4 00:30:01 PST 1998
>Closed-Date:    Fri Jun 1 17:11:38 PDT 2001
>Last-Modified:  Fri Jun 01 17:15:08 PDT 2001
>Originator:     Christopher T. Johnson
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
NetGSI, INC
>Environment:

	

Problem presents itself with both an 810 and 815 SCSI card.  In both
a 486 (AMD X6/133 40MB) and a P166 Dual processor system.  The dual
processor system shows the problem in both uni and multi processor mode.

Problem has been present in CURRENT since atleast Nov 1st 1997.


>Description:

	When the following sequence is executed with an NCR810/815 
	SCSI control card, the second rewind generates an I/O error
	with no message logged.

		open("/dev/nrst0", O_RDONLY);
		rewind via ioctl();
		read(fd, buffer, 32k);
		close(fd);
		open("/dev/nrst0", O_RDWR);
		rewind via ioctl();

	The type drive is an older EXABYTE 8200 and it is more than a
little slow in doing any tape motion.


>How-To-Repeat:
#include <stdio.h>
#include "tapeio.h"
main()
{
	int fd;
	char buffer[32768];
	char bout[32768];
	int flag;

	strcpy(bout,"AMANDA: TAPESTART DATE X TAPE NET004\n");
	fd = tape_open("/dev/nrst0", 0);	/* O_RDONLY */
	if (fd < 0) {
		perror("Tape open");
		exit(1);
	}

	flag = tapefd_rewind(fd);
	if (flag < 0 ) {
		perror("rewind 1");
		exit(2);
	}
	flag = read(fd, buffer, 32768);
	if (flag != 32768) {
		perror("read");
	}

	flag = close(fd);
	if (flag != 0) {
		perror("tape close");
		exit(4);
	}

	fd = tape_open("/dev/nrst0", 2);	/* O_RDWR */
	if (fd < 0) {
		perror("open rdwr");
		exit(4);
	}

	flag = tapefd_rewind(fd);
	if (flag < 0) {
		perror("rewind 2");
		fprintf(stderr,"Trying to rewind a second time\n");
		sleep(5);
		flag = tapefd_rewind(fd);
		if (flag < 0) {
			perror("rewind 3");
		}
	}
	flag = write(fd, bout, 32768);
	if (flag != 32768) {
		perror("write");
		exit(6);
	}
	flag = close(fd);
	if (flag != 0) {
		perror("close 2");
		exit(7);
	}
	exit(0);
}
#include <sys/mtio.h>

int tapefd_rewind(tapefd)
int tapefd;
{
    struct mtop mt;

    mt.mt_op = MTREW;
    mt.mt_count = 1;
    return ioctl(tapefd, MTIOCTOP, &mt);
}
int tape_open(filename, mode)
char *filename;
int mode;
{
    return open(filename, mode);
}

	

>Fix:
	
	

Because of the fact that the work around shows that there is a timing need
I suspect that the ncr code is not waiting for something to settle.

This problem does NOT happen with the same equipment but with an 
Adaptec 1542cp
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: jesper 
State-Changed-When: Sun May 27 17:00:37 PDT 2001 
State-Changed-Why:  
Please test with the sym(4) driver. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=5643 
Responsible-Changed-From-To: freebsd-bugs->jesper 
Responsible-Changed-By: jesper 
Responsible-Changed-When: Sun May 27 17:06:14 PDT 2001 
Responsible-Changed-Why:  
keep it on the radarscreen 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=5643 
State-Changed-From-To: suspended->closed 
State-Changed-By: jesper 
State-Changed-When: Fri Jun 1 17:11:38 PDT 2001 
State-Changed-Why:  
Mail to submitter bounce, so the questions will not be answered. 

The original message was received at Sun, 27 May 2001 17:01:06 -0700 (PDT) 
from jesper@localhost 

----- The following addresses had permanent fatal errors ----- 
cjohnson@neunacht.netgsi.com 

----- Transcript of session follows ----- 
451 cjohnson@neunacht.netgsi.com     ... neunacht.netgsi.com: Name server timeout 
Message could not be delivered for 5 days 
Message will be deleted from queue 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=5643 
>Unformatted:
