From tim@robbins.dropbear.id.au  Wed Apr  2 03:55:15 2003
Return-Path: <tim@robbins.dropbear.id.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 589CB37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  2 Apr 2003 03:55:15 -0800 (PST)
Received: from smtp01.syd.iprimus.net.au (smtp01.syd.iprimus.net.au [210.50.30.52])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BB38843F93
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  2 Apr 2003 03:55:14 -0800 (PST)
	(envelope-from tim@robbins.dropbear.id.au)
Received: from dilbert.robbins.dropbear.id.au (210.50.201.91) by smtp01.syd.iprimus.net.au (7.0.012)
        id 3E8A144A000296F5 for FreeBSD-gnats-submit@freebsd.org; Wed, 2 Apr 2003 21:55:12 +1000
Received: by dilbert.robbins.dropbear.id.au (Postfix, from userid 1000)
	id 0C1C4B4CD; Wed,  2 Apr 2003 21:54:53 +1000 (EST)
Message-Id: <20030402115453.0C1C4B4CD@dilbert.robbins.dropbear.id.au>
Date: Wed,  2 Apr 2003 21:54:53 +1000 (EST)
From: Tim Robbins <tim@robbins.dropbear.id.au>
Reply-To: Tim Robbins <tim@robbins.dropbear.id.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: raidframe does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50541
>Category:       kern
>Synopsis:       raidframe does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    scottl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 02 04:00:26 PST 2003
>Closed-Date:    Tue Jun 29 15:25:57 GMT 2004
>Last-Modified:  Tue Jun 29 15:25:57 GMT 2004
>Originator:     Tim Robbins
>Release:        FreeBSD 5.0-CURRENT
>Organization:
The FreeBSD Project
>Environment:
System: FreeBSD 5.0-CURRENT dated April 2, 2003

>Description:

RAIDframe does not work in FreeBSD 5.0-CURRENT: attempts to initialise an
array cause a kernel panic.

Mounting root from ufs:/dev/ad0s1a
RAIDFRAME: protectedSectors is 64
Waiting for DAG engine to start
Warning: p_fd fields not set
panic: lockmgr: thread 0xc0a08390, not exclusive lock holder 0xc1239ab0 unlocking
panic: from debugger
Uptime: 5m42s

This is easily reproduceable, and seems to be occurring when raidlookup() calls
vn_open().


In addition to this problem, there seems to be a misunderstanding between
threads and processes in rf_threadstuff.h, specifically RF_CREATE_THREAD.
It tries to return a struct proc * from kthread_create() into the caller's
struct thread *. A patch is attached for this problem, but not for the
lockmgr panic.

>How-To-Repeat:

cat <<EOF >mirror
START array
# numRow numCol numSpare
1 2 0

START disks
/dev/md0c
/dev/md1c

START layout
# sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level_0
128 1 1 1

START queue
fifo 100
EOF

mdconfig -a -t swap -s 32m
disklabel -r -w md0 auto
mdconfig -a -t swap -s 32m
disklabel -r -w md1 auto
raidctl -C mirror

>Fix:

Fix for thread/proc mixup:

Index: rf_threadstuff.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/raidframe/rf_threadstuff.h,v
retrieving revision 1.2
diff -u -r1.2 rf_threadstuff.h
--- rf_threadstuff.h	20 Mar 2003 21:17:39 -0000	1.2
+++ rf_threadstuff.h	2 Apr 2003 07:41:41 -0000
@@ -125,9 +125,21 @@
 	kthread_exit(ret)
 #elif defined(__FreeBSD__)
 #if __FreeBSD_version > 500005
+static __inline int
+rf_create_thread(struct thread **_handle, void (*_func)(void *), void *_arg,
+   const char *_name)
+{
+	struct proc *p;
+	int ret;
+	
+	ret = kthread_create(_func, _arg, &p, 0, 4, _name);
+	if (ret == 0)
+		*_handle = FIRST_THREAD_IN_PROC(p);
+	return (ret);
+}
 #define RF_CREATE_THREAD(_handle_, _func_, _arg_, _name_) \
-	kthread_create((void (*)(void *))(_func_), (void *)(_arg_), \
-	    (struct proc **)&(_handle_), 0, 4, _name_)
+	rf_create_thread(&(_handle_), (void (*)(void *))(_func_), _arg_, \
+	    _name_)
 #define RF_THREAD_EXIT(ret)	\
 	kthread_exit(ret)
 #else
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->scottl 
Responsible-Changed-By: tjr 
Responsible-Changed-When: Tue Apr 8 03:22:50 PDT 2003 
Responsible-Changed-Why:  
scottl has been working on raidframe. 

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

From: Pawel Malachowski <pawmal-posting@freebsd.lublin.pl>
To: "Tim J. Robbins" <tjr@FreeBSD.org>
Cc: FreeBSD-gnats-submit@freebsd.org, scottl@FreeBSD.org
Subject: Re: kern/50541: raidframe does not work
Date: Wed, 7 Apr 2004 00:18:34 +0200

 On Tue, Apr 08, 2003 at 03:23:31AM -0700, Tim J. Robbins wrote:
 
 > Synopsis: raidframe does not work
 > 
 > Responsible-Changed-From-To: freebsd-bugs->scottl
 > Responsible-Changed-By: tjr
 > Responsible-Changed-When: Tue Apr 8 03:22:50 PDT 2003
 > Responsible-Changed-Why: 
 > scottl has been working on raidframe.
 
 Since RAIDFrame was removed, this PR is probably no longer significant.
 
 
 -- 
 Pawe Maachowski
State-Changed-From-To: open->closed 
State-Changed-By: scottl 
State-Changed-When: Tue Jun 29 15:25:09 GMT 2004 
State-Changed-Why:  
Closing this PR 

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