From marck@woozle.rinet.ru  Sun Apr 25 05:52:42 2004
Return-Path: <marck@woozle.rinet.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 360AF16A4CE; Sun, 25 Apr 2004 05:52:42 -0700 (PDT)
Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 4B45843D54; Sun, 25 Apr 2004 05:52:41 -0700 (PDT)
	(envelope-from marck@woozle.rinet.ru)
Received: from woozle.rinet.ru (localhost [127.0.0.1])
	by woozle.rinet.ru (8.12.11/8.12.11) with ESMTP id i3PCqeS8051948;
	Sun, 25 Apr 2004 16:52:40 +0400 (MSD)
	(envelope-from marck@woozle.rinet.ru)
Received: (from marck@localhost)
	by woozle.rinet.ru (8.12.11/8.12.11/Submit) id i3PCqeSg051947;
	Sun, 25 Apr 2004 16:52:40 +0400 (MSD)
	(envelope-from marck)
Message-Id: <200404251252.i3PCqeSg051947@woozle.rinet.ru>
Date: Sun, 25 Apr 2004 16:52:40 +0400 (MSD)
From: Dmitry Morozovsky <marck@rinet.ru>
Reply-To: Dmitry Morozovsky <marck@rinet.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: le@freebsd.org, grog@freebsd.org
Subject: [patch] vinum: bug in detached subdisk config
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         65956
>Category:       kern
>Synopsis:       [patch] vinum: bug in detached subdisk config
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    le
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 25 06:00:40 PDT 2004
>Closed-Date:    Mon Apr 26 13:33:39 PDT 2004
>Last-Modified:  Mon Apr 26 13:33:39 PDT 2004
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4-STABLE i386
>Organization:
Cronyx Plus LLC (RiNet ISP)
>Environment:
System: FreeBSD 4-STABLE 


>Description:

When a subdisk has been created without plex attached to, or when detaching, vinum
writes incorrect line in on-disk config, so after stop-start cycle (or after reboot)
it cannot interpret it.

>How-To-Repeat:

[Assume ad0s1h is freshly created or cleared by `vinum resetconfig']

# echo drive test device /dev/ad0s1h >/tmp/vinum0
# kldload vinum
vinum: loaded
# vinum create /tmp/vinum0
vinum: drive test is up
1 drives:
D test                  State: up       Device /dev/ad0s1h      Avail: 32515/32516 MB (100%)

0 volumes:
0 plexes:
0 subdisks:
# echo sd name test.p0.s0 len 1g drive test >/tmp/vinum1
# vinum create /tmp/vinum1
1 drives:
D test                  State: up       Device /dev/ad0s1h      Avail: 31491/32516 MB (96%)

0 volumes:
0 plexes:
1 subdisks:
S test.p0.s0            State: empty    (detached)      Size:       1024 MB
# vinum printconfig
# Vinum configuration of , saved at Mon Apr 26 00:20:29 2004
drive test device /dev/ad0s1h
sd name test.p0.s0 drive test detached len 2097152s driveoffset 265s
# vinum dumpconfig
Drive test:     Device /dev/ad0s1h
                Created on  at Mon Apr 26 00:19:35 2004
                Config last updated Mon Apr 26 00:20:24 2004
                Size:      34095612416 bytes (32516 MB)
sd name test.p0.s0 drive test plex  len 2097152s driveoffset 265s state empty detached 

Drive /dev/ad0s1h: 31 GB (34095612416 bytes)
# vinum stop
vinum: unloaded
vinum unloaded
# vinum start
vinum: loaded
vinum: reading configuration from /dev/ad0s1h
vinum: test.p0.s0: invalid keyword: 2097152s
Disabling configuration updates
vinum: No space for  on test
*** Warning: configuration updates are disabled. ***
*** Warning: configuration updates are disabled. ***


>Fix:
Move plexname to the end of config line, where 'detached' attribute resides fixes the problem.

Index: sys/dev/vinum/vinumio.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/vinum/vinumio.c,v
retrieving revision 1.52.2.7
diff -u -r1.52.2.7 vinumio.c
--- sys/dev/vinum/vinumio.c	9 Mar 2004 10:18:47 -0000	1.52.2.7
+++ sys/dev/vinum/vinumio.c	25 Apr 2004 12:43:12 -0000
@@ -559,10 +559,9 @@
 		drivename = "*invalid*";
 	    snprintf(s,
 		configend - s,
-		"sd name %s drive %s plex %s len %llus driveoffset %llus state %s",
+		"sd name %s drive %s len %llus driveoffset %llus state %s",
 		sd->name,
 		drivename,
-		vinum_conf.plex[sd->plexno].name,
 		(unsigned long long) sd->sectors,
 		(unsigned long long) sd->driveoffset,
 		sd_state(sd->state));
@@ -571,7 +570,8 @@
 	    if (sd->plexno >= 0)
 		snprintf(s,
 		    configend - s,
-		    " plexoffset %llds",
+		    " plex %s plexoffset %llds",
+		    vinum_conf.plex[sd->plexno].name,
 		    (long long) sd->plexoffset);
 	    else
 		snprintf(s, configend - s, " detached");
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->le 
Responsible-Changed-By: le 
Responsible-Changed-When: Mon Apr 26 01:21:58 PDT 2004 
Responsible-Changed-Why:  
I'll handle this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65956 
State-Changed-From-To: open->closed 
State-Changed-By: le 
State-Changed-When: Mon Apr 26 13:33:21 PDT 2004 
State-Changed-Why:  
Patch committed, thanks for your submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65956 
>Unformatted:
