From owner-svn-src-head@freebsd.org Thu Apr 30 21:08:59 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CECE52C8E9B; Thu, 30 Apr 2020 21:08:59 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49Cp0C4y02z44Nv; Thu, 30 Apr 2020 21:08:59 +0000 (UTC) (envelope-from imp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A515A25132; Thu, 30 Apr 2020 21:08:59 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03UL8xdc087665; Thu, 30 Apr 2020 21:08:59 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03UL8xks087664; Thu, 30 Apr 2020 21:08:59 GMT (envelope-from imp@FreeBSD.org) Message-Id: <202004302108.03UL8xks087664@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 30 Apr 2020 21:08:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360508 - head/sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam/nvme X-SVN-Commit-Revision: 360508 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Thu, 30 Apr 2020 21:08:59 -0000 Author: imp Date: Thu Apr 30 21:08:59 2020 New Revision: 360508 URL: https://svnweb.freebsd.org/changeset/base/360508 Log: Fix three bugs highlighted by review: - maxio should be dp->d_maxsize. This is often MAXPHYS, but not always (especially if MAXPHYS is > 1MB). - Unlock the periph before returning. We don't need to relock it to release the ccb. - Make sure we release the ccb in error paths. Reviewed by: cperciva Modified: head/sys/cam/nvme/nvme_da.c Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Thu Apr 30 21:08:22 2020 (r360507) +++ head/sys/cam/nvme/nvme_da.c Thu Apr 30 21:08:59 2020 (r360508) @@ -402,7 +402,7 @@ ndaioctl(struct disk *dp, u_long cmd, void *data, int struct nvme_pt_command *pt; union ccb *ccb; struct cam_periph_map_info mapinfo; - u_int maxmap = MAXPHYS; /* XXX is this right */ + u_int maxmap = dp->d_maxsize; int error; /* @@ -426,8 +426,10 @@ ndaioctl(struct disk *dp, u_long cmd, void *data, int */ memset(&mapinfo, 0, sizeof(mapinfo)); error = cam_periph_mapmem(ccb, &mapinfo, maxmap); - if (error) + if (error) { + xpt_release_ccb(ccb); return (error); + } /* * Lock the periph and run the command. XXX do we need @@ -442,7 +444,6 @@ ndaioctl(struct disk *dp, u_long cmd, void *data, int * Tear down mapping and return status. */ cam_periph_unmapmem(ccb, &mapinfo); - cam_periph_lock(periph); error = (ccb->ccb_h.status == CAM_REQ_CMP) ? 0 : EIO; xpt_release_ccb(ccb); return (error);