From owner-freebsd-stable@freebsd.org Sun Jan 24 19:51:00 2016 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AF217C90; Sun, 24 Jan 2016 19:51:00 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "alchemy.franken.de", Issuer "alchemy.franken.de" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 447332F1; Sun, 24 Jan 2016 19:50:59 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.15.2/8.15.2/ALCHEMY.FRANKEN.DE) with ESMTPS id u0OJoog2019255 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 24 Jan 2016 20:50:50 +0100 (CET) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.15.2/8.15.2/Submit) id u0OJoot0019254; Sun, 24 Jan 2016 20:50:50 +0100 (CET) (envelope-from marius) Date: Sun, 24 Jan 2016 20:50:50 +0100 From: Marius Strobl To: Andrea Venturoli Cc: freebsd-stable@freebsd.org, freebsd-questions@freebsd.org Subject: Re: Panic with sym on 10.2 Message-ID: <20160124195050.GA19171@alchemy.franken.de> References: <569E368F.4060802@netfence.it> <569E45D9.1050604@freebsd.org> <569E4ABB.9070903@netfence.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: <569E4ABB.9070903@netfence.it> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (alchemy.franken.de [0.0.0.0]); Sun, 24 Jan 2016 20:50:50 +0100 (CET) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2016 19:51:00 -0000 --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 19, 2016 at 03:39:55PM +0100, Andrea Venturoli wrote: > On 01/19/16 15:19, Matthew Seaman wrote: > > On 01/19/16 13:13, Andrea Venturoli wrote: > >> Two days ago I upgraded a (perfectly working) 9.3/i386 box to 10.2p10 > >> Since then I've had two panics with the following message: > >> > >> panic: assertion "lp->busy_itl==0&&lp->busy_itlq==0" failed: file > >> /usr/src/sys/dev/sym/sym_hipd.c > >> > >> Since the disk controller is involved, I do not get any core and I have > >> to press the reset button. > >> > >> Google showed up no results (I'm not using ZFS, btw) and Bugzilla didn't > >> help either. > >> These debugging assertions in sym_get_ccb() probably can just be replaced with graceful handling (see the attached patch). I'm unsure whether it's sufficient to tell the CAM stack to retry at a later point, though, and given I'm not hitting this problem I also can't test. Unlike SCSI-2, SCSI-3 generally allows to mix a single untagged command with tagged ones (the situation you are encountering), which FreeBSD apparently started doing somewhere between 9.3 and 10.2. However, permitting that would require a careful review of sym(4) and most likely larger changes. Marius --rwEMma7ioTxnRzrJ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="sym_get_ccb_nuke_debugging.diff" Index: sym_hipd.c =================================================================== --- sym_hipd.c (revision 294669) +++ sym_hipd.c (working copy) @@ -6296,14 +6296,13 @@ static ccb_p sym_get_ccb (hcb_p np, u_char tn, u_c goto out_free; } else { /* - * If we have been asked for a tagged command. + * If we have been asked for a tagged command, refuse + * to overlap with an existing untagged one. */ if (tag_order) { + if (lp->busy_itl != 0) + goto out_free; /* - * Debugging purpose. - */ - assert(lp->busy_itl == 0); - /* * Allocate resources for tags if not yet. */ if (!lp->cb_tags) { @@ -6335,22 +6334,17 @@ static ccb_p sym_get_ccb (hcb_p np, u_char tn, u_c * one, refuse to overlap this untagged one. */ else { + if (lp->busy_itlq != 0 || lp->busy_itl != 0) + goto out_free; /* - * Debugging purpose. - */ - assert(lp->busy_itl == 0 && lp->busy_itlq == 0); - /* * Count this nexus for this LUN. * Set up the CCB bus address for reselection. * Toggle reselect path to untagged. */ - if (++lp->busy_itl == 1) { - lp->head.itl_task_sa = cpu_to_scr(cp->ccb_ba); - lp->head.resel_sa = - cpu_to_scr(SCRIPTA_BA (np, resel_no_tag)); - } - else - goto out_free; + lp->busy_itl = 1; + lp->head.itl_task_sa = cpu_to_scr(cp->ccb_ba); + lp->head.resel_sa = + cpu_to_scr(SCRIPTA_BA (np, resel_no_tag)); } } /* @@ -6396,7 +6390,7 @@ static void sym_free_ccb(hcb_p np, ccb_p cp) */ if (lp) { /* - * If tagged, release the tag, set the relect path + * If tagged, release the tag, set the reselect path. */ if (cp->tag != NO_TAG) { /* @@ -6417,7 +6411,7 @@ static void sym_free_ccb(hcb_p np, ccb_p cp) * and uncount this CCB. */ lp->head.itl_task_sa = cpu_to_scr(np->bad_itl_ba); - --lp->busy_itl; + lp->busy_itl = 0; } /* * If no JOB active, make the LUN reselect path invalid. --rwEMma7ioTxnRzrJ--