Make sc_ops->sdo_flush' synchronous. The flags SDF_FLUSHING' and

`SDF_DIRTY' were never reset because `sddone' doesn't get called from
synchronous scsi commands.
This commit is contained in:
hannken 1999-08-26 09:28:17 +00:00
parent 44591ccc49
commit f04bd56be1
3 changed files with 29 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.145 1999/05/31 12:05:39 lukem Exp $ */
/* $NetBSD: sd.c,v 1.146 1999/08/26 09:28:17 hannken Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -437,8 +437,14 @@ sdclose(dev, flag, fmt, p)
* it, do it now.
*/
if ((sd->flags & SDF_DIRTY) != 0 &&
sd->sc_ops->sdo_flush != NULL)
(*sd->sc_ops->sdo_flush)(sd, 0);
sd->sc_ops->sdo_flush != NULL) {
if ((*sd->sc_ops->sdo_flush)(sd, 0)) {
printf("%s: cache synchronization failed\n",
sd->sc_dev.dv_xname);
sd->flags &= ~SDF_FLUSHING;
} else
sd->flags &= ~(SDF_FLUSHING|SDF_DIRTY);
}
scsipi_wait_drain(sd->sc_link);
@ -953,8 +959,14 @@ sd_shutdown(arg)
* it, flush it. We're cold at this point, so we poll for
* completion.
*/
if ((sd->flags & SDF_DIRTY) != 0 && sd->sc_ops->sdo_flush != NULL)
(*sd->sc_ops->sdo_flush)(sd, SCSI_AUTOCONF);
if ((sd->flags & SDF_DIRTY) != 0 && sd->sc_ops->sdo_flush != NULL) {
if ((*sd->sc_ops->sdo_flush)(sd, SCSI_AUTOCONF)) {
printf("%s: cache synchronization failed\n",
sd->sc_dev.dv_xname);
sd->flags &= ~SDF_FLUSHING;
} else
sd->flags &= ~(SDF_FLUSHING|SDF_DIRTY);
}
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd_scsi.c,v 1.8 1998/10/08 20:21:13 thorpej Exp $ */
/* $NetBSD: sd_scsi.c,v 1.9 1999/08/26 09:28:18 hannken Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -101,7 +101,7 @@ static int sd_scsibus_get_parms __P((struct sd_softc *,
struct disk_parms *, int));
static int sd_scsibus_get_optparms __P((struct sd_softc *,
struct disk_parms *, int));
static void sd_scsibus_flush __P((struct sd_softc *, int));
static int sd_scsibus_flush __P((struct sd_softc *, int));
const struct sd_ops sd_scsibus_ops = {
sd_scsibus_get_parms,
@ -329,7 +329,7 @@ fake_it:
return (SDGP_RESULT_OK);
}
static void
static int
sd_scsibus_flush(sd, flags)
struct sd_softc *sd;
int flags;
@ -353,16 +353,14 @@ sd_scsibus_flush(sd, flags)
*/
if ((sc_link->scsipi_scsi.scsi_version & SID_ANSII) >= 2 &&
(sc_link->quirks & SDEV_NOSYNCCACHE) == 0) {
sd->flags |= SDF_FLUSHING;
bzero(&sync_cmd, sizeof(sync_cmd));
sync_cmd.opcode = SCSI_SYNCHRONIZE_CACHE;
if (scsipi_command(sc_link,
(struct scsipi_generic *)&sync_cmd, sizeof(sync_cmd),
NULL, 0, SDRETRIES, 100000, NULL,
flags|SCSI_IGNORE_ILLEGAL_REQUEST))
printf("%s: WARNING: cache synchronization failed\n",
sd->sc_dev.dv_xname);
else
sd->flags |= SDF_FLUSHING;
}
return(scsipi_command(sc_link,
(struct scsipi_generic *)&sync_cmd, sizeof(sync_cmd),
NULL, 0, SDRETRIES, 100000, NULL,
flags|SCSI_IGNORE_ILLEGAL_REQUEST));
} else
return(0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */
/* $NetBSD: sdvar.h,v 1.8 1999/08/26 09:28:18 hannken Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -93,7 +93,7 @@ struct sd_softc {
struct sd_ops {
int (*sdo_get_parms) __P((struct sd_softc *, struct disk_parms *,
int));
void (*sdo_flush) __P((struct sd_softc *, int));
int (*sdo_flush) __P((struct sd_softc *, int));
};
#define SDGP_RESULT_OK 0 /* paramters obtained */
#define SDGP_RESULT_OFFLINE 1 /* no media, or otherwise losing */