Module Name: src
Committed By: jdolecek
Date: Tue Oct 23 22:05:01 UTC 2018
Modified Files:
src/sys/dev/ata: TODO.ncq ld_ataraid.c
Log Message:
add support for DIOCCACHESYNC (!), and DIOCGCACHE; code adapted from ccd(4)
tested with Intel ATA Raid
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/TODO.ncq
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/ata/ld_ataraid.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ata/TODO.ncq
diff -u src/sys/dev/ata/TODO.ncq:1.9 src/sys/dev/ata/TODO.ncq:1.10
--- src/sys/dev/ata/TODO.ncq:1.9 Mon Oct 22 21:25:23 2018
+++ src/sys/dev/ata/TODO.ncq Tue Oct 23 22:05:01 2018
@@ -15,4 +15,5 @@ set
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
Index: src/sys/dev/ata/ld_ataraid.c
diff -u src/sys/dev/ata/ld_ataraid.c:1.47 src/sys/dev/ata/ld_ataraid.c:1.48
--- src/sys/dev/ata/ld_ataraid.c:1.47 Mon Oct 22 19:36:28 2018
+++ src/sys/dev/ata/ld_ataraid.c Tue Oct 23 22:05:01 2018
@@ -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 int ld_ataraid_match(device_t, cf
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_ataraid_attach(device_t parent, devic
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 @@ ld_ataraid_biodisk(struct ld_ataraid_sof
}
#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