Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/dev/dkwedge Pull up following revision(s) (requested ...



details:   https://anonhg.NetBSD.org/src/rev/6a87df17ff05
branches:  netbsd-7
changeset: 798309:6a87df17ff05
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Aug 29 11:49:41 2014 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #65):
        sys/dev/dkwedge/dk.c: revision 1.73
Make dk(4) discard from partition start, not from disk start.
Otherwise, anything mounted with `-o discard' will pretty quickly
munch itself up and barf up an unrecoverably corrupted file system!
XXX pullup to netbsd-7

diffstat:

 sys/dev/dkwedge/dk.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (49 lines):

diff -r 34603b6a87e5 -r 6a87df17ff05 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Fri Aug 29 11:47:16 2014 +0000
+++ b/sys/dev/dkwedge/dk.c      Fri Aug 29 11:49:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.72 2014/07/25 08:23:56 dholland Exp $ */
+/*     $NetBSD: dk.c,v 1.72.2.1 2014/08/29 11:49:41 martin 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.72 2014/07/25 08:23:56 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.72.2.1 2014/08/29 11:49:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1350,6 +1350,8 @@
 dkdiscard(dev_t dev, off_t pos, off_t len)
 {
        struct dkwedge_softc *sc = dkwedge_lookup(dev);
+       unsigned shift;
+       off_t offset, maxlen;
 
        if (sc == NULL)
                return (ENODEV);
@@ -1358,6 +1360,21 @@
        if (sc->sc_parent->dk_rawvp == NULL)
                return (ENXIO);
 
+       shift = (sc->sc_parent->dk_blkshift + DEV_BSHIFT);
+       KASSERT(__type_fit(off_t, sc->sc_size));
+       KASSERT(__type_fit(off_t, sc->sc_offset));
+       KASSERT(0 <= sc->sc_offset);
+       KASSERT(sc->sc_size <= (__type_max(off_t) >> shift));
+       KASSERT(sc->sc_offset <= ((__type_max(off_t) >> shift) - sc->sc_size));
+       offset = ((off_t)sc->sc_offset << shift);
+       maxlen = ((off_t)sc->sc_size << shift);
+
+       if (len > maxlen)
+               return (EINVAL);
+       if (pos > (maxlen - len))
+               return (EINVAL);
+
+       pos += offset;
        return VOP_FDISCARD(sc->sc_parent->dk_rawvp, pos, len);
 }
 



Home | Main Index | Thread Index | Old Index