NetBSD Problem Report #47940
From riz@slash.lan Mon Jun 17 15:13:23 2013
Return-Path: <riz@slash.lan>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 3A4B270B8A
for <gnats-bugs@gnats.NetBSD.org>; Mon, 17 Jun 2013 15:13:23 +0000 (UTC)
Message-Id: <20130617151113.39518D504D@slash.lan>
Date: Mon, 17 Jun 2013 08:11:13 -0700 (PDT)
From: riz@NetBSD.org
Reply-To: riz@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: "discard" ffs mount option does not work on wedges
X-Send-Pr-Version: 3.95
>Number: 47940
>Category: kern
>Synopsis: "discard" ffs mount option does not work on wedges
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 17 15:15:00 +0000 2013
>Closed-Date: Sat Jul 26 23:06:29 +0000 2014
>Last-Modified: Sat Jul 26 23:06:29 +0000 2014
>Originator: Jeff Rizzo
>Release: NetBSD 6.99.21
>Organization:
>Environment:
System: NetBSD slash.lan 6.99.21 NetBSD 6.99.21 (DTRACE) #23: Sun Jun 16 22:36:30 PDT 2013 riz@slash.lan:/usr/src/sys/arch/amd64/compile/DTRACE amd64
Architecture: x86_64
Machine: amd64
>Description:
The "discard" mount option, set in /etc/fstab or otherwise,
returns ENOTTY if the underlying device is a dk(4) device,
even though the drive supports it.
>How-To-Repeat:
Try to mount -o discard /dev/dk0 /mnt, see cryptic "DIOCGPARAMS: 25"
"error" message. Check the source code and see that it's probably
not enabled.
>Fix:
This patch is only lightly tested. I'm still having problems
with kern/47937 (discard and log don't play nicely together), so
I'm not ready to commit this yet - I'd love if someone else could
test this.
Index: sys/dev/dkwedge/dk.c
===================================================================
RCS file: /cvsroot/src/sys/dev/dkwedge/dk.c,v
retrieving revision 1.66
diff -u -r1.66 dk.c
--- sys/dev/dkwedge/dk.c 29 May 2013 00:47:48 -0000 1.66
+++ sys/dev/dkwedge/dk.c 17 Jun 2013 15:07:53 -0000
@@ -1315,6 +1315,29 @@
break;
}
+ case DIOCGDISCARDPARAMS:
+ error = VOP_IOCTL(sc->sc_parent->dk_rawvp, cmd, data, flag,
+ l != NULL ? l->l_cred : NOCRED);
+ break;
+
+ case DIOCDISCARD: {
+ struct disk_discard_range *dr;
+
+ dr = (struct disk_discard_range *)data;
+#define DSIZE sc->sc_parent->dk_geom.dg_secperunit
+ if (dr->size > (DSIZE - sc->sc_offset))
+ return EINVAL;
+ if (dr->bno > DSIZE - sc->sc_offset - dr->size)
+ return EINVAL;
+ dr->bno += sc->sc_offset;
+ if (dr->bno > DSIZE)
+ return EINVAL;
+#undef DSIZE
+ error = VOP_IOCTL(sc->sc_parent->dk_rawvp, cmd, data, flag,
+ l != NULL ? l->l_cred : NOCRED);
+ break;
+ }
+
default:
error = ENOTTY;
}
>Release-Note:
>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/47940: "discard" ffs mount option does not work on wedges
Date: Mon, 17 Jun 2013 11:36:20 -0400
On Jun 17, 3:15pm, riz@NetBSD.org (riz@NetBSD.org) wrote:
-- Subject: kern/47940: "discard" ffs mount option does not work on wedges
| + case DIOCGDISCARDPARAMS:
| + error = VOP_IOCTL(sc->sc_parent->dk_rawvp, cmd, data, flag,
| + l != NULL ? l->l_cred : NOCRED);
| + break;
| +
| + case DIOCDISCARD: {
| + struct disk_discard_range *dr;
| +
| + dr = (struct disk_discard_range *)data;
The cast is not needed since data is void *.
| +#define DSIZE sc->sc_parent->dk_geom.dg_secperunit
| + if (dr->size > (DSIZE - sc->sc_offset))
| + return EINVAL;
| + if (dr->bno > DSIZE - sc->sc_offset - dr->size)
| + return EINVAL;
| + dr->bno += sc->sc_offset;
| + if (dr->bno > DSIZE)
| + return EINVAL;
These values are all signed so they should not be allowed to be negative.
christos
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47940 CVS commit: src/sys/dev/dkwedge
Date: Fri, 25 Jul 2014 08:23:57 +0000
Module Name: src
Committed By: dholland
Date: Fri Jul 25 08:23:57 UTC 2014
Modified Files:
src/sys/dev/dkwedge: dk.c
Log Message:
Implement d_discard for dk. This closes PR 47940.
To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/dkwedge/dk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 26 Jul 2014 23:06:29 +0000
State-Changed-Why:
fixed (with different code)
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.