Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Apr 1999 13:49:38 -0700 (PWT)
From:      Matthew Jacob <mjacob@feral.com>
To:        Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
Cc:        freebsd-scsi@FreeBSD.ORG
Subject:   Re: QIC tape problems on -stable (was: hanging `tar xfvR /dev/nrst0' process, can i debug it?)
Message-ID:  <Pine.LNX.4.04.9904281344410.26302-100000@feral.com>
In-Reply-To: <19990428214609.07248@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> ...this hunk failed to patch (and manually patching it this way
> yielded a `softc might be used unitiniatilized' warning, so i figure
> your source was a little different).

Yes, I'm off of -current.

> 
> Well, there are still some superfluous WRITE FILEMARKS, nevertheless.
> I played a little with `mt rdhpos' and `mt sethpos', and it seems the
> `set' operations make the driver think anything had been written, so
> it's also issuing the WRITE FILEMARKS command.  This doesn't seem to
> write any filemarks, indeed, as long as it happens after BOT, _but_
> issuing an `mt sethpos 1' _at_ BOT still erases the tape then...  Is
> there any reason why the driver sets the SA_FLAG_TAPE_WRITTEN flag for
> just the `mt set*pos' operation?

Oh- sorry- the same bloody patch applies to sasetpos too- this is what I
get for doing this on the fly while working on 50 other projects (and
answering this email through a clogged 144Kb DSL line because there's half
a dozen dweebs getting the linux networker client from my site....)..


static int
sardpos(struct cam_periph *periph, int hard, u_int32_t *blkptr)
{
	struct scsi_tape_position_data loc;
	union ccb *ccb;
	struct sa_softc *softc = (struct sa_softc *)periph->softc;
	int error = 0;

	/*
	 * First flush any pending writes (if any had occurred).
	 * Amazingly stupid drives sometimes take a zero count
	 * and say "Duh! Zero must mean One!".
	 */
	if (softc->flags & SA_FLAG_TAPE_WRITTEN)
		error = sawritefilemarks(periph, 0, 0);

	/*
	 * The latter case is for 'write protected' tapes
	 * which are too stupid to recognize a zero count
	 * for writing filemarks as a no-op.
	 */
	if (error != 0 && error != EACCES)
		return (error);

	ccb = cam_periph_getccb(periph, 1);

	scsi_read_position(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
	    hard, &loc, SSD_FULL_SIZE, 5000);
	softc->dsreg = MTIO_DSREG_RBSY;
	error = cam_periph_runccb(ccb, saerror, 0, 0, &softc->device_stats);
	softc->dsreg = MTIO_DSREG_REST;
	if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
		cam_release_devq(ccb->ccb_h.path, 0, 0, 0, 0);

	if (error == 0) {
		if (loc.flags & SA_RPOS_UNCERTAIN) {
			error = EINVAL;		/* nothing is certain */
		} else {
			*blkptr = scsi_4btoul(loc.firstblk);
		}
	}

	xpt_release_ccb(ccb);
	return (error);
}

static int
sasetpos(struct cam_periph *periph, int hard, u_int32_t *blkptr)
{
	union ccb *ccb;
	struct sa_softc *softc = (struct sa_softc *)periph->softc;
	int error = 0;

	/*
	 * First flush any pending writes (if any had occurred).
	 * Amazingly stupid drives sometimes take a zero count
	 * and say "Duh! Zero must mean One!".
	 */
	if (softc->flags & SA_FLAG_TAPE_WRITTEN)
		error = sawritefilemarks(periph, 0, 0);

	/*
	 * The latter case is for 'write protected' tapes
	 * which are too stupid to recognize a zero count
	 * for writing filemarks as a no-op.
	 */
	if (error != 0 && error != EACCES)
		return (error);

	softc = (struct sa_softc *)periph->softc;
	ccb = cam_periph_getccb(periph, 1);

	
	scsi_set_position(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
	    hard, *blkptr, SSD_FULL_SIZE, 60 * 60 * 1000);

	softc->dsreg = MTIO_DSREG_POS;
	error = cam_periph_runccb(ccb, saerror, 0, 0, &softc->device_stats);
	softc->dsreg = MTIO_DSREG_REST;
	if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
		cam_release_devq(ccb->ccb_h.path, 0, 0, 0, 0);
	xpt_release_ccb(ccb);
	/*
	 * Note relative file && block number position now unknown (if
	 * these things ever start being maintained in this driver).
	 *
	 * Do this for any kind of error (to be safe).
	 */
	softc->fileno = softc->blkno = (daddr_t) -1;
	return (error);
}



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-scsi" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.04.9904281344410.26302-100000>