NetBSD-Bugs archive

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

kern/47940: "discard" ffs mount option does not work on wedges



>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:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 17 15:15:00 +0000 2013
>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@localhost:/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;
        }
        

>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index