Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe Add a SET_LAST_UNIT ioctl.



details:   https://anonhg.NetBSD.org/src/rev/7e33b94f21b4
branches:  trunk
changeset: 812866:7e33b94f21b4
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 06 17:40:50 2016 +0000

description:
Add a SET_LAST_UNIT ioctl.

diffstat:

 sys/dev/raidframe/raidframeio.h    |   3 +-
 sys/dev/raidframe/rf_netbsdkintf.c |  39 +++++++++++++++++++++++++++----------
 2 files changed, 30 insertions(+), 12 deletions(-)

diffs (104 lines):

diff -r 0df75c4db73b -r 7e33b94f21b4 sys/dev/raidframe/raidframeio.h
--- a/sys/dev/raidframe/raidframeio.h   Wed Jan 06 15:34:54 2016 +0000
+++ b/sys/dev/raidframe/raidframeio.h   Wed Jan 06 17:40:50 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raidframeio.h,v 1.6 2009/11/17 18:54:26 jld Exp $ */
+/*     $NetBSD: raidframeio.h,v 1.7 2016/01/06 17:40:50 christos Exp $ */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -131,5 +131,6 @@
 #define RAIDFRAME_PARITYMAP_GET_DISABLE _IOR('r', 38, int)
 #define RAIDFRAME_PARITYMAP_SET_DISABLE _IOW('r', 39, int)
 #define RAIDFRAME_PARITYMAP_SET_PARAMS _IOW('r', 40, struct rf_pmparams)
+#define RAIDFRAME_SET_LAST_UNIT _IOW('r', 41, int)
 
 #endif                         /* !_RF_RAIDFRAMEIO_H_ */
diff -r 0df75c4db73b -r 7e33b94f21b4 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Wed Jan 06 15:34:54 2016 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Wed Jan 06 17:40:50 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.340 2016/01/05 18:44:34 christos Exp $    */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.341 2016/01/06 17:40:50 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: rf_netbsdkintf.c,v 1.340 2016/01/05 18:44:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.341 2016/01/06 17:40:50 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -259,13 +259,14 @@
        LIST_ENTRY(raid_softc) sc_link;
 };
 /* sc_flags */
-#define RAIDF_INITED   0x01    /* unit has been initialized */
-#define RAIDF_WLABEL   0x02    /* label area is writable */
-#define RAIDF_LABELLING        0x04    /* unit is currently being labelled */
-#define RAIDF_SHUTDOWN 0x08    /* unit is being shutdown */
-#define RAIDF_DETACH   0x10    /* detach after final close */
-#define RAIDF_WANTED   0x40    /* someone is waiting to obtain a lock */
-#define RAIDF_LOCKED   0x80    /* unit is locked */
+#define RAIDF_INITED           0x001   /* unit has been initialized */
+#define RAIDF_WLABEL           0x002   /* label area is writable */
+#define RAIDF_LABELLING                0x004   /* unit is currently being labelled */
+#define RAIDF_SHUTDOWN         0x008   /* unit is being shutdown */
+#define RAIDF_DETACH           0x010   /* detach after final close */
+#define RAIDF_WANTED           0x040   /* someone is waiting to obtain a lock */
+#define RAIDF_LOCKED           0x080   /* unit is locked */
+#define RAIDF_UNIT_CHANGED     0x100   /* unit is being changed */
 
 #define        raidunit(x)     DISKUNIT(x)
 #define        raidsoftc(dev)  (((struct raid_softc *)device_private(dev))->sc_r.softc)
@@ -1676,6 +1677,19 @@
                                  sizeof(RF_ProgressInfo_t));
                return (retcode);
 
+       case RAIDFRAME_SET_LAST_UNIT:
+               for (column = 0; column < raidPtr->numCol; column++)
+                       if (raidPtr->Disks[column].status != rf_ds_optimal)
+                               return EBUSY;
+
+               for (column = 0; column < raidPtr->numCol; column++) {
+                       clabel = raidget_component_label(raidPtr, column);
+                       clabel->last_unit = *(int *)data;
+                       raidflush_component_label(raidPtr, column);
+               }
+               rs->sc_cflags |= RAIDF_UNIT_CHANGED;
+               return 0;
+
                /* the sparetable daemon calls this to wait for the kernel to
                 * need a spare table. this ioctl does not return until a
                 * spare table is needed. XXX -- calling mpsleep here in the
@@ -2491,6 +2505,7 @@
        int c;
        int j;
        int scol;
+       struct raid_softc *rs = raidPtr->softc;
 
        scol = -1;
 
@@ -2506,7 +2521,8 @@
                        clabel->status = rf_ds_optimal;
                        
                        /* note what unit we are configured as */
-                       clabel->last_unit = raidPtr->raidid;
+                       if ((rs->sc_cflags & RAIDF_UNIT_CHANGED) == 0)
+                               clabel->last_unit = raidPtr->raidid;
 
                        raidflush_component_label(raidPtr, c);
                        if (final == RF_FINAL_COMPONENT_UPDATE) {
@@ -2546,7 +2562,8 @@
 
                        clabel->column = scol;
                        clabel->status = rf_ds_optimal;
-                       clabel->last_unit = raidPtr->raidid;
+                       if ((rs->sc_cflags & RAIDF_UNIT_CHANGED) == 0)
+                               clabel->last_unit = raidPtr->raidid;
 
                        raidflush_component_label(raidPtr, sparecol);
                        if (final == RF_FINAL_COMPONENT_UPDATE) {



Home | Main Index | Thread Index | Old Index