svn commit: r200284 - in stable/8: . contrib/top lib/libusb
sbin/geom/class/mirror sys/geom/mirror
tools/regression/lib/msun tools/regression/usr.bin/pkill
tools/tools/ath/common tools/tools/termca...
Alexander Motin
mav at FreeBSD.org
Tue Dec 8 15:15:49 PST 2009
Author: mav
Date: Tue Dec 8 23:15:48 2009
New Revision: 200284
URL: http://svn.freebsd.org/changeset/base/200284
Log:
MFC r196879:
Add support for changing providers priority.
Modified:
stable/8/sbin/geom/class/mirror/geom_mirror.c
stable/8/sbin/geom/class/mirror/gmirror.8
stable/8/sys/geom/mirror/g_mirror_ctl.c
Directory Properties:
stable/8/ (props changed)
stable/8/ObsoleteFiles.inc (props changed)
stable/8/UPDATING (props changed)
stable/8/bin/csh/ (props changed)
stable/8/bin/ps/ (props changed)
stable/8/bin/sh/ (props changed)
stable/8/cddl/compat/opensolaris/ (props changed)
stable/8/cddl/contrib/opensolaris/ (props changed)
stable/8/cddl/lib/libnvpair/ (props changed)
stable/8/contrib/bind9/ (props changed)
stable/8/contrib/bzip2/ (props changed)
stable/8/contrib/cpio/ (props changed)
stable/8/contrib/csup/ (props changed)
stable/8/contrib/ee/ (props changed)
stable/8/contrib/file/ (props changed)
stable/8/contrib/gdb/ (props changed)
stable/8/contrib/gdtoa/ (props changed)
stable/8/contrib/less/ (props changed)
stable/8/contrib/libpcap/ (props changed)
stable/8/contrib/ncurses/ (props changed)
stable/8/contrib/netcat/ (props changed)
stable/8/contrib/ntp/ (props changed)
stable/8/contrib/openbsm/ (props changed)
stable/8/contrib/openpam/ (props changed)
stable/8/contrib/pf/ (props changed)
stable/8/contrib/sendmail/ (props changed)
stable/8/contrib/tcpdump/ (props changed)
stable/8/contrib/tcsh/ (props changed)
stable/8/contrib/top/ (props changed)
stable/8/contrib/top/install-sh (props changed)
stable/8/contrib/traceroute/ (props changed)
stable/8/contrib/wpa/ (props changed)
stable/8/crypto/openssh/ (props changed)
stable/8/crypto/openssl/ (props changed)
stable/8/etc/ (props changed)
stable/8/games/fortune/ (props changed)
stable/8/games/fortune/datfiles/ (props changed)
stable/8/gnu/usr.bin/groff/ (props changed)
stable/8/gnu/usr.bin/patch/ (props changed)
stable/8/include/ (props changed)
stable/8/kerberos5/lib/libgssapi_krb5/ (props changed)
stable/8/kerberos5/lib/libgssapi_spnego/ (props changed)
stable/8/lib/libarchive/ (props changed)
stable/8/lib/libc/ (props changed)
stable/8/lib/libc/stdtime/ (props changed)
stable/8/lib/libdevinfo/ (props changed)
stable/8/lib/libdisk/ (props changed)
stable/8/lib/libfetch/ (props changed)
stable/8/lib/libkvm/ (props changed)
stable/8/lib/libpmc/ (props changed)
stable/8/lib/libradius/ (props changed)
stable/8/lib/libstand/ (props changed)
stable/8/lib/libthr/ (props changed)
stable/8/lib/libusb/ (props changed)
stable/8/lib/libusb/usb.h (props changed)
stable/8/lib/libutil/ (props changed)
stable/8/libexec/rtld-elf/ (props changed)
stable/8/release/ (props changed)
stable/8/release/doc/ (props changed)
stable/8/release/doc/en_US.ISO8859-1/hardware/ (props changed)
stable/8/sbin/ (props changed)
stable/8/sbin/atacontrol/ (props changed)
stable/8/sbin/bsdlabel/ (props changed)
stable/8/sbin/camcontrol/ (props changed)
stable/8/sbin/ddb/ (props changed)
stable/8/sbin/dhclient/ (props changed)
stable/8/sbin/fsck/ (props changed)
stable/8/sbin/geom/ (props changed)
stable/8/sbin/ifconfig/ (props changed)
stable/8/sbin/ipfw/ (props changed)
stable/8/sbin/mksnap_ffs/ (props changed)
stable/8/sbin/mount/ (props changed)
stable/8/sbin/mount_cd9660/ (props changed)
stable/8/sbin/mount_nfs/ (props changed)
stable/8/sbin/umount/ (props changed)
stable/8/secure/usr.bin/bdes/ (props changed)
stable/8/share/man/man3/ (props changed)
stable/8/share/man/man4/ (props changed)
stable/8/share/man/man5/ (props changed)
stable/8/share/man/man7/ (props changed)
stable/8/share/man/man9/ (props changed)
stable/8/share/misc/ (props changed)
stable/8/share/timedef/ (props changed)
stable/8/share/zoneinfo/ (props changed)
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
stable/8/tools/kerneldoc/subsys/ (props changed)
stable/8/tools/regression/bin/sh/ (props changed)
stable/8/tools/regression/lib/libc/ (props changed)
stable/8/tools/regression/lib/msun/test-conj.t (props changed)
stable/8/tools/regression/poll/ (props changed)
stable/8/tools/regression/priv/ (props changed)
stable/8/tools/regression/usr.bin/pkill/pgrep-_g.t (props changed)
stable/8/tools/regression/usr.bin/pkill/pgrep-_s.t (props changed)
stable/8/tools/regression/usr.bin/pkill/pkill-_g.t (props changed)
stable/8/tools/tools/ath/common/dumpregs.h (props changed)
stable/8/tools/tools/ath/common/dumpregs_5210.c (props changed)
stable/8/tools/tools/ath/common/dumpregs_5211.c (props changed)
stable/8/tools/tools/ath/common/dumpregs_5212.c (props changed)
stable/8/tools/tools/ath/common/dumpregs_5416.c (props changed)
stable/8/tools/tools/termcap/termcap.pl (props changed)
stable/8/tools/tools/vimage/ (props changed)
stable/8/usr.bin/calendar/calendars/calendar.freebsd (props changed)
stable/8/usr.bin/csup/ (props changed)
stable/8/usr.bin/find/ (props changed)
stable/8/usr.bin/fstat/ (props changed)
stable/8/usr.bin/gcore/ (props changed)
stable/8/usr.bin/gzip/ (props changed)
stable/8/usr.bin/kdump/ (props changed)
stable/8/usr.bin/locale/ (props changed)
stable/8/usr.bin/look/ (props changed)
stable/8/usr.bin/netstat/ (props changed)
stable/8/usr.bin/perror/ (props changed)
stable/8/usr.bin/procstat/ (props changed)
stable/8/usr.bin/systat/ (props changed)
stable/8/usr.bin/vmstat/ (props changed)
stable/8/usr.bin/w/ (props changed)
stable/8/usr.bin/whois/ (props changed)
stable/8/usr.sbin/ (props changed)
stable/8/usr.sbin/acpi/ (props changed)
stable/8/usr.sbin/arp/ (props changed)
stable/8/usr.sbin/cdcontrol/ (props changed)
stable/8/usr.sbin/crashinfo/ (props changed)
stable/8/usr.sbin/dumpcis/cardinfo.h (props changed)
stable/8/usr.sbin/dumpcis/cis.h (props changed)
stable/8/usr.sbin/freebsd-update/ (props changed)
stable/8/usr.sbin/iostat/ (props changed)
stable/8/usr.sbin/jail/ (props changed)
stable/8/usr.sbin/jls/ (props changed)
stable/8/usr.sbin/lpr/ (props changed)
stable/8/usr.sbin/makefs/ffs/ffs_bswap.c (props changed)
stable/8/usr.sbin/makefs/ffs/ffs_subr.c (props changed)
stable/8/usr.sbin/makefs/ffs/ufs_bswap.h (props changed)
stable/8/usr.sbin/makefs/getid.c (props changed)
stable/8/usr.sbin/mfiutil/mfiutil.8 (props changed)
stable/8/usr.sbin/ndp/ (props changed)
stable/8/usr.sbin/ntp/ (props changed)
stable/8/usr.sbin/ppp/ (props changed)
stable/8/usr.sbin/pstat/ (props changed)
stable/8/usr.sbin/sysinstall/ (props changed)
stable/8/usr.sbin/traceroute6/ (props changed)
stable/8/usr.sbin/usbconfig/ (props changed)
stable/8/usr.sbin/wpa/ (props changed)
stable/8/usr.sbin/zic/ (props changed)
Modified: stable/8/sbin/geom/class/mirror/geom_mirror.c
==============================================================================
--- stable/8/sbin/geom/class/mirror/geom_mirror.c Tue Dec 8 22:49:03 2009 (r200283)
+++ stable/8/sbin/geom/class/mirror/geom_mirror.c Tue Dec 8 23:15:48 2009 (r200284)
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+ * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,13 +41,12 @@ __FBSDID("$FreeBSD$");
#include <core/geom.h>
#include <misc/subr.h>
-
uint32_t lib_version = G_LIB_VERSION;
uint32_t version = G_MIRROR_VERSION;
static char label_balance[] = "split", configure_balance[] = "none";
static intmax_t label_slice = 4096, configure_slice = -1;
-static intmax_t insert_priority = 0;
+static intmax_t insert_priority = 0, configure_priority = -1;
static void mirror_main(struct gctl_req *req, unsigned flags);
static void mirror_activate(struct gctl_req *req);
@@ -71,10 +70,12 @@ struct g_command class_commands[] = {
{ 'F', "nofailsync", NULL, G_TYPE_BOOL },
{ 'h', "hardcode", NULL, G_TYPE_BOOL },
{ 'n', "noautosync", NULL, G_TYPE_BOOL },
+ { 'p', "priority", &configure_priority, G_TYPE_NUMBER },
{ 's', "slice", &configure_slice, G_TYPE_NUMBER },
G_OPT_SENTINEL
},
- NULL, "[-adfFhnv] [-b balance] [-s slice] name"
+ NULL, "[-adfFhnv] [-b balance] [-s slice] name\n"
+ "[-v] -p priority name prov"
},
{ "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
"[-v] name prov ..."
Modified: stable/8/sbin/geom/class/mirror/gmirror.8
==============================================================================
--- stable/8/sbin/geom/class/mirror/gmirror.8 Tue Dec 8 22:49:03 2009 (r200283)
+++ stable/8/sbin/geom/class/mirror/gmirror.8 Tue Dec 8 23:15:48 2009 (r200284)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+.\" Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd at FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 1, 2006
+.Dd August 1, 2009
.Dt GMIRROR 8
.Os
.Sh NAME
@@ -49,6 +49,12 @@
.Op Fl s Ar slice
.Ar name
.Nm
+.Cm configure
+.Op Fl v
+.Fl p Ar priority
+.Ar name
+.Ar prov
+.Nm
.Cm rebuild
.Op Fl v
.Ar name
@@ -115,8 +121,8 @@ indicates an action to be performed:
.It Cm label
Create a mirror.
The order of components is important, because a component's priority is based on its position
-(starting from 0).
-The component with the biggest priority is used by the
+(starting from 0 to 255).
+The component with the biggest priority (the lowest number) is used by the
.Cm prefer
balance algorithm
and is also used as a master component when resynchronization is needed,
@@ -159,7 +165,7 @@ Clear metadata on the given providers.
Configure the given device.
.Pp
Additional options include:
-.Bl -tag -width ".Fl b Ar balance"
+.Bl -tag -width ".Fl p Ar priority"
.It Fl a
Turn on autosynchronization of stale components.
.It Fl b Ar balance
@@ -175,6 +181,9 @@ Assumes device is in consistent state.
Hardcode providers' names in metadata.
.It Fl n
Turn off autosynchronization of stale components.
+.It Fl p Ar priority
+Specifies priority for the given component
+.Ar prov .
.It Fl s Ar slice
Specifies slice size for
.Cm split
Modified: stable/8/sys/geom/mirror/g_mirror_ctl.c
==============================================================================
--- stable/8/sys/geom/mirror/g_mirror_ctl.c Tue Dec 8 22:49:03 2009 (r200283)
+++ stable/8/sys/geom/mirror/g_mirror_ctl.c Tue Dec 8 23:15:48 2009 (r200284)
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+ * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -93,19 +93,19 @@ g_mirror_ctl_configure(struct gctl_req *
{
struct g_mirror_softc *sc;
struct g_mirror_disk *disk;
- const char *name, *balancep;
- intmax_t *slicep;
+ const char *name, *balancep, *prov;
+ intmax_t *slicep, *priority;
uint32_t slice;
uint8_t balance;
int *autosync, *noautosync, *failsync, *nofailsync, *hardcode, *dynamic;
- int *nargs, do_sync = 0, dirty = 1;
+ int *nargs, do_sync = 0, dirty = 1, do_priority = 0;
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
if (nargs == NULL) {
gctl_error(req, "No '%s' argument.", "nargs");
return;
}
- if (*nargs != 1) {
+ if (*nargs != 1 && *nargs != 2) {
gctl_error(req, "Invalid number of arguments.");
return;
}
@@ -149,6 +149,29 @@ g_mirror_ctl_configure(struct gctl_req *
gctl_error(req, "No '%s' argument.", "dynamic");
return;
}
+ priority = gctl_get_paraml(req, "priority", sizeof(*priority));
+ if (priority == NULL) {
+ gctl_error(req, "No '%s' argument.", "priority");
+ return;
+ }
+ if (*priority < -1 || *priority > 255) {
+ gctl_error(req, "Priority range is 0 to 255, %jd given",
+ *priority);
+ return;
+ }
+ /*
+ * Since we have a priority, we also need a provider now.
+ * Note: be WARNS safe, by always assigning prov and only throw an
+ * error if *priority != -1.
+ */
+ prov = gctl_get_asciiparam(req, "arg1");
+ if (*priority > -1) {
+ if (prov == NULL) {
+ gctl_error(req, "Priority needs a disk name");
+ return;
+ }
+ do_priority = 1;
+ }
if (*autosync && *noautosync) {
gctl_error(req, "'%s' and '%s' specified.", "autosync",
"noautosync");
@@ -189,19 +212,32 @@ g_mirror_ctl_configure(struct gctl_req *
slice = sc->sc_slice;
else
slice = *slicep;
- if (g_mirror_ndisks(sc, -1) < sc->sc_ndisks) {
+ /* Enforce usage() of -p not allowing any other options. */
+ if (do_priority && (*autosync || *noautosync || *failsync ||
+ *nofailsync || *hardcode || *dynamic || *slicep != -1 ||
+ strcmp(balancep, "none") != 0)) {
sx_xunlock(&sc->sc_lock);
- gctl_error(req, "Not all disks connected. Try 'forget' command "
- "first.");
+ gctl_error(req, "only -p accepted when setting priority");
return;
}
if (sc->sc_balance == balance && sc->sc_slice == slice && !*autosync &&
!*noautosync && !*failsync && !*nofailsync && !*hardcode &&
- !*dynamic) {
+ !*dynamic && !do_priority) {
sx_xunlock(&sc->sc_lock);
gctl_error(req, "Nothing has changed.");
return;
}
+ if ((!do_priority && *nargs != 1) || (do_priority && *nargs != 2)) {
+ sx_xunlock(&sc->sc_lock);
+ gctl_error(req, "Invalid number of arguments.");
+ return;
+ }
+ if (g_mirror_ndisks(sc, -1) < sc->sc_ndisks) {
+ sx_xunlock(&sc->sc_lock);
+ gctl_error(req, "Not all disks connected. Try 'forget' command "
+ "first.");
+ return;
+ }
sc->sc_balance = balance;
sc->sc_slice = slice;
if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOAUTOSYNC) != 0) {
@@ -223,6 +259,23 @@ g_mirror_ctl_configure(struct gctl_req *
}
}
LIST_FOREACH(disk, &sc->sc_disks, d_next) {
+ /*
+ * Handle priority first, since we only need one disk, do one
+ * operation on it and then we're done. No need to check other
+ * flags, as usage doesn't allow it.
+ */
+ if (do_priority) {
+ if (strcmp(disk->d_name, prov) == 0) {
+ if (disk->d_priority == *priority)
+ gctl_error(req, "Nothing has changed.");
+ else {
+ disk->d_priority = *priority;
+ g_mirror_update_metadata(disk);
+ }
+ break;
+ }
+ continue;
+ }
if (do_sync) {
if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING)
disk->d_flags &= ~G_MIRROR_DISK_FLAG_FORCE_SYNC;
More information about the svn-src-stable
mailing list