From owner-svn-src-all@freebsd.org Mon Mar 12 03:17:05 2018 Return-Path: Delivered-To: svn-src-all@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 8AED3F4353E; Mon, 12 Mar 2018 03:17:05 +0000 (UTC) (envelope-from dexuan.bsd@gmail.com) Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (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 ED3568C0B6; Mon, 12 Mar 2018 03:17:04 +0000 (UTC) (envelope-from dexuan.bsd@gmail.com) Received: by mail-lf0-x242.google.com with SMTP id l191-v6so20965872lfe.1; Sun, 11 Mar 2018 20:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=m0BriEnHIwwJO/s4ChZE2/2xCTAZBxX8RGTJsQkG95c=; b=or6/gWqB4Q66nGp73qdkVaOWCAqxu7Wwltn2aek66yTht6cwIU4sT/Nc2CSz8ViUKz a7veL0JVAv3CN6svfJpiBninzTXpGTOUAbup2cUYKIqtIV9lPJ/WB8aCELanDX3jMwPM MMOcN9f2sF2KSTTRhgf2pSKyNTLA+lqhY56+Nd3hqyIyZnHvd5ewTeeGvXax7LnJObzL Z9FIEeFWgVSJhsrwL3r2NUqAzjZPmKyIGYtKyYVNGbtZd9b6HilYiYFfgkRHtulARSxx Mf9RdqX/w7HuDqaBNdFLPrAI0edmC7aPVyToCkh+rieiErS7emdku5ALs0mpscQY/vAe g5JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=m0BriEnHIwwJO/s4ChZE2/2xCTAZBxX8RGTJsQkG95c=; b=dY1Nfcop+9Vl5LG6LHNGSbYNLZsEKhGMj+4kehk6+J9VyVsO5Hd5QP0qXqrOfSL+O7 Q+dS3dV7z2bRvaqfYLQ4Ss7/amNtroULsh6kVgDZqJjm1ScB3a81GUO4evCev4ewPtTy +fVuuxwIcVcy5FmfvAaTOKvfgnzaDxzYjFzRB2pSULTOHlRfVMVi51Id+LOOrdhXSJWw I/2Hz+HfWITvbcRzB+PXKm5pSaI7nyBcob3Jlrsy+Y5xt+iERt3vFB+qHQcEkbYVFP6b NDC+j9ezC8B+oZlZzMFztte5e5+lXi+ds3MnJrFpeE9Ubuj2W585WvXqMnY0cRoLVm45 vaTg== X-Gm-Message-State: AElRT7FWi0bPjZ01ubfQrxdRZg8HGFFfpPHSrfCzHRM3SZoq23kkX0Ht dPji3nCxEYxIJ/9h1Hln1VHZEZGDvn4EuPAo8p8= X-Google-Smtp-Source: AG47ELuor/GJ1i4vGj+7YcyAwuvfCwGm4AV7M6BXkzGIfqydizIsB+eSiE1Vdc/Hn/+SzxG9GA9a0cU3Bp47bmkw9jk= X-Received: by 10.46.89.213 with SMTP id g82mr4153059ljf.105.1520824622575; Sun, 11 Mar 2018 20:17:02 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:d8e8:0:0:0:0:0 with HTTP; Sun, 11 Mar 2018 20:17:02 -0700 (PDT) In-Reply-To: <201801291807.w0TI7EVD092154@repo.freebsd.org> References: <201801291807.w0TI7EVD092154@repo.freebsd.org> From: Dexuan-BSD Cui Date: Sun, 11 Mar 2018 20:17:02 -0700 Message-ID: Subject: Re: svn commit: r328554 - head/sys/cam/scsi To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, Dexuan Cui Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2018 03:17:05 -0000 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 >