tech-kern archive

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

Re: Raidframe and disk strategy



        Hello.  Here is a script showing what I hav in mind.  This is
NetBSD-5.1, but I have patches for both 5.1 and -current, included below,
which do exactly the same thing.  Any reason I shouldn't commit this in the
next week or so, assuming I don't run into any show stoppers in my 5.1
production environment?
I should be able to say in a week or so how much of a performance increase
this makes.

-thanks
-Brian

Script started on Wed Aug  8 21:44:45 2012
[Before the patch]
rbl# dkctl /dev/rraid0d strategy
dkctl: /dev/rraid0d: DIOCGSTRATEGY: Inappropriate ioctl for device

[After the patch...]
rbl# dkctl /dev/rraid0d strategy
/dev/rraid0d: fcfs
rbl#dkctl /dev/rraid0d strategy priocscan
/dev/rraid0d: fcfs -> priocscan
rbl# dkctl /dev/rraid0d strategy
/dev/rraid0d: priocscan
rbl# exit

Script done on Wed Aug  8 21:45:55 2012

[Patch against 5.1 sources from July 18, 2012]

--- rf_netbsdkintf.c.51 2012-07-19 13:10:21.000000000 -0700
+++ rf_netbsdkintf.c    2012-08-08 16:36:20.000000000 -0700
@@ -973,7 +973,7 @@
 {
        int     unit = raidunit(dev);
        int     error = 0;
-       int     part, pmask;
+       int     part, pmask, s;
        struct cfdata *cf;
        struct raid_softc *rs;
        RF_Config_t *k_cfg, *u_cfg;
@@ -1026,6 +1026,7 @@
        case DIOCWLABEL:
        case DIOCAWEDGE:
        case DIOCDWEDGE:
+       case DIOCSSTRATEGY:
                if ((flag & FWRITE) == 0)
                        return (EBADF);
        }
@@ -1078,6 +1079,8 @@
        case RAIDFRAME_PARITYMAP_GET_DISABLE:
        case RAIDFRAME_PARITYMAP_SET_DISABLE:
        case RAIDFRAME_PARITYMAP_SET_PARAMS:
+       case DIOCGSTRATEGY:
+       case DIOCSSTRATEGY:
                if ((rs->sc_flags & RAIDF_INITED) == 0)
                        return (ENXIO);
        }
@@ -1840,6 +1843,45 @@
                    (struct dkwedge_list *)data, l);
        case DIOCCACHESYNC:
                return rf_sync_component_caches(raidPtr);
+
+       case DIOCGSTRATEGY:
+           {
+               struct disk_strategy *dks = (void *)data;
+
+               s = splbio();
+               strlcpy(dks->dks_name, bufq_getstrategyname(rs->buf_queue),
+                   sizeof(dks->dks_name));
+               splx(s);
+               dks->dks_paramlen = 0;
+
+               return 0;
+           }
+       
+       case DIOCSSTRATEGY:
+           {
+               struct disk_strategy *dks = (void *)data;
+               struct bufq_state *new;
+               struct bufq_state *old;
+
+               if (dks->dks_param != NULL) {
+                       return EINVAL;
+               }
+               dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */
+               error = bufq_alloc(&new, dks->dks_name,
+                   BUFQ_EXACT|BUFQ_SORT_RAWBLOCK);
+               if (error) {
+                       return error;
+               }
+               s = splbio();
+               old = rs->buf_queue;
+               bufq_move(new, old);
+               rs->buf_queue = new;
+               splx(s);
+               bufq_free(old);
+
+               return 0;
+           }
+
        default:
                retcode = ENOTTY;
        }


[Patch against -current as of 8/8/2012]

Index: rf_netbsdkintf.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_netbsdkintf.c,v
retrieving revision 1.297
diff -u -r1.297 rf_netbsdkintf.c
--- rf_netbsdkintf.c    7 Apr 2012 01:39:38 -0000       1.297
+++ rf_netbsdkintf.c    9 Aug 2012 05:20:18 -0000
@@ -1,4 +1,4 @@
-/*     $NetBSD$        */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.297 2012/04/07 01:39:38 christos Exp $    
*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD$");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.297 2012/04/07 01:39:38 
christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -983,7 +983,7 @@
 {
        int     unit = raidunit(dev);
        int     error = 0;
-       int     part, pmask;
+       int     part, pmask, s;
        cfdata_t cf;
        struct raid_softc *rs;
        RF_Config_t *k_cfg, *u_cfg;
@@ -1036,6 +1036,7 @@
        case DIOCWLABEL:
        case DIOCAWEDGE:
        case DIOCDWEDGE:
+       case DIOCSSTRATEGY:
                if ((flag & FWRITE) == 0)
                        return (EBADF);
        }
@@ -1088,6 +1089,8 @@
        case RAIDFRAME_PARITYMAP_GET_DISABLE:
        case RAIDFRAME_PARITYMAP_SET_DISABLE:
        case RAIDFRAME_PARITYMAP_SET_PARAMS:
+       case DIOCGSTRATEGY:
+       case DIOCSSTRATEGY:
                if ((rs->sc_flags & RAIDF_INITED) == 0)
                        return (ENXIO);
        }
@@ -1861,6 +1864,45 @@
                    (struct dkwedge_list *)data, l);
        case DIOCCACHESYNC:
                return rf_sync_component_caches(raidPtr);
+
+       case DIOCGSTRATEGY:
+           {
+               struct disk_strategy *dks = (void *)data;
+
+               s = splbio();
+               strlcpy(dks->dks_name, bufq_getstrategyname(rs->buf_queue),
+                   sizeof(dks->dks_name));
+               splx(s);
+               dks->dks_paramlen = 0;
+
+               return 0;
+           }
+       
+       case DIOCSSTRATEGY:
+           {
+               struct disk_strategy *dks = (void *)data;
+               struct bufq_state *new;
+               struct bufq_state *old;
+
+               if (dks->dks_param != NULL) {
+                       return EINVAL;
+               }
+               dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */
+               error = bufq_alloc(&new, dks->dks_name,
+                   BUFQ_EXACT|BUFQ_SORT_RAWBLOCK);
+               if (error) {
+                       return error;
+               }
+               s = splbio();
+               old = rs->buf_queue;
+               bufq_move(new, old);
+               rs->buf_queue = new;
+               splx(s);
+               bufq_free(old);
+
+               return 0;
+           }
+
        default:
                retcode = ENOTTY;
        }


Home | Main Index | Thread Index | Old Index