Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Merge dk_intf and dkdriver interfaces.
details: https://anonhg.NetBSD.org/src/rev/0bd0740f9dab
branches: trunk
changeset: 337868:0bd0740f9dab
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sat May 02 08:00:08 2015 +0000
description:
Merge dk_intf and dkdriver interfaces.
Merge common disk driver functionality in ld.c with dksubr.c.
Adjust the two previous users of dk_intf (cgd and xbd) to
the changes.
bump kernel version to 7.99.14
diffstat:
sys/arch/xen/include/xbdvar.h | 4 +-
sys/arch/xen/xen/xbd_xenbus.c | 52 +--
sys/dev/cgd.c | 79 ++--
sys/dev/dksubr.c | 185 +++++++++---
sys/dev/dkvar.h | 42 +-
sys/dev/ld.c | 605 +++++++++++------------------------------
sys/dev/ldvar.h | 18 +-
sys/sys/disk.h | 18 +-
sys/sys/param.h | 4 +-
9 files changed, 402 insertions(+), 605 deletions(-)
diffs (truncated from 1958 to 300 lines):
diff -r 67dfc0683b16 -r 0bd0740f9dab sys/arch/xen/include/xbdvar.h
--- a/sys/arch/xen/include/xbdvar.h Fri May 01 23:55:14 2015 +0000
+++ b/sys/arch/xen/include/xbdvar.h Sat May 02 08:00:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xbdvar.h,v 1.16 2015/04/14 20:32:35 riastradh Exp $ */
+/* $NetBSD: xbdvar.h,v 1.17 2015/05/02 08:00:08 mlelstv Exp $ */
/*
*
@@ -36,7 +36,6 @@
device_t sc_dev; /* base device glue */
struct dk_softc sc_dksc; /* generic disk interface */
unsigned long sc_xd_device; /* cookie identifying device */
- struct dk_intf *sc_di; /* pseudo-disk interface */
int sc_shutdown; /* about to be removed */
krndsource_t sc_rnd_source;
};
@@ -44,7 +43,6 @@
struct xbd_attach_args {
const char *xa_device;
vdisk_t *xa_xd;
- struct dk_intf *xa_dkintf;
struct sysctlnode *xa_diskcookies;
};
diff -r 67dfc0683b16 -r 0bd0740f9dab sys/arch/xen/xen/xbd_xenbus.c
--- a/sys/arch/xen/xen/xbd_xenbus.c Fri May 01 23:55:14 2015 +0000
+++ b/sys/arch/xen/xen/xbd_xenbus.c Sat May 02 08:00:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xbd_xenbus.c,v 1.70 2015/04/13 21:18:40 riastradh Exp $ */
+/* $NetBSD: xbd_xenbus.c,v 1.71 2015/05/02 08:00:08 mlelstv Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.70 2015/04/13 21:18:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.71 2015/05/02 08:00:08 mlelstv Exp $");
#include "opt_xen.h"
@@ -168,7 +168,7 @@
static bool xbd_xenbus_resume(device_t, const pmf_qual_t *);
static int xbd_handler(void *);
-static void xbdstart(struct dk_softc *);
+static void xbdstart(device_t);
static void xbd_backend_changed(void *, XenbusState);
static void xbd_connect(struct xbd_xenbus_softc *);
@@ -218,19 +218,12 @@
extern struct cfdriver xbd_cd;
-/* Pseudo-disk Interface */
-static struct dk_intf dkintf_esdi = {
- DKTYPE_ESDI,
- "Xen Virtual ESDI",
- xbdopen,
- xbdclose,
- xbdstrategy,
- xbdstart,
-}, *di = &dkintf_esdi;
-
static struct dkdriver xbddkdriver = {
.d_strategy = xbdstrategy,
.d_minphys = xbdminphys,
+ .d_open = xbdopen,
+ .d_close = xbdclose,
+ .d_diskstart = xbdstart,
};
static int
@@ -265,8 +258,8 @@
config_pending_incr(self);
aprint_normal(": Xen Virtual Block Device Interface\n");
- dk_sc_init(&sc->sc_dksc, device_xname(self));
- sc->sc_dksc.sc_dev = self;
+ dk_init(&sc->sc_dksc, self, DKTYPE_ESDI);
+ disk_init(&sc->sc_dksc.sc_dkdev, device_xname(self), &xbddkdriver);
#ifdef XBD_DEBUG
printf("path: %s\n", xa->xa_xbusd->xbusd_path);
@@ -293,7 +286,6 @@
sc->sc_xbusd = xa->xa_xbusd;
sc->sc_xbusd->xbusd_otherend_changed = xbd_backend_changed;
- disk_init(&sc->sc_dksc.sc_dkdev, device_xname(self), &xbddkdriver);
/* initialize free requests list */
SLIST_INIT(&sc->sc_xbdreq_head);
for (i = 0; i < XBD_RING_SIZE; i++) {
@@ -380,6 +372,7 @@
/* detach disk */
disk_detach(&sc->sc_dksc.sc_dkdev);
disk_destroy(&sc->sc_dksc.sc_dkdev);
+ dk_detach(&sc->sc_dksc);
/* Unhook the entropy source. */
rnd_detach_source(&sc->sc_rnd_source);
}
@@ -580,13 +573,13 @@
dg->dg_ncylinders = dg->dg_secperunit / dg->dg_nsectors;
bufq_alloc(&sc->sc_dksc.sc_bufq, "fcfs", 0);
- sc->sc_dksc.sc_flags |= DKF_INITED;
+ dk_attach(&sc->sc_dksc);
disk_attach(&sc->sc_dksc.sc_dkdev);
sc->sc_backend_status = BLKIF_STATE_CONNECTED;
/* try to read the disklabel */
- dk_getdisklabel(di, &sc->sc_dksc, 0 /* XXX ? */);
+ dk_getdisklabel(&sc->sc_dksc, 0 /* XXX ? */);
format_bytes(buf, sizeof(buf), sc->sc_sectors * sc->sc_secsize);
aprint_verbose_dev(sc->sc_dksc.sc_dev,
"%s, %d bytes/sect x %" PRIu64 " sectors\n",
@@ -727,7 +720,7 @@
if (sc->sc_xbdreq_wait)
wakeup(&sc->sc_xbdreq_wait);
else
- xbdstart(&sc->sc_dksc);
+ xbdstart(sc->sc_dksc.sc_dev);
return 1;
}
@@ -752,7 +745,7 @@
return EROFS;
DPRINTF(("xbdopen(0x%04x, %d)\n", dev, flags));
- return dk_open(di, &sc->sc_dksc, dev, flags, fmt, l);
+ return dk_open(&sc->sc_dksc, dev, flags, fmt, l);
}
int
@@ -763,7 +756,7 @@
sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
DPRINTF(("xbdclose(%d, %d)\n", dev, flags));
- return dk_close(di, &sc->sc_dksc, dev, flags, fmt, l);
+ return dk_close(&sc->sc_dksc, dev, flags, fmt, l);
}
void
@@ -788,7 +781,7 @@
return;
}
- dk_strategy(di, &sc->sc_dksc, bp);
+ dk_strategy(&sc->sc_dksc, bp);
return;
}
@@ -802,7 +795,7 @@
sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
if (sc == NULL || sc->sc_shutdown != BLKIF_SHUTDOWN_RUN)
return -1;
- return dk_size(di, &sc->sc_dksc, dev);
+ return dk_size(&sc->sc_dksc, dev);
}
int
@@ -812,7 +805,7 @@
device_lookup_private(&xbd_cd, DISKUNIT(dev));
struct dk_softc *dksc = &sc->sc_dksc;
- if ((dksc->sc_flags & DKF_INITED) == 0)
+ if (!DK_ATTACHED(dksc))
return ENXIO;
return physio(xbdstrategy, NULL, dev, B_READ, xbdminphys, uio);
}
@@ -824,7 +817,7 @@
device_lookup_private(&xbd_cd, DISKUNIT(dev));
struct dk_softc *dksc = &sc->sc_dksc;
- if ((dksc->sc_flags & DKF_INITED) == 0)
+ if (!DK_ATTACHED(dksc))
return ENXIO;
if (__predict_false(sc->sc_info & VDISK_READONLY))
return EROFS;
@@ -904,7 +897,7 @@
break;
default:
- error = dk_ioctl(di, dksc, dev, cmd, data, flag, l);
+ error = dk_ioctl(dksc, dev, cmd, data, flag, l);
break;
}
@@ -922,13 +915,14 @@
DPRINTF(("xbddump(%d, %" PRId64 ", %p, %lu)\n", dev, blkno, va,
(unsigned long)size));
- return dk_dump(di, &sc->sc_dksc, dev, blkno, va, size);
+ return dk_dump(&sc->sc_dksc, dev, blkno, va, size);
}
static void
-xbdstart(struct dk_softc *dksc)
+xbdstart(device_t self)
{
- struct xbd_xenbus_softc *sc = (struct xbd_xenbus_softc *)dksc;
+ struct xbd_xenbus_softc *sc = device_private(self);
+ struct dk_softc *dksc = &sc->sc_dksc;
struct buf *bp;
#ifdef DIAGNOSTIC
struct buf *qbp;
diff -r 67dfc0683b16 -r 0bd0740f9dab sys/dev/cgd.c
--- a/sys/dev/cgd.c Fri May 01 23:55:14 2015 +0000
+++ b/sys/dev/cgd.c Sat May 02 08:00:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.97 2015/04/25 13:06:11 riastradh Exp $ */
+/* $NetBSD: cgd.c,v 1.98 2015/05/02 08:00:08 mlelstv Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.97 2015/04/25 13:06:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.98 2015/05/02 08:00:08 mlelstv Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -104,7 +104,7 @@
/* Internal Functions */
-static void cgdstart(struct dk_softc *);
+static void cgd_start(device_t);
static void cgdiodone(struct buf *);
static int cgd_ioctl_set(struct cgd_softc *, void *, struct lwp *);
@@ -115,21 +115,15 @@
static void cgd_cipher(struct cgd_softc *, void *, void *,
size_t, daddr_t, size_t, int);
-/* Pseudo-disk Interface */
-
-static struct dk_intf the_dkintf = {
- DKTYPE_CGD,
- "cgd",
- cgdopen,
- cgdclose,
- cgdstrategy,
- cgdstart,
-};
-static struct dk_intf *di = &the_dkintf;
-
static struct dkdriver cgddkdriver = {
- .d_strategy = cgdstrategy,
- .d_minphys = minphys,
+ .d_minphys = minphys,
+ .d_open = cgdopen,
+ .d_close = cgdclose,
+ .d_strategy = cgdstrategy,
+ .d_iosize = NULL,
+ .d_diskstart = cgd_start,
+ .d_dumpblocks = NULL,
+ .d_lastclose = NULL
};
CFATTACH_DECL3_NEW(cgd, sizeof(struct cgd_softc),
@@ -205,11 +199,10 @@
struct cgd_softc *sc = device_private(self);
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_BIO);
- dk_sc_init(&sc->sc_dksc, device_xname(self));
- sc->sc_dksc.sc_dev = self;
+ dk_init(&sc->sc_dksc, self, DKTYPE_CGD);
disk_init(&sc->sc_dksc.sc_dkdev, sc->sc_dksc.sc_xname, &cgddkdriver);
- if (!pmf_device_register(self, NULL, NULL))
+ if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "unable to register power management hooks\n");
}
@@ -225,7 +218,7 @@
if (DK_BUSY(dksc, pmask))
return EBUSY;
- if ((dksc->sc_flags & DKF_INITED) != 0 &&
+ if (DK_ATTACHED(dksc) &&
(ret = cgd_ioctl_clr(sc, curlwp)) != 0)
return ret;
@@ -281,7 +274,7 @@
DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags));
GETCGD_SOFTC(cs, dev);
- return dk_open(di, &cs->sc_dksc, dev, flags, fmt, l);
+ return dk_open(&cs->sc_dksc, dev, flags, fmt, l);
}
static int
@@ -294,10 +287,10 @@
DPRINTF_FOLLOW(("cgdclose(0x%"PRIx64", %d)\n", dev, flags));
GETCGD_SOFTC(cs, dev);
Home |
Main Index |
Thread Index |
Old Index