Author: kib
Date: Tue Jan 20 11:30:22 2009
New Revision: 187468
URL: http://svn.freebsd.org/changeset/base/187468

Log:
  When extending inode size, we call vnode_pager_setsize(), to have a
  address space where to put vnode pages, and then call UFS_BALLOC(),
  to actually allocate new block and map it. When UFS_BALLOC() returns
  error, sometimes we forget to revert the vm object size increase,
  allowing for the pages that are not backed by the logical disk blocks.
  
  Revert vnode_pager_setsize() back when UFS_BALLOC() failed, for
  ffs_truncate() and ffs_write().
  
  PR:   129956
  Reviewed by:  ups
  MFC after:    3 weeks

Modified:
  head/sys/ufs/ffs/ffs_inode.c
  head/sys/ufs/ffs/ffs_vnops.c

Modified: head/sys/ufs/ffs/ffs_inode.c
==============================================================================
--- head/sys/ufs/ffs/ffs_inode.c        Tue Jan 20 11:27:45 2009        
(r187467)
+++ head/sys/ufs/ffs/ffs_inode.c        Tue Jan 20 11:30:22 2009        
(r187468)
@@ -305,8 +305,10 @@ ffs_truncate(vp, length, flags, cred, td
                vnode_pager_setsize(vp, length);
                flags |= BA_CLRBUF;
                error = UFS_BALLOC(vp, length - 1, 1, cred, flags, &bp);
-               if (error)
+               if (error) {
+                       vnode_pager_setsize(vp, osize);
                        return (error);
+               }
                ip->i_size = length;
                DIP_SET(ip, i_size, length);
                if (bp->b_bufsize == fs->fs_bsize)

Modified: head/sys/ufs/ffs/ffs_vnops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vnops.c        Tue Jan 20 11:27:45 2009        
(r187467)
+++ head/sys/ufs/ffs/ffs_vnops.c        Tue Jan 20 11:30:22 2009        
(r187468)
@@ -723,8 +723,10 @@ ffs_write(ap)
 /* XXX is uio->uio_offset the right thing here? */
                error = UFS_BALLOC(vp, uio->uio_offset, xfersize,
                    ap->a_cred, flags, &bp);
-               if (error != 0)
+               if (error != 0) {
+                       vnode_pager_setsize(vp, ip->i_size);
                        break;
+               }
                /*
                 * If the buffer is not valid we have to clear out any
                 * garbage data from the pages instantiated for the buffer.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to