Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dkwedge Implement d_discard for dk. This closes PR 4...



details:   https://anonhg.NetBSD.org/src/rev/d93183a43424
branches:  trunk
changeset: 330909:d93183a43424
user:      dholland <dholland%NetBSD.org@localhost>
date:      Fri Jul 25 08:23:56 2014 +0000

description:
Implement d_discard for dk. This closes PR 47940.

diffstat:

 sys/dev/dkwedge/dk.c |  29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diffs (71 lines):

diff -r 25d8ef28b307 -r d93183a43424 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Fri Jul 25 08:22:08 2014 +0000
+++ b/sys/dev/dkwedge/dk.c      Fri Jul 25 08:23:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.71 2014/07/25 08:10:36 dholland Exp $ */
+/*     $NetBSD: dk.c,v 1.72 2014/07/25 08:23:56 dholland 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.71 2014/07/25 08:10:36 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.72 2014/07/25 08:23:56 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -108,6 +108,7 @@
 static dev_type_strategy(dkstrategy);
 static dev_type_dump(dkdump);
 static dev_type_size(dksize);
+static dev_type_discard(dkdiscard);
 
 const struct bdevsw dk_bdevsw = {
        .d_open = dkopen,
@@ -116,7 +117,7 @@
        .d_ioctl = dkioctl,
        .d_dump = dkdump,
        .d_psize = dksize,
-       .d_discard = nodiscard,
+       .d_discard = dkdiscard,
        .d_flag = D_DISK
 };
 
@@ -131,7 +132,7 @@
        .d_poll = nopoll,
        .d_mmap = nommap,
        .d_kqfilter = nokqfilter,
-       .d_discard = nodiscard,
+       .d_discard = dkdiscard,
        .d_flag = D_DISK
 };
 
@@ -1341,6 +1342,26 @@
 }
 
 /*
+ * dkdiscard:          [devsw entry point]
+ *
+ *     Perform a discard-range request on a wedge.
+ */
+static int
+dkdiscard(dev_t dev, off_t pos, off_t len)
+{
+       struct dkwedge_softc *sc = dkwedge_lookup(dev);
+
+       if (sc == NULL)
+               return (ENODEV);
+       if (sc->sc_state != DKW_STATE_RUNNING)
+               return (ENXIO);
+       if (sc->sc_parent->dk_rawvp == NULL)
+               return (ENXIO);
+
+       return VOP_FDISCARD(sc->sc_parent->dk_rawvp, pos, len);
+}
+
+/*
  * dksize:             [devsw entry point]
  *
  *     Query the size of a wedge for the purpose of performing a dump



Home | Main Index | Thread Index | Old Index