diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 4256f9777301..1f88bcf357ea 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -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.