Author: mav
Date: Mon Oct  5 08:09:34 2015
New Revision: 288706
URL: https://svnweb.freebsd.org/changeset/base/288706

Log:
  MFC r285030: Fix couple panics on forced unmount of backing file.

Modified:
  stable/10/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 07:42:07 2015        
(r288705)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 08:09:34 2015        
(r288706)
@@ -809,24 +809,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
@@ -2657,10 +2660,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 >>
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to