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
This commit is contained in:
Konstantin Belousov 2009-01-20 11:30:22 +00:00
parent 9316467d05
commit b1a4c8e522
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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.