Module Name: src Committed By: martin Date: Fri Jul 14 15:39:33 UTC 2017
Modified Files: src/sbin/raidctl [netbsd-7]: raidctl.8 raidctl.c src/sys/dev/raidframe [netbsd-7]: raidframeio.h rf_netbsdkintf.c Log Message: Pull up following revision(s) (requested by christos in ticket #1457): sbin/raidctl/raidctl.c: revision 1.64 sbin/raidctl/raidctl.8: revision 1.70 sys/dev/raidframe/rf_netbsdkintf.c: revision 1.341 sys/dev/raidframe/raidframeio.h: revision 1.7 Add a SET_LAST_UNIT ioctl. Access to the SET_LAST_UNIT ioctl. To generate a diff of this commit: cvs rdiff -u -r1.67.4.1 -r1.67.4.2 src/sbin/raidctl/raidctl.8 cvs rdiff -u -r1.57.4.3 -r1.57.4.4 src/sbin/raidctl/raidctl.c cvs rdiff -u -r1.6 -r1.6.38.1 src/sys/dev/raidframe/raidframeio.h cvs rdiff -u -r1.312.2.4 -r1.312.2.5 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/raidctl/raidctl.8 diff -u src/sbin/raidctl/raidctl.8:1.67.4.1 src/sbin/raidctl/raidctl.8:1.67.4.2 --- src/sbin/raidctl/raidctl.8:1.67.4.1 Sun Jul 5 20:22:34 2015 +++ src/sbin/raidctl/raidctl.8 Fri Jul 14 15:39:32 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: raidctl.8,v 1.67.4.1 2015/07/05 20:22:34 snj Exp $ +.\" $NetBSD: raidctl.8,v 1.67.4.2 2017/07/14 15:39:32 martin Exp $ .\" .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -53,7 +53,7 @@ .\" any improvements or extensions that they make and grant Carnegie the .\" rights to redistribute these changes. .\" -.Dd June 30, 2015 +.Dd January 6, 2016 .Dt RAIDCTL 8 .Os .Sh NAME @@ -125,6 +125,9 @@ .Nm .Op Fl v .Fl u Ar dev +.Nm +.Op Fl v +.Fl U Ar unit Ar dev .Sh DESCRIPTION .Nm is the user-land control program for @@ -318,6 +321,12 @@ achieved in each of these areas. Unconfigure the RAIDframe device. This does not remove any component labels or change any configuration settings (e.g. auto-configuration settings) for the RAID set. +.It Fl U Ar unit Ar dev +Set the +.Dv last_unit +field in all the raid components, so that the next time the raid +will be autoconfigured it uses that +.Ar unit . .It Fl v Be more verbose. For operations such as reconstructions, parity Index: src/sbin/raidctl/raidctl.c diff -u src/sbin/raidctl/raidctl.c:1.57.4.3 src/sbin/raidctl/raidctl.c:1.57.4.4 --- src/sbin/raidctl/raidctl.c:1.57.4.3 Sun Jul 5 20:20:10 2015 +++ src/sbin/raidctl/raidctl.c Fri Jul 14 15:39:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: raidctl.c,v 1.57.4.3 2015/07/05 20:20:10 snj Exp $ */ +/* $NetBSD: raidctl.c,v 1.57.4.4 2017/07/14 15:39:32 martin Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: raidctl.c,v 1.57.4.3 2015/07/05 20:20:10 snj Exp $"); +__RCSID("$NetBSD: raidctl.c,v 1.57.4.4 2017/07/14 15:39:32 martin Exp $"); #endif @@ -114,6 +114,7 @@ main(int argc,char *argv[]) int fd; int force; int openmode; + int last_unit; num_options = 0; action = 0; @@ -122,9 +123,10 @@ main(int argc,char *argv[]) do_rewrite = 0; serial_number = 0; force = 0; + last_unit = 0; openmode = O_RDWR; /* default to read/write */ - while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuv")) + while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuU:v")) != -1) switch(ch) { case 'a': @@ -244,6 +246,13 @@ main(int argc,char *argv[]) action = RAIDFRAME_SHUTDOWN; num_options++; break; + case 'U': + action = RAIDFRAME_SET_LAST_UNIT; + num_options++; + last_unit = atoi(optarg); + if (last_unit < 0) + errx(1, "Bad last unit %s", optarg); + break; case 'v': verbose = 1; /* Don't bump num_options, as '-v' is not @@ -342,6 +351,10 @@ main(int argc,char *argv[]) case RAIDFRAME_SHUTDOWN: do_ioctl(fd, RAIDFRAME_SHUTDOWN, NULL, "RAIDFRAME_SHUTDOWN"); break; + case RAIDFRAME_SET_LAST_UNIT: + do_ioctl(fd, RAIDFRAME_SET_LAST_UNIT, &last_unit, + "RAIDFRAME_SET_LAST_UNIT"); + break; default: break; } Index: src/sys/dev/raidframe/raidframeio.h diff -u src/sys/dev/raidframe/raidframeio.h:1.6 src/sys/dev/raidframe/raidframeio.h:1.6.38.1 --- src/sys/dev/raidframe/raidframeio.h:1.6 Tue Nov 17 18:54:26 2009 +++ src/sys/dev/raidframe/raidframeio.h Fri Jul 14 15:39:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: raidframeio.h,v 1.6 2009/11/17 18:54:26 jld Exp $ */ +/* $NetBSD: raidframeio.h,v 1.6.38.1 2017/07/14 15:39:32 martin 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_ */ Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.312.2.4 src/sys/dev/raidframe/rf_netbsdkintf.c:1.312.2.5 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.312.2.4 Mon Dec 22 02:19:32 2014 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Fri Jul 14 15:39:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.312.2.4 2014/12/22 02:19:32 msaitoh Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.312.2.5 2017/07/14 15:39:32 martin 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.312.2.4 2014/12/22 02:19:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.312.2.5 2017/07/14 15:39:32 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -251,6 +251,7 @@ struct raid_softc { #define RAIDF_SHUTDOWN 0x08 /* unit is being shutdown */ #define RAIDF_WANTED 0x40 /* someone is waiting to obtain a lock */ #define RAIDF_LOCKED 0x80 /* unit is locked */ +#define RAIDF_UNIT_CHANGED 0x100 /* unit is being changed */ #define raidunit(x) DISKUNIT(x) @@ -1761,6 +1762,19 @@ raidioctl(dev_t dev, u_long cmd, void *d 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 @@ -2849,6 +2863,7 @@ rf_update_component_labels(RF_Raid_t *ra int c; int j; int scol; + struct raid_softc *rs = raidPtr->softc; scol = -1; @@ -2864,7 +2879,8 @@ rf_update_component_labels(RF_Raid_t *ra 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) { @@ -2904,7 +2920,8 @@ rf_update_component_labels(RF_Raid_t *ra 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) {