From lev@onlyone.friendlyhosting.spb.ru  Thu Sep  8 15:07:16 2011
Return-Path: <lev@onlyone.friendlyhosting.spb.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 517CC106567A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  8 Sep 2011 15:07:16 +0000 (UTC)
	(envelope-from lev@onlyone.friendlyhosting.spb.ru)
Received: from onlyone.friendlyhosting.spb.ru (onlyone.friendlyhosting.spb.ru [IPv6:2a01:4f8:131:60a2::2])
	by mx1.freebsd.org (Postfix) with ESMTP id F2EF58FC18
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  8 Sep 2011 15:07:15 +0000 (UTC)
Received: by onlyone.friendlyhosting.spb.ru (Postfix, from userid 1000)
	id C5CA74AC60; Thu,  8 Sep 2011 19:07:14 +0400 (MSD)
Message-Id: <20110908150714.C5CA74AC60@onlyone.friendlyhosting.spb.ru>
Date: Thu,  8 Sep 2011 19:07:14 +0400 (MSD)
From: Lev Serebryakov <lev@FreeBSD.org>
Reply-To: Lev Serebryakov <lev@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [geom][patch] Allow to insert new component to geom_raid3 without specifying number.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         160562
>Category:       kern
>Synopsis:       [geom][patch] Allow to insert new component to geom_raid3 without specifying number.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-geom
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 08 15:10:07 UTC 2011
>Closed-Date:    Tue Jan 29 17:55:12 UTC 2013
>Last-Modified:  Tue Jan 29 18:00:01 UTC 2013
>Originator:     Lev Serebryakov <lev@FreeBSD.org>
>Release:        FreeBSD 9.0-BETA2 i386
>Organization:
>Environment:
System: FreeBSD vmware-9-32.home.serebryakov.spb.ru 9.0-BETA2 FreeBSD 9.0-BETA2 #1: Wed Sep 7 22:08:28 MSK 2011 lev@vmware-9-32.home.serebryakov.spb.ru:/usr/obj/usr/src/sys/VMWARE i386


>Description:
  Now "geom_raid3" requires "-n <number>" argument for "insert" command, which insert new component instead of removed (or failed) one.
  It is not convient in most cases (one lost component).
  This patch allows not to specify component number. In such case new component is added instead of first missed component.

>How-To-Repeat:

  Try to add new component to geom_raid3 without "-n" argument.
  
>Fix:
Index: sbin/geom/class/raid3/graid3.8
===================================================================
--- sbin/geom/class/raid3/graid3.8	(revision 225448)
+++ sbin/geom/class/raid3/graid3.8	(working copy)
@@ -53,7 +53,7 @@
 .Nm
 .Cm insert
 .Op Fl hv
-.Fl n Ar number
+.Op Fl n Ar number
 .Ar name
 .Ar prov
 .Nm
@@ -171,6 +171,8 @@
 removed previously with the
 .Cm remove
 command or if one component is missing and will not be connected again.
+If no number is given, new component will beaaded instead of first missed
+component.
 .Pp
 Additional options include:
 .Bl -tag -width ".Fl h"
Index: sbin/geom/class/raid3/geom_raid3.c
===================================================================
--- sbin/geom/class/raid3/geom_raid3.c	(revision 225448)
+++ sbin/geom/class/raid3/geom_raid3.c	(working copy)
@@ -76,7 +76,7 @@
 	{ "insert", G_FLAG_VERBOSE, NULL,
 	    {
 		{ 'h', "hardcode", NULL, G_TYPE_BOOL },
-		{ 'n', "number", NULL, G_TYPE_NUMBER },
+		{ 'n', "number", G_VAL_OPTIONAL, G_TYPE_NUMBER },
 		G_OPT_SENTINEL
 	    },
 	    "[-hv] <-n number> name prov"
Index: sys/geom/raid3/g_raid3_ctl.c
===================================================================
--- sys/geom/raid3/g_raid3_ctl.c	(revision 225448)
+++ sys/geom/raid3/g_raid3_ctl.c	(working copy)
@@ -404,7 +404,7 @@
 	u_char *sector;
 	off_t compsize;
 	intmax_t *no;
-	int *hardcode, *nargs, error;
+	int *hardcode, *nargs, error, autono;
 
 	nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
 	if (nargs == NULL) {
@@ -425,11 +425,10 @@
 		gctl_error(req, "No 'arg%u' argument.", 1);
 		return;
 	}
-	no = gctl_get_paraml(req, "number", sizeof(*no));
-	if (no == NULL) {
-		gctl_error(req, "No '%s' argument.", "no");
-		return;
-	}
+	if (gctl_get_param(req, "number", NULL) != NULL)
+		no = gctl_get_paraml(req, "number", sizeof(*no));
+	else
+		no = NULL;
 	if (strncmp(name, "/dev/", 5) == 0)
 		name += 5;
 	g_topology_lock();
@@ -465,17 +464,30 @@
 		gctl_error(req, "No such device: %s.", name);
 		goto end;
 	}
-	if (*no >= sc->sc_ndisks) {
-		sx_xunlock(&sc->sc_lock);
-		gctl_error(req, "Invalid component number.");
-		goto end;
+	if (no != NULL) {
+		if (*no >= sc->sc_ndisks) {
+			sx_xunlock(&sc->sc_lock);
+			gctl_error(req, "Invalid component number.");
+			goto end;
+		}
+		disk = &sc->sc_disks[*no];
+		if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
+			sx_xunlock(&sc->sc_lock);
+			gctl_error(req, "Component %jd is already connected.", *no);
+			goto end;
+		}
+	} else {
+		disk = NULL;
+		for (autono = 0; autono < sc->sc_ndisks && disk == NULL; autono++)
+			if (sc->sc_disks[autono].d_state == G_RAID3_DISK_STATE_NODISK)
+				disk = &sc->sc_disks[autono];
+		if (disk == NULL) {
+			sx_xunlock(&sc->sc_lock);
+			gctl_error(req, "No unconnected components.");
+			goto end;
+		}
+				
 	}
-	disk = &sc->sc_disks[*no];
-	if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
-		sx_xunlock(&sc->sc_lock);
-		gctl_error(req, "Component %jd is already connected.", *no);
-		goto end;
-	}
 	if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) {
 		sx_xunlock(&sc->sc_lock);
 		gctl_error(req,
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-geom 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Sep 9 23:57:31 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/160562: commit references a PR
Date: Tue, 15 Jan 2013 10:06:43 +0000 (UTC)

 Author: mav
 Date: Tue Jan 15 10:06:35 2013
 New Revision: 245456
 URL: http://svnweb.freebsd.org/changeset/base/245456
 
 Log:
   Allow to insert new component to geom_raid3 without specifying number.
   
   PR:		kern/160562
   MFC after:	2 weeks
 
 Modified:
   head/sbin/geom/class/raid3/geom_raid3.c
   head/sbin/geom/class/raid3/graid3.8
   head/sys/geom/raid3/g_raid3_ctl.c
 
 Modified: head/sbin/geom/class/raid3/geom_raid3.c
 ==============================================================================
 --- head/sbin/geom/class/raid3/geom_raid3.c	Tue Jan 15 09:56:20 2013	(r245455)
 +++ head/sbin/geom/class/raid3/geom_raid3.c	Tue Jan 15 10:06:35 2013	(r245456)
 @@ -76,7 +76,7 @@ struct g_command class_commands[] = {
  	{ "insert", G_FLAG_VERBOSE, NULL,
  	    {
  		{ 'h', "hardcode", NULL, G_TYPE_BOOL },
 -		{ 'n', "number", NULL, G_TYPE_NUMBER },
 +		{ 'n', "number", G_VAL_OPTIONAL, G_TYPE_NUMBER },
  		G_OPT_SENTINEL
  	    },
  	    "[-hv] <-n number> name prov"
 
 Modified: head/sbin/geom/class/raid3/graid3.8
 ==============================================================================
 --- head/sbin/geom/class/raid3/graid3.8	Tue Jan 15 09:56:20 2013	(r245455)
 +++ head/sbin/geom/class/raid3/graid3.8	Tue Jan 15 10:06:35 2013	(r245456)
 @@ -24,7 +24,7 @@
  .\"
  .\" $FreeBSD$
  .\"
 -.Dd January 5, 2010
 +.Dd January 15, 2012
  .Dt GRAID3 8
  .Os
  .Sh NAME
 @@ -53,7 +53,7 @@
  .Nm
  .Cm insert
  .Op Fl hv
 -.Fl n Ar number
 +.Op Fl n Ar number
  .Ar name
  .Ar prov
  .Nm
 @@ -171,6 +171,8 @@ Add the given component to the existing 
  removed previously with the
  .Cm remove
  command or if one component is missing and will not be connected again.
 +If no number is given, new component will be added instead of first missed
 +component.
  .Pp
  Additional options include:
  .Bl -tag -width ".Fl h"
 
 Modified: head/sys/geom/raid3/g_raid3_ctl.c
 ==============================================================================
 --- head/sys/geom/raid3/g_raid3_ctl.c	Tue Jan 15 09:56:20 2013	(r245455)
 +++ head/sys/geom/raid3/g_raid3_ctl.c	Tue Jan 15 10:06:35 2013	(r245456)
 @@ -404,7 +404,7 @@ g_raid3_ctl_insert(struct gctl_req *req,
  	u_char *sector;
  	off_t compsize;
  	intmax_t *no;
 -	int *hardcode, *nargs, error;
 +	int *hardcode, *nargs, error, autono;
  
  	nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
  	if (nargs == NULL) {
 @@ -425,11 +425,10 @@ g_raid3_ctl_insert(struct gctl_req *req,
  		gctl_error(req, "No 'arg%u' argument.", 1);
  		return;
  	}
 -	no = gctl_get_paraml(req, "number", sizeof(*no));
 -	if (no == NULL) {
 -		gctl_error(req, "No '%s' argument.", "no");
 -		return;
 -	}
 +	if (gctl_get_param(req, "number", NULL) != NULL)
 +		no = gctl_get_paraml(req, "number", sizeof(*no));
 +	else
 +		no = NULL;
  	if (strncmp(name, "/dev/", 5) == 0)
  		name += 5;
  	g_topology_lock();
 @@ -465,16 +464,30 @@ g_raid3_ctl_insert(struct gctl_req *req,
  		gctl_error(req, "No such device: %s.", name);
  		goto end;
  	}
 -	if (*no >= sc->sc_ndisks) {
 -		sx_xunlock(&sc->sc_lock);
 -		gctl_error(req, "Invalid component number.");
 -		goto end;
 -	}
 -	disk = &sc->sc_disks[*no];
 -	if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
 -		sx_xunlock(&sc->sc_lock);
 -		gctl_error(req, "Component %jd is already connected.", *no);
 -		goto end;
 +	if (no != NULL) {
 +		if (*no < 0 || *no >= sc->sc_ndisks) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "Invalid component number.");
 +			goto end;
 +		}
 +		disk = &sc->sc_disks[*no];
 +		if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "Component %jd is already connected.",
 +			    *no);
 +			goto end;
 +		}
 +	} else {
 +		disk = NULL;
 +		for (autono = 0; autono < sc->sc_ndisks && disk == NULL; autono++)
 +			if (sc->sc_disks[autono].d_state ==
 +			    G_RAID3_DISK_STATE_NODISK)
 +				disk = &sc->sc_disks[autono];
 +		if (disk == NULL) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "No disconnected components.");
 +			goto end;
 +		}
  	}
  	if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) {
  		sx_xunlock(&sc->sc_lock);
 _______________________________________________
 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"
 
State-Changed-From-To: open->closed 
State-Changed-By: mav 
State-Changed-When: Tue Jan 29 17:54:42 UTC 2013 
State-Changed-Why:  
Patch committed and merged to 8/9-STABLE. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/160562: commit references a PR
Date: Tue, 29 Jan 2013 17:51:30 +0000 (UTC)

 Author: mav
 Date: Tue Jan 29 17:51:12 2013
 New Revision: 246081
 URL: http://svnweb.freebsd.org/changeset/base/246081
 
 Log:
   MFC r245456:
   Allow to insert new component to geom_raid3 without specifying number.
   
   PR:		kern/160562
 
 Modified:
   stable/9/sbin/geom/class/raid3/geom_raid3.c
   stable/9/sbin/geom/class/raid3/graid3.8
   stable/9/sys/geom/raid3/g_raid3_ctl.c
 Directory Properties:
   stable/9/sbin/geom/class/raid3/   (props changed)
   stable/9/sys/   (props changed)
 
 Modified: stable/9/sbin/geom/class/raid3/geom_raid3.c
 ==============================================================================
 --- stable/9/sbin/geom/class/raid3/geom_raid3.c	Tue Jan 29 17:47:07 2013	(r246080)
 +++ stable/9/sbin/geom/class/raid3/geom_raid3.c	Tue Jan 29 17:51:12 2013	(r246081)
 @@ -76,7 +76,7 @@ struct g_command class_commands[] = {
  	{ "insert", G_FLAG_VERBOSE, NULL,
  	    {
  		{ 'h', "hardcode", NULL, G_TYPE_BOOL },
 -		{ 'n', "number", NULL, G_TYPE_NUMBER },
 +		{ 'n', "number", G_VAL_OPTIONAL, G_TYPE_NUMBER },
  		G_OPT_SENTINEL
  	    },
  	    "[-hv] <-n number> name prov"
 
 Modified: stable/9/sbin/geom/class/raid3/graid3.8
 ==============================================================================
 --- stable/9/sbin/geom/class/raid3/graid3.8	Tue Jan 29 17:47:07 2013	(r246080)
 +++ stable/9/sbin/geom/class/raid3/graid3.8	Tue Jan 29 17:51:12 2013	(r246081)
 @@ -24,7 +24,7 @@
  .\"
  .\" $FreeBSD$
  .\"
 -.Dd January 5, 2010
 +.Dd January 15, 2012
  .Dt GRAID3 8
  .Os
  .Sh NAME
 @@ -53,7 +53,7 @@
  .Nm
  .Cm insert
  .Op Fl hv
 -.Fl n Ar number
 +.Op Fl n Ar number
  .Ar name
  .Ar prov
  .Nm
 @@ -171,6 +171,8 @@ Add the given component to the existing 
  removed previously with the
  .Cm remove
  command or if one component is missing and will not be connected again.
 +If no number is given, new component will be added instead of first missed
 +component.
  .Pp
  Additional options include:
  .Bl -tag -width ".Fl h"
 
 Modified: stable/9/sys/geom/raid3/g_raid3_ctl.c
 ==============================================================================
 --- stable/9/sys/geom/raid3/g_raid3_ctl.c	Tue Jan 29 17:47:07 2013	(r246080)
 +++ stable/9/sys/geom/raid3/g_raid3_ctl.c	Tue Jan 29 17:51:12 2013	(r246081)
 @@ -404,7 +404,7 @@ g_raid3_ctl_insert(struct gctl_req *req,
  	u_char *sector;
  	off_t compsize;
  	intmax_t *no;
 -	int *hardcode, *nargs, error;
 +	int *hardcode, *nargs, error, autono;
  
  	nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
  	if (nargs == NULL) {
 @@ -425,11 +425,10 @@ g_raid3_ctl_insert(struct gctl_req *req,
  		gctl_error(req, "No 'arg%u' argument.", 1);
  		return;
  	}
 -	no = gctl_get_paraml(req, "number", sizeof(*no));
 -	if (no == NULL) {
 -		gctl_error(req, "No '%s' argument.", "no");
 -		return;
 -	}
 +	if (gctl_get_param(req, "number", NULL) != NULL)
 +		no = gctl_get_paraml(req, "number", sizeof(*no));
 +	else
 +		no = NULL;
  	if (strncmp(name, "/dev/", 5) == 0)
  		name += 5;
  	g_topology_lock();
 @@ -465,16 +464,30 @@ g_raid3_ctl_insert(struct gctl_req *req,
  		gctl_error(req, "No such device: %s.", name);
  		goto end;
  	}
 -	if (*no >= sc->sc_ndisks) {
 -		sx_xunlock(&sc->sc_lock);
 -		gctl_error(req, "Invalid component number.");
 -		goto end;
 -	}
 -	disk = &sc->sc_disks[*no];
 -	if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
 -		sx_xunlock(&sc->sc_lock);
 -		gctl_error(req, "Component %jd is already connected.", *no);
 -		goto end;
 +	if (no != NULL) {
 +		if (*no < 0 || *no >= sc->sc_ndisks) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "Invalid component number.");
 +			goto end;
 +		}
 +		disk = &sc->sc_disks[*no];
 +		if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "Component %jd is already connected.",
 +			    *no);
 +			goto end;
 +		}
 +	} else {
 +		disk = NULL;
 +		for (autono = 0; autono < sc->sc_ndisks && disk == NULL; autono++)
 +			if (sc->sc_disks[autono].d_state ==
 +			    G_RAID3_DISK_STATE_NODISK)
 +				disk = &sc->sc_disks[autono];
 +		if (disk == NULL) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "No disconnected components.");
 +			goto end;
 +		}
  	}
  	if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) {
  		sx_xunlock(&sc->sc_lock);
 _______________________________________________
 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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/160562: commit references a PR
Date: Tue, 29 Jan 2013 17:54:39 +0000 (UTC)

 Author: mav
 Date: Tue Jan 29 17:54:26 2013
 New Revision: 246082
 URL: http://svnweb.freebsd.org/changeset/base/246082
 
 Log:
   MFC r245456:
   Allow to insert new component to geom_raid3 without specifying number.
   
   PR:		kern/160562
 
 Modified:
   stable/8/sbin/geom/class/raid3/geom_raid3.c
   stable/8/sbin/geom/class/raid3/graid3.8
   stable/8/sys/geom/raid3/g_raid3_ctl.c
 Directory Properties:
   stable/8/sbin/geom/class/raid3/   (props changed)
   stable/8/sys/   (props changed)
   stable/8/sys/geom/   (props changed)
 
 Modified: stable/8/sbin/geom/class/raid3/geom_raid3.c
 ==============================================================================
 --- stable/8/sbin/geom/class/raid3/geom_raid3.c	Tue Jan 29 17:51:12 2013	(r246081)
 +++ stable/8/sbin/geom/class/raid3/geom_raid3.c	Tue Jan 29 17:54:26 2013	(r246082)
 @@ -76,7 +76,7 @@ struct g_command class_commands[] = {
  	{ "insert", G_FLAG_VERBOSE, NULL,
  	    {
  		{ 'h', "hardcode", NULL, G_TYPE_BOOL },
 -		{ 'n', "number", NULL, G_TYPE_NUMBER },
 +		{ 'n', "number", G_VAL_OPTIONAL, G_TYPE_NUMBER },
  		G_OPT_SENTINEL
  	    },
  	    NULL, "[-hv] <-n number> name prov"
 
 Modified: stable/8/sbin/geom/class/raid3/graid3.8
 ==============================================================================
 --- stable/8/sbin/geom/class/raid3/graid3.8	Tue Jan 29 17:51:12 2013	(r246081)
 +++ stable/8/sbin/geom/class/raid3/graid3.8	Tue Jan 29 17:54:26 2013	(r246082)
 @@ -24,7 +24,7 @@
  .\"
  .\" $FreeBSD$
  .\"
 -.Dd November 1, 2006
 +.Dd January 15, 2012
  .Dt GRAID3 8
  .Os
  .Sh NAME
 @@ -52,7 +52,7 @@
  .Nm
  .Cm insert
  .Op Fl hv
 -.Fl n Ar number
 +.Op Fl n Ar number
  .Ar name
  .Ar prov
  .Nm
 @@ -164,6 +164,8 @@ Add the given component to the existing 
  removed previously with the
  .Cm remove
  command or if one component is missing and will not be connected again.
 +If no number is given, new component will be added instead of first missed
 +component.
  .Pp
  Additional options include:
  .Bl -tag -width ".Fl h"
 
 Modified: stable/8/sys/geom/raid3/g_raid3_ctl.c
 ==============================================================================
 --- stable/8/sys/geom/raid3/g_raid3_ctl.c	Tue Jan 29 17:51:12 2013	(r246081)
 +++ stable/8/sys/geom/raid3/g_raid3_ctl.c	Tue Jan 29 17:54:26 2013	(r246082)
 @@ -404,7 +404,7 @@ g_raid3_ctl_insert(struct gctl_req *req,
  	u_char *sector;
  	off_t compsize;
  	intmax_t *no;
 -	int *hardcode, *nargs, error;
 +	int *hardcode, *nargs, error, autono;
  
  	nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
  	if (nargs == NULL) {
 @@ -425,11 +425,10 @@ g_raid3_ctl_insert(struct gctl_req *req,
  		gctl_error(req, "No 'arg%u' argument.", 1);
  		return;
  	}
 -	no = gctl_get_paraml(req, "number", sizeof(*no));
 -	if (no == NULL) {
 -		gctl_error(req, "No '%s' argument.", "no");
 -		return;
 -	}
 +	if (gctl_get_param(req, "number", NULL) != NULL)
 +		no = gctl_get_paraml(req, "number", sizeof(*no));
 +	else
 +		no = NULL;
  	if (strncmp(name, "/dev/", 5) == 0)
  		name += 5;
  	g_topology_lock();
 @@ -465,16 +464,30 @@ g_raid3_ctl_insert(struct gctl_req *req,
  		gctl_error(req, "No such device: %s.", name);
  		goto end;
  	}
 -	if (*no >= sc->sc_ndisks) {
 -		sx_xunlock(&sc->sc_lock);
 -		gctl_error(req, "Invalid component number.");
 -		goto end;
 -	}
 -	disk = &sc->sc_disks[*no];
 -	if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
 -		sx_xunlock(&sc->sc_lock);
 -		gctl_error(req, "Component %jd is already connected.", *no);
 -		goto end;
 +	if (no != NULL) {
 +		if (*no < 0 || *no >= sc->sc_ndisks) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "Invalid component number.");
 +			goto end;
 +		}
 +		disk = &sc->sc_disks[*no];
 +		if (disk->d_state != G_RAID3_DISK_STATE_NODISK) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "Component %jd is already connected.",
 +			    *no);
 +			goto end;
 +		}
 +	} else {
 +		disk = NULL;
 +		for (autono = 0; autono < sc->sc_ndisks && disk == NULL; autono++)
 +			if (sc->sc_disks[autono].d_state ==
 +			    G_RAID3_DISK_STATE_NODISK)
 +				disk = &sc->sc_disks[autono];
 +		if (disk == NULL) {
 +			sx_xunlock(&sc->sc_lock);
 +			gctl_error(req, "No disconnected components.");
 +			goto end;
 +		}
  	}
  	if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) {
  		sx_xunlock(&sc->sc_lock);
 _______________________________________________
 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:
