Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/tls-maxphys]: src/sys Don't pass NULL struct dkdriver to disk_init. Tha...
details: https://anonhg.NetBSD.org/src/rev/2b00f0282e86
branches: tls-maxphys
changeset: 852965:2b00f0282e86
user: tls <tls%NetBSD.org@localhost>
date: Sun Dec 02 05:46:39 2012 +0000
description:
Don't pass NULL struct dkdriver to disk_init. That's seriously bogus.
diffstat:
sys/arch/hp300/dev/rd.c | 19 ++++++++++++++++---
sys/arch/vax/mba/hp.c | 8 +++++---
sys/arch/vax/vsa/hdc9224.c | 16 ++++++++++++----
sys/dev/ccd.c | 30 +++++++++++++++++++++++++++---
sys/dev/ccdvar.h | 3 ++-
sys/dev/dkwedge/dk.c | 8 +++++---
sys/dev/fss.c | 19 ++++++++++++++++---
sys/dev/gpib/rd.c | 19 ++++++++++++++++---
sys/kern/subr_disk.c | 7 +++++--
9 files changed, 104 insertions(+), 25 deletions(-)
diffs (truncated from 388 to 300 lines):
diff -r 01e44260d943 -r 2b00f0282e86 sys/arch/hp300/dev/rd.c
--- a/sys/arch/hp300/dev/rd.c Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/arch/hp300/dev/rd.c Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rd.c,v 1.92.6.1 2012/11/20 03:01:21 tls Exp $ */
+/* $NetBSD: rd.c,v 1.92.6.2 2012/12/02 05:46:39 tls Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.92.6.1 2012/11/20 03:01:21 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.92.6.2 2012/12/02 05:46:39 tls Exp $");
#include "opt_useleds.h"
@@ -290,6 +290,19 @@
nostop, notty, nopoll, nommap, nokqfilter, D_DISK
};
+static void
+rdminphys(struct buf *bp)
+{
+ struct rd_softc *sc = device_lookup_private(&rd_cd, rdunit(bp->b_dev));
+
+ long xmax;
+ xmax = sc->sc_dev->dv_maxphys;
+ if (bp->b_bcount > xmax)
+ bp->b_bcount = xmax;
+}
+
+const struct dkdriver rd_dkdriver = { rdstrategy, rdminphys };
+
static int
rdmatch(device_t parent, cfdata_t cf, void *aux)
{
@@ -334,7 +347,7 @@
* Initialize and attach the disk structure.
*/
memset(&sc->sc_dkdev, 0, sizeof(sc->sc_dkdev));
- disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), NULL);
+ disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), &rd_dkdriver);
disk_attach(&sc->sc_dkdev);
sc->sc_slave = ha->ha_slave;
diff -r 01e44260d943 -r 2b00f0282e86 sys/arch/vax/mba/hp.c
--- a/sys/arch/vax/mba/hp.c Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/arch/vax/mba/hp.c Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hp.c,v 1.48 2010/12/14 23:38:30 matt Exp $ */
+/* $NetBSD: hp.c,v 1.48.18.1 2012/12/02 05:46:39 tls Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hp.c,v 1.48 2010/12/14 23:38:30 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hp.c,v 1.48.18.1 2012/12/02 05:46:39 tls Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -118,6 +118,8 @@
.d_flag = D_DISK
};
+const struct dkdriver hp_dkdriver = { hpstrategy, minphys };
+
#define HP_WCSR(reg, val) \
bus_space_write_4(sc->sc_iot, sc->sc_ioh, (reg), (val))
#define HP_RCSR(reg) \
@@ -174,7 +176,7 @@
/*
* Init and attach the disk structure.
*/
- disk_init(&sc->sc_disk, device_xname(sc->sc_dev), NULL);
+ disk_init(&sc->sc_disk, device_xname(sc->sc_dev), &hp_dkdriver);
disk_attach(&sc->sc_disk);
/*
diff -r 01e44260d943 -r 2b00f0282e86 sys/arch/vax/vsa/hdc9224.c
--- a/sys/arch/vax/vsa/hdc9224.c Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/arch/vax/vsa/hdc9224.c Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdc9224.c,v 1.51 2010/12/14 23:31:16 matt Exp $ */
+/* $NetBSD: hdc9224.c,v 1.51.18.1 2012/12/02 05:46:39 tls Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -51,7 +51,7 @@
#undef RDDEBUG
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdc9224.c,v 1.51 2010/12/14 23:31:16 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdc9224.c,v 1.51.18.1 2012/12/02 05:46:39 tls Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -228,6 +228,14 @@
#define HDC_WCMD(x) *(volatile char *)(sc->sc_regs + 4) = (x)
#define HDC_RSTAT *(volatile char *)(sc->sc_regs + 4)
+static void
+rdminphys(struct buf *bp)
+{
+ if (bp->b_bcount > rd_dmasize)
+ bp->b_bcount = rd_dmasize;
+}
+
+const struct dkdriver rd_dkdriver = { rdstrategy, rdminphys };
/*
* new-config's hdcmatch() is similiar to old-config's hdcprobe(),
* thus we probe for the existence of the controller and reset it.
@@ -301,7 +309,7 @@
sc->sc_dmabase = (void *)va->va_dmaaddr;
sc->sc_dmasize = va->va_dmasize;
sc->sc_intbit = va->va_maskno;
- rd_dmasize = min(MAXPHYS, sc->sc_dmasize); /* Used in rd_minphys */
+ rd_dmasize = min(MAXPHYS, sc->sc_dmasize); /* Used in rdminphys */
sc->sc_vd.vd_go = hdc_qstart;
sc->sc_vd.vd_arg = sc;
@@ -365,7 +373,7 @@
/*
* Initialize and attach the disk structure.
*/
- disk_init(&rd->sc_disk, device_xname(rd->sc_dev), NULL);
+ disk_init(&rd->sc_disk, device_xname(rd->sc_dev), &rd_dkdriver);
disk_attach(&rd->sc_disk);
/*
diff -r 01e44260d943 -r 2b00f0282e86 sys/dev/ccd.c
--- a/sys/dev/ccd.c Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/dev/ccd.c Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.143 2011/11/13 23:02:46 christos Exp $ */
+/* $NetBSD: ccd.c,v 1.143.10.1 2012/12/02 05:46:39 tls Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.143 2011/11/13 23:02:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.143.10.1 2012/12/02 05:46:39 tls Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -210,6 +210,23 @@
const int ccd_softc_elemsize = sizeof(struct ccd_softc);
int numccd = 0;
+static void
+ccdminphys(struct buf *bp)
+{
+ struct ccd_softc *cs;
+ long xmax;
+ int unit = ccdunit(bp->b_dev);
+
+ cs = &ccd_softc[unit];
+
+ xmax = cs->sc_maxphys;
+
+ if (bp->b_bcount > xmax)
+ bp->b_bcount = xmax;
+}
+
+const struct dkdriver ccd_dkdriver = { ccdstrategy, ccdminphys };
+
/*
* Called by main() during pseudo-device attachment. All we need
* to do is allocate enough space for devices to be configured later.
@@ -246,7 +263,7 @@
cs->sc_iolock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
cv_init(&cs->sc_stop, "ccdstop");
cv_init(&cs->sc_push, "ccdthr");
- disk_init(&cs->sc_dkdev, cs->sc_xname, NULL); /* XXX */
+ disk_init(&cs->sc_dkdev, cs->sc_xname, &ccd_dkdriver);
}
}
@@ -274,6 +291,7 @@
tmppath = kmem_alloc(MAXPATHLEN, KM_SLEEP);
cs->sc_size = 0;
+ cs->sc_maxphys = MACHINE_MAXPHYS;
/*
* Verify that each component piece exists and record
@@ -284,6 +302,7 @@
for (ix = 0, path_alloced = 0; ix < cs->sc_nccdisks; ix++) {
ci = &cs->sc_cinfo[ix];
ci->ci_vp = vpp[ix];
+ struct disk *diskp;
/*
* Copy in the pathname of the component.
@@ -321,6 +340,11 @@
goto out;
}
ci->ci_dev = va.va_rdev;
+ if ((diskp = disk_find_blk(ci->ci_dev)) == NULL) {
+ panic("no disk for device %d %d", major(ci->ci_dev),
+ DISKUNIT(ci->ci_dev));
+ }
+ cs->sc_maxphys = MIN(cs->sc_maxphys, disk_maxphys(diskp));
/*
* Get partition information for the component.
diff -r 01e44260d943 -r 2b00f0282e86 sys/dev/ccdvar.h
--- a/sys/dev/ccdvar.h Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/dev/ccdvar.h Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ccdvar.h,v 1.32 2011/02/08 20:20:26 rmind Exp $ */
+/* $NetBSD: ccdvar.h,v 1.32.14.1 2012/12/02 05:46:39 tls Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -176,6 +176,7 @@
struct lwp *sc_thread; /* for deferred I/O */
kcondvar_t sc_push; /* for deferred I/O */
bool sc_zap; /* for deferred I/O */
+ size_t sc_maxphys; /* Max I/O size */
#endif
};
diff -r 01e44260d943 -r 2b00f0282e86 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/dev/dkwedge/dk.c Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.64.2.1 2012/11/20 03:02:00 tls Exp $ */
+/* $NetBSD: dk.c,v 1.64.2.2 2012/12/02 05:46:40 tls Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.64.2.1 2012/11/20 03:02:00 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.64.2.2 2012/12/02 05:46:40 tls Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -118,6 +118,8 @@
nostop, notty, nopoll, nommap, nokqfilter, D_DISK
};
+const struct dkdriver dk_dkdriver = { dkstrategy, dkminphys };
+
static struct dkwedge_softc **dkwedges;
static u_int ndkwedges;
static krwlock_t dkwedges_lock;
@@ -432,7 +434,7 @@
* of state to RUNNING atomic.
*/
- disk_init(&sc->sc_dk, device_xname(sc->sc_dev), NULL);
+ disk_init(&sc->sc_dk, device_xname(sc->sc_dev), &dk_dkdriver);
disk_blocksize(&sc->sc_dk, DEV_BSIZE << pdk->dk_blkshift);
dkgetproperties(&sc->sc_dk, dkw);
disk_attach(&sc->sc_dk);
diff -r 01e44260d943 -r 2b00f0282e86 sys/dev/fss.c
--- a/sys/dev/fss.c Sun Dec 02 05:46:03 2012 +0000
+++ b/sys/dev/fss.c Sun Dec 02 05:46:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $ */
+/* $NetBSD: fss.c,v 1.83.2.1 2012/12/02 05:46:39 tls Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.83.2.1 2012/12/02 05:46:39 tls Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -117,6 +117,19 @@
fss_match, fss_attach, fss_detach, NULL);
extern struct cfdriver fss_cd;
+static void
+fss_minphys(struct buf *bp)
+{
+ struct fss_softc *fc = device_lookup_private(&fss_cd, minor(bp->b_dev));
+
+ long xmax;
+ xmax = fc->sc_mount->mnt_maxphys;
+ if (bp->b_bcount > xmax)
+ bp->b_bcount = xmax;
+}
+
+const struct dkdriver fss_dkdriver = { fss_strategy, fss_minphys };
Home |
Main Index |
Thread Index |
Old Index