summaryrefslogtreecommitdiffstats
path: root/sys/ufs/ffs/ffs_balloc.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2002-10-22 01:14:25 +0000
committermckusick <mckusick@FreeBSD.org>2002-10-22 01:14:25 +0000
commita515fcf789d48d52262122aef25ce2bafcf856e0 (patch)
tree4c2b95865bcf2b11cee7058fcd9ff5a548694644 /sys/ufs/ffs/ffs_balloc.c
parent76a6cc0dc172d9a26b57c6064948c52bb19a87e5 (diff)
downloadFreeBSD-src-a515fcf789d48d52262122aef25ce2bafcf856e0.zip
FreeBSD-src-a515fcf789d48d52262122aef25ce2bafcf856e0.tar.gz
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.
Diffstat (limited to 'sys/ufs/ffs/ffs_balloc.c')
-rw-r--r--sys/ufs/ffs/ffs_balloc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index 4256f97..1f88bcf 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -361,6 +361,12 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
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.
* We have to fsync the file before we start to get rid of all
@@ -822,6 +828,12 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
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.
* We have to fsync the file before we start to get rid of all
OpenPOWER on IntegriCloud