NetBSD Problem Report #51641

From martin@duskware.de  Mon Nov 21 18:31:12 2016
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 2CEEB7A281
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 21 Nov 2016 18:31:12 +0000 (UTC)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: locking error in scsipi
X-Send-Pr-Version: 3.95

>Number:         51641
>Category:       kern
>Synopsis:       locking error in scsipi
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 21 18:35:00 +0000 2016
>Closed-Date:    Thu Nov 24 11:17:25 +0000 2016
>Last-Modified:  Thu Nov 24 11:17:25 +0000 2016
>Originator:     Martin Husemann
>Release:        NetBSD 7.99.42
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD thirdstage.duskware.de 7.99.42 NetBSD 7.99.42 (MODULAR) #566: Mon Nov 21 19:20:57 CET 2016 martin@thirdstage.duskware.de:/usr/src/sys/arch/sparc64/compile/MODULAR sparc64
Architecture: sparc64
Machine: sparc64
>Description:

With a LOCKDEBUG kernel I get assertion failures locking against myself.
The following patch, suggested by Nick Hudson, seems to fix it. Not sure
if other functions called from the event thread need similar treatment.

Index: scsipi_base.c
===================================================================
RCS file: /cvsroot/src/sys/dev/scsipi/scsipi_base.c,v
retrieving revision 1.167
diff -u -p -r1.167 scsipi_base.c
--- scsipi_base.c	20 Nov 2016 15:37:19 -0000	1.167
+++ scsipi_base.c	21 Nov 2016 18:27:03 -0000
@@ -2277,7 +2277,8 @@ scsipi_async_event_max_openings(struct s

 	/* XXX This could really suck with a large LUN space. */
 	for (; minlun <= maxlun; minlun++) {
-		periph = scsipi_lookup_periph(chan, mo->mo_target, minlun);
+		periph = scsipi_lookup_periph_locked(chan, mo->mo_target,
+		    minlun);
 		if (periph == NULL)
 			continue;



>How-To-Repeat:
Boot a scsi system and use it. Without LOCKDEBUG it will hang hard easily,
with LOCKDEBUG a locking error in scsipi_lookup_periph will show up.

>Fix:
s/a

>Release-Note:

>Audit-Trail:
From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51641 CVS commit: src/sys/dev/scsipi
Date: Mon, 21 Nov 2016 21:03:22 +0000

 Module Name:	src
 Committed By:	mlelstv
 Date:		Mon Nov 21 21:03:22 UTC 2016

 Modified Files:
 	src/sys/dev/scsipi: scsipi_base.c

 Log Message:
 Lock is already taken when handling async events, don't lock again
 in scsipi_lookup_periph.

 Fixes PR kern/51641.


 To generate a diff of this commit:
 cvs rdiff -u -r1.167 -r1.168 src/sys/dev/scsipi/scsipi_base.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Thu, 24 Nov 2016 11:17:25 +0000
State-Changed-Why:
sounds like it was fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.