Source-Changes-HG archive

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

[src/trunk]: src/sys/dev support DIOCGCACHE - result is intersection of flags...



details:   https://anonhg.NetBSD.org/src/rev/cdf65567da52
branches:  trunk
changeset: 822654:cdf65567da52
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Mar 30 16:50:32 2017 +0000

description:
support DIOCGCACHE - result is intersection of flags returned by underlying
devices; devices can't be added or removed, so the feature flags remain
static

add support for DIOCGSTRATEGY while here, mainly to make dkctl(8) output neater

diffstat:

 sys/dev/ccd.c |  50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 48 insertions(+), 2 deletions(-)

diffs (78 lines):

diff -r 9339c2ce15a1 -r cdf65567da52 sys/dev/ccd.c
--- a/sys/dev/ccd.c     Thu Mar 30 09:16:52 2017 +0000
+++ b/sys/dev/ccd.c     Thu Mar 30 16:50:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ccd.c,v 1.169 2017/03/05 23:07:12 mlelstv Exp $        */
+/*     $NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.169 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1182,6 +1182,8 @@
        switch (cmd) {
        case CCDIOCCLR:
        case DIOCGDINFO:
+       case DIOCGSTRATEGY:
+       case DIOCGCACHE:
        case DIOCCACHESYNC:
        case DIOCAWEDGE:
        case DIOCDWEDGE:
@@ -1393,6 +1395,50 @@
                /* Don't break, otherwise cs is read again. */
                return 0;
 
+       case DIOCGSTRATEGY:
+           {
+               struct disk_strategy *dks = (void *)data;
+
+               mutex_enter(cs->sc_iolock);
+               if (cs->sc_bufq != NULL)
+                       strlcpy(dks->dks_name,
+                           bufq_getstrategyname(cs->sc_bufq),
+                           sizeof(dks->dks_name));
+               else
+                       error = EINVAL;
+               mutex_exit(cs->sc_iolock);
+               dks->dks_paramlen = 0;
+               break;
+           }
+
+       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. CCD components
+                * can not change unless the device is unconfigured, so
+                * device feature flags will remain static. RCE/WCE can change
+                * of course, if set directly on underlying device.
+                */
+               for (error = 0, i = 0; i < cs->sc_nccdisks; i++) {
+                       error = VOP_IOCTL(cs->sc_cinfo[i].ci_vp, cmd, &j,
+                                     flag, uc);
+                       if (error)
+                               break;
+
+                       if (i == 0)
+                               dkcache = j;
+                       else
+                               dkcache &= j;
+               }
+
+               *((int *)data) = dkcache;
+               break;
+           }
+
        case DIOCCACHESYNC:
                /*
                 * We pass this call down to all components and report



Home | Main Index | Thread Index | Old Index