From eugen@grosbein.pp.ru  Sun Sep 18 21:21:58 2011
Return-Path: <eugen@grosbein.pp.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 69FFF106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 18 Sep 2011 21:21:58 +0000 (UTC)
	(envelope-from eugen@grosbein.pp.ru)
Received: from grosbein.pp.ru (grosbein.pp.ru [89.189.172.146])
	by mx1.freebsd.org (Postfix) with ESMTP id C9FA38FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 18 Sep 2011 21:21:57 +0000 (UTC)
Received: from grosbein.pp.ru (localhost [127.0.0.1])
	by grosbein.pp.ru (8.14.5/8.14.5) with ESMTP id p8IKkfBM004610;
	Mon, 19 Sep 2011 03:46:41 +0700 (NOVST)
	(envelope-from eugen@grosbein.pp.ru)
Received: (from eugen@localhost)
	by grosbein.pp.ru (8.14.5/8.14.5/Submit) id p8IKkfGx004609;
	Mon, 19 Sep 2011 03:46:41 +0700 (NOVST)
	(envelope-from eugen)
Message-Id: <201109182046.p8IKkfGx004609@grosbein.pp.ru>
Date: Mon, 19 Sep 2011 03:46:41 +0700 (NOVST)
From: Eugene Grosbein <eugen@grosbein.pp.ru>
Reply-To: Eugene Grosbein <eugen@grosbein.pp.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: mav@freebsd.org
Subject: Cannot change gmirror provider priority in RELENG_7 (r196879)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         160811
>Category:       kern
>Synopsis:       [geom] Cannot change gmirror provider priority in RELENG_7 (r196879)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-geom
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 18 21:30:10 UTC 2011
>Closed-Date:    Thu Sep 29 18:43:45 UTC 2011
>Last-Modified:  Thu Sep 29 18:50:09 UTC 2011
>Originator:     Eugene Grosbein
>Release:        FreeBSD 7
>Organization:
RDTC JSC
>Environment:
System: FreeBSD 7.2-RELEASE

>Description:
	When first of gmirror's drives in some old server started dying
	(read errors, SMART offline read test fails) I was forced
	to prepare new hardware to replace this 2-drive PATA system.

	But, it appears this is not possible to make final dumps
	of its file systems as dump(8) hangs the whole box while reading
	failing drive.

	I was going to switch gmirror to 'prefer' balance algorithm
	to disable reads from first drive. I could not achieve this
	as /sbin/gmirror in RELENG_7 does not allow to change provider
	priorities (both drives priorities are zeroes).

>How-To-Repeat:
	gmirror(8) manual page shows no support for "gmirror -p"
	as in 8.x and 9.x branches due to missed SVN r196879 merge.
>Fix:

	Please perform merge of r196879 to RELENG_7.
	I've did it manually, it applies cleanly and works just fine,
	I was able to make second drive more preferable with this change.

Eugene Grosbein
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-geom 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Sep 19 05:25:21 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160811 
State-Changed-From-To: open->closed 
State-Changed-By: mav 
State-Changed-When: Thu Sep 29 18:43:25 UTC 2011 
State-Changed-Why:  
Merged. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160811 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/160811: commit references a PR
Date: Thu, 29 Sep 2011 18:43:05 +0000 (UTC)

 Author: mav
 Date: Thu Sep 29 18:42:44 2011
 New Revision: 225881
 URL: http://svn.freebsd.org/changeset/base/225881
 
 Log:
   MFC r196879:
   Add support for changing providers priority.
   
   PR:		kern/160811
 
 Modified:
   stable/7/sbin/geom/class/mirror/geom_mirror.c
   stable/7/sbin/geom/class/mirror/gmirror.8
   stable/7/sys/geom/mirror/g_mirror_ctl.c
 Directory Properties:
   stable/7/sbin/geom/   (props changed)
   stable/7/sbin/geom/class/journal/   (props changed)
   stable/7/sbin/geom/class/label/   (props changed)
   stable/7/sbin/geom/class/part/   (props changed)
   stable/7/sbin/geom/class/stripe/   (props changed)
   stable/7/sbin/geom/misc/   (props changed)
   stable/7/sys/   (props changed)
   stable/7/sys/cddl/contrib/opensolaris/   (props changed)
   stable/7/sys/contrib/dev/acpica/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
 
 Modified: stable/7/sbin/geom/class/mirror/geom_mirror.c
 ==============================================================================
 --- stable/7/sbin/geom/class/mirror/geom_mirror.c	Thu Sep 29 18:12:40 2011	(r225880)
 +++ stable/7/sbin/geom/class/mirror/geom_mirror.c	Thu Sep 29 18:42:44 2011	(r225881)
 @@ -1,5 +1,5 @@
  /*-
 - * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
 + * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@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[] = "load", 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/7/sbin/geom/class/mirror/gmirror.8
 ==============================================================================
 --- stable/7/sbin/geom/class/mirror/gmirror.8	Thu Sep 29 18:12:40 2011	(r225880)
 +++ stable/7/sbin/geom/class/mirror/gmirror.8	Thu Sep 29 18:42:44 2011	(r225881)
 @@ -1,4 +1,4 @@
 -.\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
 +.\" Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@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/7/sys/geom/mirror/g_mirror_ctl.c
 ==============================================================================
 --- stable/7/sys/geom/mirror/g_mirror_ctl.c	Thu Sep 29 18:12:40 2011	(r225880)
 +++ stable/7/sys/geom/mirror/g_mirror_ctl.c	Thu Sep 29 18:42:44 2011	(r225881)
 @@ -1,5 +1,5 @@
  /*-
 - * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
 + * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@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;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
