Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ata add support for DIOCCACHESYNC (!), and DIOCGCACH...



details:   https://anonhg.NetBSD.org/src/rev/4d3e458fa1ec
branches:  trunk
changeset: 445343:4d3e458fa1ec
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Oct 23 22:05:01 2018 +0000

description:
add support for DIOCCACHESYNC (!), and DIOCGCACHE; code adapted from ccd(4)

tested with Intel ATA Raid

diffstat:

 sys/dev/ata/TODO.ncq     |   3 +-
 sys/dev/ata/ld_ataraid.c |  73 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 3 deletions(-)

diffs (118 lines):

diff -r 656626a7c0f5 -r 4d3e458fa1ec sys/dev/ata/TODO.ncq
--- a/sys/dev/ata/TODO.ncq      Tue Oct 23 20:09:40 2018 +0000
+++ b/sys/dev/ata/TODO.ncq      Tue Oct 23 22:05:01 2018 +0000
@@ -15,4 +15,5 @@
 
 add support for the NCQ TRIM if supported by device?
 
-implement DIOCGCACHE/DIOCCACHESYNC for ld@ataraid? just passthrough, like ccd
+ahcisata(4)/siisata(4) - enable detach on shutdown, and fix the issue
+with atabus being detached several times
diff -r 656626a7c0f5 -r 4d3e458fa1ec sys/dev/ata/ld_ataraid.c
--- a/sys/dev/ata/ld_ataraid.c  Tue Oct 23 20:09:40 2018 +0000
+++ b/sys/dev/ata/ld_ataraid.c  Tue Oct 23 22:05:01 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld_ataraid.c,v 1.47 2018/10/22 19:36:28 jdolecek Exp $ */
+/*     $NetBSD: ld_ataraid.c,v 1.48 2018/10/23 22:05:01 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.47 2018/10/22 19:36:28 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.48 2018/10/23 22:05:01 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "bio.h"
@@ -102,6 +102,8 @@
 static void    ld_ataraid_attach(device_t, device_t, void *);
 
 static int     ld_ataraid_dump(struct ld_softc *, void *, int, int);
+static int     ld_ataraid_ioctl(struct ld_softc *, u_long, void *, int32_t,
+    bool);
 
 static int     cbufpool_ctor(void *, void *, int);
 static void    cbufpool_dtor(void *, void *);
@@ -170,6 +172,7 @@
        ld->sc_secsize = 512;                           /* XXX */
        ld->sc_maxqueuecnt = 128;                       /* XXX */
        ld->sc_dump = ld_ataraid_dump;
+       ld->sc_ioctl = ld_ataraid_ioctl;
 
        switch (aai->aai_level) {
        case AAI_L_SPAN:
@@ -715,6 +718,72 @@
 }
 #endif /* NBIO > 0 */
 
+static int
+ld_ataraid_ioctl(struct ld_softc *ld, u_long cmd, void *addr, int32_t flag,
+    bool poll)
+{
+       struct ld_ataraid_softc *sc = (void *)ld;
+       int error, i, j;
+       kauth_cred_t uc;
+
+       uc = kauth_cred_get();
+
+       switch (cmd) {
+       case DIOCGCACHE:
+           {
+               int dkcache = 0;
+
+               /*
+                * We pass this call down to all components and report
+                * intersection of the flags returned by the components.
+                * If any errors out, we return error. ATA RAID components
+                * can only change via BIOS, device feature flags will remain
+                * static. RCE/WCE can change if set directly on underlying
+                * device.
+                */
+               for (error = 0, i = 0; i < sc->sc_aai->aai_ndisks; i++) {
+                       KASSERT(sc->sc_vnodes[i] != NULL);
+
+                       error = VOP_IOCTL(sc->sc_vnodes[i], cmd, &j,
+                                     flag, uc);
+                       if (error)
+                               break;
+
+                       if (i == 0)
+                               dkcache = j;
+                       else
+                               dkcache = DKCACHE_COMBINE(dkcache, j);
+               }
+
+               *((int *)addr) = dkcache;
+               break;
+           }
+
+       case DIOCCACHESYNC:
+           {
+               /*
+                * We pass this call down to all components and report
+                * the first error we encounter.
+                */
+               for (error = 0, i = 0; i < sc->sc_aai->aai_ndisks; i++) {
+                       KASSERT(sc->sc_vnodes[i] != NULL);
+
+                       j = VOP_IOCTL(sc->sc_vnodes[i], cmd, addr,
+                                     flag, uc);
+                       if (j != 0 && error == 0)
+                               error = j;
+               }
+               break;
+           }
+
+       default:
+               error = EPASSTHROUGH;
+               break;
+       }
+
+       return error;
+}
+
 MODULE(MODULE_CLASS_DRIVER, ld_ataraid, "ld,ataraid");
 
 #ifdef _MODULE



Home | Main Index | Thread Index | Old Index