Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add support for implementing discard functionality w...
details: https://anonhg.NetBSD.org/src/rev/06a2623d6d65
branches: trunk
changeset: 339950:06a2623d6d65
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Mon Aug 17 19:47:21 2015 +0000
description:
Add support for implementing discard functionality with ld(4)
diffstat:
sys/dev/ld.c | 38 +++++++++++++++++++++++++++++++++-----
sys/dev/ldvar.h | 3 ++-
2 files changed, 35 insertions(+), 6 deletions(-)
diffs (108 lines):
diff -r 7c3ac419b7f5 -r 06a2623d6d65 sys/dev/ld.c
--- a/sys/dev/ld.c Mon Aug 17 18:43:37 2015 +0000
+++ b/sys/dev/ld.c Mon Aug 17 19:47:21 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld.c,v 1.89 2015/08/16 18:00:03 mlelstv Exp $ */
+/* $NetBSD: ld.c,v 1.90 2015/08/17 19:47:21 jakllsch Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.89 2015/08/16 18:00:03 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.90 2015/08/17 19:47:21 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,6 +70,7 @@
static void ld_set_geometry(struct ld_softc *);
static void ld_config_interrupts (device_t);
static int ld_lastclose(device_t);
+static int ld_discard(device_t, off_t, off_t);
extern struct cfdriver ld_cd;
@@ -81,6 +82,7 @@
static dev_type_strategy(ldstrategy);
static dev_type_dump(lddump);
static dev_type_size(ldsize);
+static dev_type_discard(lddiscard);
const struct bdevsw ld_bdevsw = {
.d_open = ldopen,
@@ -89,7 +91,7 @@
.d_ioctl = ldioctl,
.d_dump = lddump,
.d_psize = ldsize,
- .d_discard = nodiscard,
+ .d_discard = lddiscard,
.d_flag = D_DISK | D_MPSAFE
};
@@ -104,7 +106,7 @@
.d_poll = nopoll,
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
- .d_discard = nodiscard,
+ .d_discard = lddiscard,
.d_flag = D_DISK | D_MPSAFE
};
@@ -116,7 +118,8 @@
.d_minphys = ldminphys,
.d_diskstart = ld_diskstart,
.d_dumpblocks = ld_dumpblocks,
- .d_lastclose = ld_lastclose
+ .d_lastclose = ld_lastclose,
+ .d_discard = ld_discard
};
void
@@ -578,3 +581,28 @@
dkwedge_discover(&dksc->sc_dkdev);
}
+
+static int
+ld_discard(device_t dev, off_t pos, off_t len)
+{
+ struct ld_softc *sc = device_private(dev);
+
+ if (sc->sc_discard == NULL)
+ return (ENXIO);
+
+ return (*sc->sc_discard)(sc, pos, len);
+}
+
+static int
+lddiscard(dev_t dev, off_t pos, off_t len)
+{
+ struct ld_softc *sc;
+ struct dk_softc *dksc;
+ int unit;
+
+ unit = DISKUNIT(dev);
+ sc = device_lookup_private(&ld_cd, unit);
+ dksc = &sc->sc_dksc;
+
+ return dk_discard(dksc, dev, pos, len);
+}
diff -r 7c3ac419b7f5 -r 06a2623d6d65 sys/dev/ldvar.h
--- a/sys/dev/ldvar.h Mon Aug 17 18:43:37 2015 +0000
+++ b/sys/dev/ldvar.h Mon Aug 17 19:47:21 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldvar.h,v 1.25 2015/08/16 14:02:52 mlelstv Exp $ */
+/* $NetBSD: ldvar.h,v 1.26 2015/08/17 19:47:21 jakllsch Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -62,6 +62,7 @@
int (*sc_dump)(struct ld_softc *, void *, int, int);
int (*sc_flush)(struct ld_softc *, int);
int (*sc_start)(struct ld_softc *, struct buf *);
+ int (*sc_discard)(struct ld_softc *, off_t, off_t);
};
/* sc_flags */
Home |
Main Index |
Thread Index |
Old Index