This update is a performance improvement when allocating blocks on

a full filesystem. Previously, if the allocation failed, we had to
fsync the file before rolling back any partial allocation of indirect
blocks. Most block allocation requests only need to allocate a single
data block and if that allocation fails, there is nothing to unroll.
So, before doing the fsync, we check to see if any rollback will
really be necessary. If none is necessary, then we simply return.
This update eliminates the flurry of disk activity that got triggered
whenever a filesystem would run out of space.

Sponsored by:	DARPA & NAI Labs.
This commit is contained in:
Kirk McKusick 2002-10-22 01:14:25 +00:00
parent 9e4b381a54
commit 127ab960d5

View File

@ -360,6 +360,12 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
*bpp = nbp;
return (0);
fail:
/*
* If we have failed to allocate any blocks, simply return the error.
* This is the usual case and avoids the need to fsync the file.
*/
if (allocblk == allociblk && allocib == NULL && unwindidx == -1)
return (error);
/*
* If we have failed part way through block allocation, we
* have to deallocate any indirect blocks that we have allocated.
@ -821,6 +827,12 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
*bpp = nbp;
return (0);
fail:
/*
* If we have failed to allocate any blocks, simply return the error.
* This is the usual case and avoids the need to fsync the file.
*/
if (allocblk == allociblk && allocib == NULL && unwindidx == -1)
return (error);
/*
* If we have failed part way through block allocation, we
* have to deallocate any indirect blocks that we have allocated.