From owner-svn-src-stable@freebsd.org Mon Mar 6 06:41:08 2017 Return-Path: Delivered-To: svn-src-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 10B07CF8C25; Mon, 6 Mar 2017 06:41:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1A3B116A; Mon, 6 Mar 2017 06:41:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v266f6Bi001017; Mon, 6 Mar 2017 06:41:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v266f6Bf001016; Mon, 6 Mar 2017 06:41:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703060641.v266f6Bf001016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 6 Mar 2017 06:41:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r314761 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Mar 2017 06:41:08 -0000 Author: mav Date: Mon Mar 6 06:41:06 2017 New Revision: 314761 URL: https://svnweb.freebsd.org/changeset/base/314761 Log: MFC r314387: Make ctl_queue_sense() not sleep. It may be called in non-sleepable frontend context. Modified: stable/10/sys/cam/ctl/ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Mon Mar 6 06:40:33 2017 (r314760) +++ stable/10/sys/cam/ctl/ctl.c Mon Mar 6 06:41:06 2017 (r314761) @@ -13142,21 +13142,15 @@ ctl_queue_sense(union ctl_io *io) initidx = ctl_get_initindex(&io->io_hdr.nexus); p = initidx / CTL_MAX_INIT_PER_PORT; - if ((ps = lun->pending_sense[p]) == NULL) { - mtx_unlock(&lun->lun_lock); - ps = malloc(sizeof(*ps) * CTL_MAX_INIT_PER_PORT, M_CTL, - M_WAITOK | M_ZERO); - mtx_lock(&lun->lun_lock); - if (lun->pending_sense[p] == NULL) { - lun->pending_sense[p] = ps; - } else { - free(ps, M_CTL); - ps = lun->pending_sense[p]; - } + if (lun->pending_sense[p] == NULL) { + lun->pending_sense[p] = malloc(sizeof(*ps) * CTL_MAX_INIT_PER_PORT, + M_CTL, M_NOWAIT | M_ZERO); + } + if ((ps = lun->pending_sense[p]) != NULL) { + ps += initidx % CTL_MAX_INIT_PER_PORT; + memset(ps, 0, sizeof(*ps)); + memcpy(ps, &io->scsiio.sense_data, io->scsiio.sense_len); } - ps += initidx % CTL_MAX_INIT_PER_PORT; - memset(ps, 0, sizeof(*ps)); - memcpy(ps, &io->scsiio.sense_data, io->scsiio.sense_len); mtx_unlock(&lun->lun_lock); bailout: