Fix long standing problem with CD/DVD writing with `dd'. If done this way the

device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528
This commit is contained in:
reinoud 2009-03-17 21:25:47 +00:00
parent 69fbb7297e
commit 83969672ba
1 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.288 2009/03/14 11:08:29 ad Exp $ */
/* $NetBSD: cd.c,v 1.289 2009/03/17 21:25:47 reinoud Exp $ */
/*-
* Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.288 2009/03/14 11:08:29 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.289 2009/03/17 21:25:47 reinoud Exp $");
#include "rnd.h"
@ -148,6 +148,7 @@ static int cd_read_toc(struct cd_softc *, int, int, int,
static int cd_get_parms(struct cd_softc *, int);
static int cd_load_toc(struct cd_softc *, int, struct cd_formatted_toc *, int);
static int cdreadmsaddr(struct cd_softc *, struct cd_formatted_toc *,int *);
static int cdcachesync(struct scsipi_periph *periph, int flags);
static int dvd_auth(struct cd_softc *, dvd_authinfo *);
static int dvd_read_physical(struct cd_softc *, dvd_struct *);
@ -549,6 +550,10 @@ cdclose(dev_t dev, int flag, int fmt, struct lwp *l)
cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
if (cd->sc_dk.dk_openmask == 0) {
/* synchronise caches on last close */
cdcachesync(periph, 0);
/* drain outstanding calls */
scsipi_wait_drain(periph);
scsipi_prevent(periph, SPAMR_ALLOW,