From owner-svn-src-head@freebsd.org Mon Mar 12 16:44:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED44BF2A599 for ; Mon, 12 Mar 2018 16:44:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x236.google.com (mail-io0-x236.google.com [IPv6:2607:f8b0:4001:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6FD3484E2F for ; Mon, 12 Mar 2018 16:44:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x236.google.com with SMTP id v10so5562299iob.6 for ; Mon, 12 Mar 2018 09:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=2M8kfs6Tm7DmbyzHLgnC2NF7gw/2jo9LhR0j5ZcrncQ=; b=JR5DDFJrGnG14QG1O3wk4jINJgpWMc+uOzjstcNTtp1zDR6gBXNsvFF4/rouDIua1A V+v5AgZUsNPsOBMOyIDSAI4qgHvKtUIFKJ/8Ia5EoHxQSPmgqR0NiN8U8AL8Lv+0gtVg uJBSmr1Ie4W4CJZ52luIcmVqZPIbsYSghxAguObyuLVMC4/GwpS7BNCoAwNGvneIfIyJ bi/h7UVUwGg4IZ2A06ZejKIHheuUXlmySgGitF0Mo7w/dEoOSvEEP5UWGkHVs/4xaJ1j QI7WMv+mTtQp0nX4qCYpQWwj+3tkcWuW78i+xP7NV7UGTRQZmyGis5i0EdcXp2kCNUQ8 /Gew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=2M8kfs6Tm7DmbyzHLgnC2NF7gw/2jo9LhR0j5ZcrncQ=; b=La+tEoM4pg+dBJ5sICTuspr21K4qXgoPHi9WEy8EQSh7N/ADDD7UIEgIYrUWuHjlBC 506ilU5F4AWwnMgKtdz47GE9sRqcTHjcD9C7mr62oaIWI7W9tcJsKJZC0M85VCvxLfFr JLO2HvLST1SBBfYEFIu32LzYHGAgK4yMWnaKrPOptBXUvYCEIsdc5HUnbyx+iMb7CK+f ViO6edIcP3rP5hxd0pgHY4HkI/RIfDq9wJ3v5xSB7J++o9mPzbkEeUNYqAsARVFUmRXZ m5/qC2M46ALTIJ1ZlA4PRDo7MFdtH+roC0hl+Tm5feLc9YEBiN9KqzR5kxhTUAJflz3+ GxMA== X-Gm-Message-State: AElRT7FXbETmG5RW2sDriRFtAnyPebPl1tl7F6qndcN1gkmU88hQXPOT kncFzG1cSeq2yUpCwdaiadlFbQ7hpZWo720eYKC4/g== X-Google-Smtp-Source: AG47ELuM7QVveg66mAiI0RJFmu+F7xrbxvu+ol7XZ9yafB3UfKRvicSG0OeaYAVa2FcxqWWo7LMj4MLh/OwygrIrG50= X-Received: by 10.107.180.83 with SMTP id d80mr9319650iof.168.1520873085568; Mon, 12 Mar 2018 09:44:45 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.203.196 with HTTP; Mon, 12 Mar 2018 09:44:44 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: References: <201801291807.w0TI7EVD092154@repo.freebsd.org> From: Warner Losh Date: Mon, 12 Mar 2018 10:44:44 -0600 X-Google-Sender-Auth: AjwHSHmz-e7MEFJN_AQrTux88zE Message-ID: Subject: Re: svn commit: r328554 - head/sys/cam/scsi To: Dexuan-BSD Cui Cc: Warner Losh , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Dexuan Cui Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2018 16:44:47 -0000 I think this is a good idea to MFC. We've had no reports of it causing issues. There's more extensive locking changes / tweaks needed for da that just went in that likely should also be MFC'd. Warner On Sun, Mar 11, 2018 at 9:17 PM, Dexuan-BSD Cui wrote: > Hi imp and all, > I think this patch is very important, because it can fix a panic I > noticed recently when I try to hot-remove a SCSI disk from a VM > running on Azure/Hyper-V. > > The panic is almost 100% reproducible with stable/11, but not in the > latest CURRENT code, so finally I identified this fix in the CURRENT > branch. > > Can you please MFC this patch to 11 and 10? > It looks there is a major difference in the CAM code between 11/10 > and the CURRENT code, and we may have to MFC more related patches. If > this is difficult, I hope at least we can provide a minimal re-written > version of the patch to 11 and 10? > > Looking forward to your insight! > > Thanks, > -- Dexuan > > > On Mon, Jan 29, 2018 at 10:07 AM, Warner Losh wrote: > > Author: imp > > Date: Mon Jan 29 18:07:14 2018 > > New Revision: 328554 > > URL: https://svnweb.freebsd.org/changeset/base/328554 > > > > Log: > > Do the book-keeping on release before we release the reference. The > > periph was going away on final release, and then returning and we > > started dancing in free memory. > > > > Sponsored by: Netflix > > > > Modified: > > head/sys/cam/scsi/scsi_da.c > > > > Modified: head/sys/cam/scsi/scsi_da.c > > ============================================================ > ================== > > --- head/sys/cam/scsi/scsi_da.c Mon Jan 29 17:32:30 2018 (r328553) > > +++ head/sys/cam/scsi/scsi_da.c Mon Jan 29 18:07:14 2018 (r328554) > > @@ -1549,12 +1549,12 @@ da_periph_unhold(struct cam_periph *periph, > da_ref_tok > > struct da_softc *softc = periph->softc; > > > > token_sanity(token); > > - cam_periph_unhold(periph); > > DA_PERIPH_PRINT(periph, "Unholding device %s (%d)\n", > > da_ref_text[token], token); > > cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1); > > if (cnt != 1) > > panic("Unholding %d with cnt = %d", token, cnt); > > + cam_periph_unhold(periph); > > } > > > > static inline int > > @@ -1583,12 +1583,12 @@ da_periph_release(struct cam_periph *periph, > da_ref_to > > struct da_softc *softc = periph->softc; > > > > token_sanity(token); > > - cam_periph_release(periph); > > DA_PERIPH_PRINT(periph, "releasing device %s (%d)\n", > > da_ref_text[token], token); > > cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1); > > if (cnt != 1) > > panic("Releasing %d with cnt = %d", token, cnt); > > + cam_periph_release(periph); > > } > > > > static inline void > > @@ -1598,12 +1598,12 @@ da_periph_release_locked(struct cam_periph > *periph, da > > struct da_softc *softc = periph->softc; > > > > token_sanity(token); > > - cam_periph_release_locked(periph); > > DA_PERIPH_PRINT(periph, "releasing device (locked) %s (%d)\n", > > da_ref_text[token], token); > > cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1); > > if (cnt != 1) > > panic("Unholding %d with cnt = %d", token, cnt); > > + cam_periph_release_locked(periph); > > } > > > > #define cam_periph_hold POISON > > >