From nobody Tue Jan 04 02:34:29 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B7F8B192AA04; Tue, 4 Jan 2022 02:34:48 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JScCD4nVJz3NV9; Tue, 4 Jan 2022 02:34:48 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-oi1-f179.google.com with SMTP id t23so57424233oiw.3; Mon, 03 Jan 2022 18:34:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+h9v+zvF7fYGeQ+4x7HSz90un6NoeDAGvubesYzsGao=; b=xMkE/Ogt+DJL9RC4rmwPC0sSkoyOkymHpGuVe/KQJfce90L7aAJpsZUvfaahAIBYAC jSN7TcVrQZC8IdNuqtO5g2Sxhy+KVfqBbI2LIMeOPogVnvqMKGYaIO5GT803JnYv7hD1 KXbXjawwTxWLUcqGSTsiEVMP4zZdbPTL21//X4n1a9jCk3Yp2IR46hLDKlw1u1ByYXLS qcyPDMTdHKTJ+E3ZmBMTPZHzI8KgdvNjY+XJWNnv0YXbeqL8FjakzfKHuGzJhK8aPAoG UccKHqos6wGX+IxyQHZL4wJP88/R+PZpfwe9EYrr0DnuJ108uhS1NowneEPkLG99OwbF pNPg== X-Gm-Message-State: AOAM530xghNoBe5WGc7E6OYgxW5hNScYhURFFRT8JyvzrqV7EbXPxmq1 oywS80R6iyoxbEhXaSwpykWwreVVzJww1PbdzKNZMhgh X-Google-Smtp-Source: ABdhPJxNdvvgcmIxo1mdlbTImxcvvhEUZOV+E6RdyY0LUHSJwRi2+OgUJtTv3AwXztioClLk4E8f5piD0EXlr4Y1szw= X-Received: by 2002:a05:6808:1642:: with SMTP id az2mr38104687oib.73.1641263681568; Mon, 03 Jan 2022 18:34:41 -0800 (PST) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202201040201.20421vmw040882@gitrepo.freebsd.org> In-Reply-To: <202201040201.20421vmw040882@gitrepo.freebsd.org> From: Alan Somers Date: Mon, 3 Jan 2022 19:34:29 -0700 Message-ID: Subject: Re: git: bb8441184bab - main - cam: don't lock while handling an AC_UNIT_ATTENTION To: Robert Wing Cc: src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4JScCD4nVJz3NV9 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, Jan 3, 2022 at 7:02 PM Robert Wing wrote: > > The branch main has been updated by rew: > > URL: https://cgit.FreeBSD.org/src/commit/?id=bb8441184bab60cd8a07c2b94bd6c4ae8b56ec25 > > commit bb8441184bab60cd8a07c2b94bd6c4ae8b56ec25 > Author: Robert Wing > AuthorDate: 2022-01-04 01:21:58 +0000 > Commit: Robert Wing > CommitDate: 2022-01-04 01:56:48 +0000 > > cam: don't lock while handling an AC_UNIT_ATTENTION > > Don't take the device_mtx lock in daasync() when handling an > AC_UNIT_ATTENTION. Instead, assert the lock is held before modifying the > periph's softc flags. > > The device_mtx lock is taken in xptdevicetraverse() before daasync() > is eventually called in xpt_async_bcast(). > > PR: 240917, 226510, 226578 > Reviewed by: imp > MFC after: 3 weeks > Differential Revision: https://reviews.freebsd.org/D27735 > --- > sys/cam/scsi/scsi_da.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c > index 243e86d18caa..df8791e4b23e 100644 > --- a/sys/cam/scsi/scsi_da.c > +++ b/sys/cam/scsi/scsi_da.c > @@ -2158,7 +2158,7 @@ daasync(void *callback_arg, u_int32_t code, > } > break; > } > - case AC_UNIT_ATTENTION: > + case AC_UNIT_ATTENTION: /* Called for this path: periph locked */ > { > union ccb *ccb; > int error_code, sense_key, asc, ascq; > @@ -2168,9 +2168,7 @@ daasync(void *callback_arg, u_int32_t code, > > /* > * Handle all UNIT ATTENTIONs except our own, as they will be > - * handled by daerror(). Since this comes from a different periph, > - * that periph's lock is held, not ours, so we have to take it ours > - * out to touch softc flags. > + * handled by daerror(). > */ > if (xpt_path_periph(ccb->ccb_h.path) != periph && > scsi_extract_sense_ccb(ccb, > @@ -2178,22 +2176,19 @@ daasync(void *callback_arg, u_int32_t code, > if (asc == 0x2A && ascq == 0x09) { > xpt_print(ccb->ccb_h.path, > "Capacity data has changed\n"); > - cam_periph_lock(periph); > + cam_periph_assert(periph, MA_OWNED); > softc->flags &= ~DA_FLAG_PROBED; > dareprobe(periph); > - cam_periph_unlock(periph); > } else if (asc == 0x28 && ascq == 0x00) { > - cam_periph_lock(periph); > + cam_periph_assert(periph, MA_OWNED); > softc->flags &= ~DA_FLAG_PROBED; > - cam_periph_unlock(periph); > disk_media_changed(softc->disk, M_NOWAIT); > } else if (asc == 0x3F && ascq == 0x03) { > xpt_print(ccb->ccb_h.path, > "INQUIRY data has changed\n"); > - cam_periph_lock(periph); > + cam_periph_assert(periph, MA_OWNED); > softc->flags &= ~DA_FLAG_PROBED; > dareprobe(periph); > - cam_periph_unlock(periph); > } > } > break; Thanks a lot!