summaryrefslogtreecommitdiffstats
path: root/sys/ufs/ffs
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-01-20 11:30:22 +0000
committerkib <kib@FreeBSD.org>2009-01-20 11:30:22 +0000
commitac57d6e717c7b5921f7a8c6d60d1c846ea1d04d5 (patch)
treedcb7f2dd79fbec6fe58af1c382774421b3b97268 /sys/ufs/ffs
parentcbb8defa10711f9b65be83f41f04cbabab84b5fc (diff)
downloadFreeBSD-src-ac57d6e717c7b5921f7a8c6d60d1c846ea1d04d5.zip
FreeBSD-src-ac57d6e717c7b5921f7a8c6d60d1c846ea1d04d5.tar.gz
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
Diffstat (limited to 'sys/ufs/ffs')
-rw-r--r--sys/ufs/ffs/ffs_inode.c4
-rw-r--r--sys/ufs/ffs/ffs_vnops.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 2be220e..36aac0e 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -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)
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 38dc2b6..e5b3ffe 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -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.
OpenPOWER on IntegriCloud