From owner-svn-src-head@freebsd.org Thu Jul 2 12:53:23 2015 Return-Path: Delivered-To: svn-src-head@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 06973991C19; Thu, 2 Jul 2015 12:53:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 CAFD81CB9; Thu, 2 Jul 2015 12:53:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t62CrM0S030849; Thu, 2 Jul 2015 12:53:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t62CrMVR030848; Thu, 2 Jul 2015 12:53:22 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201507021253.t62CrMVR030848@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 2 Jul 2015 12:53:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285030 - head/sys/cam/ctl X-SVN-Group: head 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.20 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, 02 Jul 2015 12:53:23 -0000 Author: mav Date: Thu Jul 2 12:53:22 2015 New Revision: 285030 URL: https://svnweb.freebsd.org/changeset/base/285030 Log: Fix couple panics on forced unmount of backing file. MFC after: 1 week Sponsored by: iXsystems, Inc. Modified: head/sys/cam/ctl/ctl_backend_block.c Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Thu Jul 2 12:14:48 2015 (r285029) +++ head/sys/cam/ctl/ctl_backend_block.c Thu Jul 2 12:53:22 2015 (r285030) @@ -810,24 +810,27 @@ ctl_be_block_getattr_file(struct ctl_be_ { struct vattr vattr; struct statfs statfs; + uint64_t val; int error; + val = UINT64_MAX; if (be_lun->vn == NULL) - return (UINT64_MAX); + return (val); + vn_lock(be_lun->vn, LK_SHARED | LK_RETRY); if (strcmp(attrname, "blocksused") == 0) { error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred); - if (error != 0) - return (UINT64_MAX); - return (vattr.va_bytes >> be_lun->blocksize_shift); + if (error == 0) + val = vattr.va_bytes >> be_lun->blocksize_shift; } - if (strcmp(attrname, "blocksavail") == 0) { + if (strcmp(attrname, "blocksavail") == 0 && + (be_lun->vn->v_iflag & VI_DOOMED) == 0) { error = VFS_STATFS(be_lun->vn->v_mount, &statfs); - if (error != 0) - return (UINT64_MAX); - return ((statfs.f_bavail * statfs.f_bsize) >> - be_lun->blocksize_shift); + if (error == 0) + val = (statfs.f_bavail * statfs.f_bsize) >> + be_lun->blocksize_shift; } - return (UINT64_MAX); + VOP_UNLOCK(be_lun->vn, 0); + return (val); } static void @@ -2666,10 +2669,12 @@ ctl_be_block_modify(struct ctl_be_block_ oldsize = be_lun->size_bytes; if (be_lun->vn == NULL) error = ctl_be_block_open(softc, be_lun, req); + else if (vn_isdisk(be_lun->vn, &error)) + error = ctl_be_block_modify_dev(be_lun, req); else if (be_lun->vn->v_type == VREG) error = ctl_be_block_modify_file(be_lun, req); else - error = ctl_be_block_modify_dev(be_lun, req); + error = EINVAL; if (error == 0 && be_lun->size_bytes != oldsize) { be_lun->size_blocks = be_lun->size_bytes >>