diff options
author | alc <alc@FreeBSD.org> | 1999-05-02 23:57:16 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 1999-05-02 23:57:16 +0000 |
commit | 5cb08a2652f36ddab7172faf6b766038472c1647 (patch) | |
tree | c47eaa3332628f6c725ca32dda81aa44d24e2ac2 /sys/ufs | |
parent | c75d7e89c3e63bc9b8e9863a5cc985649edf5f9a (diff) | |
download | FreeBSD-src-5cb08a2652f36ddab7172faf6b766038472c1647.zip FreeBSD-src-5cb08a2652f36ddab7172faf6b766038472c1647.tar.gz |
The VFS/BIO subsystem contained a number of hacks in order to optimize
piecemeal, middle-of-file writes for NFS. These hacks have caused no
end of trouble, especially when combined with mmap(). I've removed
them. Instead, NFS will issue a read-before-write to fully
instantiate the struct buf containing the write. NFS does, however,
optimize piecemeal appends to files. For most common file operations,
you will not notice the difference. The sole remaining fragment in
the VFS/BIO system is b_dirtyoff/end, which NFS uses to avoid cache
coherency issues with read-merge-write style operations. NFS also
optimizes the write-covers-entire-buffer case by avoiding the
read-before-write. There is quite a bit of room for further
optimization in these areas.
The VM system marks pages fully-valid (AKA vm_page_t->valid =
VM_PAGE_BITS_ALL) in several places, most noteably in vm_fault. This
is not correct operation. The vm_pager_get_pages() code is now
responsible for marking VM pages all-valid. A number of VM helper
routines have been added to aid in zeroing-out the invalid portions of
a VM page prior to the page being marked all-valid. This operation is
necessary to properly support mmap(). The zeroing occurs most often
when dealing with file-EOF situations. Several bugs have been fixed
in the NFS subsystem, including bits handling file and directory EOF
situations and buf->b_flags consistancy issues relating to clearing
B_ERROR & B_INVAL, and handling B_DONE.
getblk() and allocbuf() have been rewritten. B_CACHE operation is now
formally defined in comments and more straightforward in
implementation. B_CACHE for VMIO buffers is based on the validity of
the backing store. B_CACHE for non-VMIO buffers is based simply on
whether the buffer is B_INVAL or not (B_CACHE set if B_INVAL clear,
and vise-versa). biodone() is now responsible for setting B_CACHE
when a successful read completes. B_CACHE is also set when a bdwrite()
is initiated and when a bwrite() is initiated. VFS VOP_BWRITE
routines (there are only two - nfs_bwrite() and bwrite()) are now
expected to set B_CACHE. This means that bowrite() and bawrite() also
set B_CACHE indirectly.
There are a number of places in the code which were previously using
buf->b_bufsize (which is DEV_BSIZE aligned) when they should have
been using buf->b_bcount. These have been fixed. getblk() now clears
B_DONE on return because the rest of the system is so bad about
dealing with B_DONE.
Major fixes to NFS/TCP have been made. A server-side bug could cause
requests to be lost by the server due to nfs_realign() overwriting
other rpc's in the same TCP mbuf chain. The server's kernel must be
recompiled to get the benefit of the fixes.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 3 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vnops.c | 5 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_bmap.c | 3 |
3 files changed, 8 insertions, 3 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 8821440..c80d0a5 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 - * $Id: ffs_inode.c,v 1.52 1999/01/07 16:14:16 bde Exp $ + * $Id: ffs_inode.c,v 1.53 1999/01/28 00:57:54 dillon Exp $ */ #include "opt_quota.h" @@ -452,6 +452,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) if ((bp->b_flags & B_CACHE) == 0) { curproc->p_stats->p_ru.ru_inblock++; /* pay for read */ bp->b_flags |= B_READ; + bp->b_flags &= ~(B_ERROR|B_INVAL); if (bp->b_bcount > bp->b_bufsize) panic("ffs_indirtrunc: bad buffer size"); bp->b_blkno = dbn; diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c index d4d82f0..c9ae4dd 100644 --- a/sys/ufs/mfs/mfs_vnops.c +++ b/sys/ufs/mfs/mfs_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mfs_vnops.c 8.11 (Berkeley) 5/22/95 - * $Id: mfs_vnops.c,v 1.42 1999/01/28 00:57:55 dillon Exp $ + * $Id: mfs_vnops.c,v 1.43 1999/04/11 02:28:32 eivind Exp $ */ #include <sys/param.h> @@ -127,6 +127,9 @@ mfs_fsync(ap) * We implement the B_FREEBUF strategy. We can't just madvise() * here because we have to do it in the correct order vs other bio * requests, so we queue it. + * + * Note: geteblk() sets B_INVAL. We leave it set to guarentee buffer + * throw-away on brelse()? XXX */ static int diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index f40ff33..3ea5965 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 - * $Id: ufs_bmap.c,v 1.24 1998/10/27 11:47:08 bde Exp $ + * $Id: ufs_bmap.c,v 1.25 1999/01/28 00:57:55 dillon Exp $ */ #include <sys/param.h> @@ -228,6 +228,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) #endif bp->b_blkno = blkptrtodb(ump, daddr); bp->b_flags |= B_READ; + bp->b_flags &= ~(B_INVAL|B_ERROR); vfs_busy_pages(bp, 0); VOP_STRATEGY(bp->b_vp, bp); curproc->p_stats->p_ru.ru_inblock++; /* XXX */ |