2005-01-07 02:29:27 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1982, 1986, 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* (c) UNIX System Laboratories, Inc.
|
|
|
|
* All or some portions of this file are derived from material licensed
|
|
|
|
* to the University of California by American Telephone and Telegraph
|
|
|
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
|
|
|
* the permission of UNIX System Laboratories, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1996-03-11 02:04:27 +00:00
|
|
|
* @(#)buf.h 8.9 (Berkeley) 3/30/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_BUF_H_
|
|
|
|
#define _SYS_BUF_H_
|
1996-05-01 02:16:17 +00:00
|
|
|
|
2004-10-24 20:03:41 +00:00
|
|
|
#include <sys/bufobj.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/queue.h>
|
1999-06-26 02:47:16 +00:00
|
|
|
#include <sys/lock.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lockmgr.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2000-05-01 13:36:25 +00:00
|
|
|
struct bio;
|
1995-02-18 21:12:33 +00:00
|
|
|
struct buf;
|
2004-10-22 08:47:20 +00:00
|
|
|
struct bufobj;
|
1998-03-08 09:59:44 +00:00
|
|
|
struct mount;
|
1998-09-24 15:02:46 +00:00
|
|
|
struct vnode;
|
2004-10-27 08:05:02 +00:00
|
|
|
struct uio;
|
1998-03-08 09:59:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* To avoid including <ufs/ffs/softdep.h>
|
|
|
|
*/
|
2000-05-26 02:09:24 +00:00
|
|
|
LIST_HEAD(workhead, worklist);
|
1998-03-08 09:59:44 +00:00
|
|
|
/*
|
|
|
|
* These are currently used only by the soft dependency code, hence
|
|
|
|
* are stored once in a global variable. If other subsystems wanted
|
|
|
|
* to use these hooks, a pointer to a set of bio_ops could be added
|
|
|
|
* to each buffer.
|
|
|
|
*/
|
|
|
|
extern struct bio_ops {
|
2002-03-19 20:18:42 +00:00
|
|
|
void (*io_start)(struct buf *);
|
|
|
|
void (*io_complete)(struct buf *);
|
|
|
|
void (*io_deallocate)(struct buf *);
|
|
|
|
int (*io_countdeps)(struct buf *, int);
|
1998-03-08 09:59:44 +00:00
|
|
|
} bioops;
|
1995-02-18 21:12:33 +00:00
|
|
|
|
2002-07-06 08:59:52 +00:00
|
|
|
struct vm_object;
|
|
|
|
|
2002-07-10 17:02:32 +00:00
|
|
|
typedef unsigned char b_xflags_t;
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* The buffer header describes an I/O operation in the kernel.
|
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>
1999-05-02 23:57:16 +00:00
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
* b_bufsize, b_bcount. b_bufsize is the allocation size of the
|
|
|
|
* buffer, either DEV_BSIZE or PAGE_SIZE aligned. b_bcount is the
|
|
|
|
* originally requested buffer size and can serve as a bounds check
|
|
|
|
* against EOF. For most, but not all uses, b_bcount == b_bufsize.
|
|
|
|
*
|
|
|
|
* b_dirtyoff, b_dirtyend. Buffers support piecemeal, unaligned
|
|
|
|
* ranges of dirty data that need to be written to backing store.
|
|
|
|
* The range is typically clipped at b_bcount ( not b_bufsize ).
|
|
|
|
*
|
|
|
|
* b_resid. Number of bytes remaining in I/O. After an I/O operation
|
|
|
|
* completes, b_resid is usually 0 indicating 100% success.
|
2003-02-09 11:28:35 +00:00
|
|
|
*
|
|
|
|
* All fields are protected by the buffer lock except those marked:
|
2008-03-22 09:15:16 +00:00
|
|
|
* V - Protected by owning bufobj lock
|
2003-02-09 11:28:35 +00:00
|
|
|
* Q - Protected by the buf queue lock
|
|
|
|
* D - Protected by an dependency implementation specific lock
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
struct buf {
|
2004-10-22 08:47:20 +00:00
|
|
|
struct bufobj *b_bufobj;
|
2004-11-04 09:37:50 +00:00
|
|
|
long b_bcount;
|
|
|
|
void *b_caller1;
|
|
|
|
caddr_t b_data;
|
|
|
|
int b_error;
|
|
|
|
uint8_t b_iocmd;
|
|
|
|
uint8_t b_ioflags;
|
|
|
|
off_t b_iooffset;
|
|
|
|
long b_resid;
|
2002-03-19 20:18:42 +00:00
|
|
|
void (*b_iodone)(struct buf *);
|
2003-10-18 17:53:34 +00:00
|
|
|
daddr_t b_blkno; /* Underlying physical block number. */
|
2000-04-25 10:51:18 +00:00
|
|
|
off_t b_offset; /* Offset into file. */
|
2004-10-21 15:53:54 +00:00
|
|
|
TAILQ_ENTRY(buf) b_bobufs; /* (V) Buffer's associated vnode. */
|
2003-02-09 11:28:35 +00:00
|
|
|
struct buf *b_left; /* (V) splay tree link */
|
|
|
|
struct buf *b_right; /* (V) splay tree link */
|
|
|
|
uint32_t b_vflags; /* (V) BV_* flags */
|
|
|
|
TAILQ_ENTRY(buf) b_freelist; /* (Q) Free list position inactive. */
|
|
|
|
unsigned short b_qindex; /* (Q) buffer queue index */
|
|
|
|
uint32_t b_flags; /* B_* flags. */
|
2002-07-10 17:02:32 +00:00
|
|
|
b_xflags_t b_xflags; /* extra flags */
|
1999-06-26 02:47:16 +00:00
|
|
|
struct lock b_lock; /* Buffer lock */
|
1994-05-24 10:09:53 +00:00
|
|
|
long b_bufsize; /* Allocated buffer size. */
|
2000-12-26 19:41:38 +00:00
|
|
|
long b_runningbufspace; /* when I/O is running, pipelining */
|
1996-11-30 22:41:49 +00:00
|
|
|
caddr_t b_kvabase; /* base kva for buffer */
|
Implement the concept of the unmapped VMIO buffers, i.e. buffers which
do not map the b_pages pages into buffer_map KVA. The use of the
unmapped buffers eliminate the need to perform TLB shootdown for
mapping on the buffer creation and reuse, greatly reducing the amount
of IPIs for shootdown on big-SMP machines and eliminating up to 25-30%
of the system time on i/o intensive workloads.
The unmapped buffer should be explicitely requested by the GB_UNMAPPED
flag by the consumer. For unmapped buffer, no KVA reservation is
performed at all. The consumer might request unmapped buffer which
does have a KVA reserve, to manually map it without recursing into
buffer cache and blocking, with the GB_KVAALLOC flag.
When the mapped buffer is requested and unmapped buffer already
exists, the cache performs an upgrade, possibly reusing the KVA
reservation.
Unmapped buffer is translated into unmapped bio in g_vfs_strategy().
Unmapped bio carry a pointer to the vm_page_t array, offset and length
instead of the data pointer. The provider which processes the bio
should explicitely specify a readiness to accept unmapped bio,
otherwise g_down geom thread performs the transient upgrade of the bio
request by mapping the pages into the new bio_transient_map KVA
submap.
The bio_transient_map submap claims up to 10% of the buffer map, and
the total buffer_map + bio_transient_map KVA usage stays the
same. Still, it could be manually tuned by kern.bio_transient_maxcnt
tunable, in the units of the transient mappings. Eventually, the
bio_transient_map could be removed after all geom classes and drivers
can accept unmapped i/o requests.
Unmapped support can be turned off by the vfs.unmapped_buf_allowed
tunable, disabling which makes the buffer (or cluster) creation
requests to ignore GB_UNMAPPED and GB_KVAALLOC flags. Unmapped
buffers are only enabled by default on the architectures where
pmap_copy_page() was implemented and tested.
In the rework, filesystem metadata is not the subject to maxbufspace
limit anymore. Since the metadata buffers are always mapped, the
buffers still have to fit into the buffer map, which provides a
reasonable (but practically unreachable) upper bound on it. The
non-metadata buffer allocations, both mapped and unmapped, is
accounted against maxbufspace, as before. Effectively, this means that
the maxbufspace is forced on mapped and unmapped buffers separately.
The pre-patch bufspace limiting code did not worked, because
buffer_map fragmentation does not allow the limit to be reached.
By Jeff Roberson request, the getnewbuf() function was split into
smaller single-purpose functions.
Sponsored by: The FreeBSD Foundation
Discussed with: jeff (previous version)
Tested by: pho, scottl (previous version), jhb, bf
MFC after: 2 weeks
2013-03-19 14:13:12 +00:00
|
|
|
caddr_t b_kvaalloc; /* allocated kva for B_KVAALLOC */
|
1996-11-30 22:41:49 +00:00
|
|
|
int b_kvasize; /* size of kva for buffer */
|
2002-05-14 11:09:43 +00:00
|
|
|
daddr_t b_lblkno; /* Logical block number. */
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *b_vp; /* Device vnode. */
|
|
|
|
int b_dirtyoff; /* Offset in buffer of dirty region. */
|
|
|
|
int b_dirtyend; /* Offset of end of dirty region. */
|
|
|
|
struct ucred *b_rcred; /* Read credentials reference. */
|
|
|
|
struct ucred *b_wcred; /* Write credentials reference. */
|
1996-12-29 02:45:28 +00:00
|
|
|
void *b_saveaddr; /* Original b_addr for physio. */
|
1999-01-21 08:29:12 +00:00
|
|
|
union pager_info {
|
|
|
|
int pg_reqpage;
|
|
|
|
} b_pager;
|
1995-11-19 19:54:31 +00:00
|
|
|
union cluster_info {
|
2000-05-26 02:09:24 +00:00
|
|
|
TAILQ_HEAD(cluster_list_head, buf) cluster_head;
|
|
|
|
TAILQ_ENTRY(buf) cluster_entry;
|
1995-11-19 19:54:31 +00:00
|
|
|
} b_cluster;
|
1996-05-03 20:56:09 +00:00
|
|
|
struct vm_page *b_pages[btoc(MAXPHYS)];
|
1994-10-05 09:48:45 +00:00
|
|
|
int b_npages;
|
2003-02-09 11:28:35 +00:00
|
|
|
struct workhead b_dep; /* (D) List of filesystem dependencies. */
|
2005-12-07 03:39:08 +00:00
|
|
|
void *b_fsprivate1;
|
|
|
|
void *b_fsprivate2;
|
|
|
|
void *b_fsprivate3;
|
|
|
|
int b_pin_count;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
2004-10-25 06:02:57 +00:00
|
|
|
#define b_object b_bufobj->bo_object
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* These flags are kept in b_flags.
|
1999-01-21 08:29:12 +00:00
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
*
|
|
|
|
* B_ASYNC VOP calls on bp's are usually async whether or not
|
|
|
|
* B_ASYNC is set, but some subsystems, such as NFS, like
|
|
|
|
* to know what is best for the caller so they can
|
|
|
|
* optimize the I/O.
|
|
|
|
*
|
|
|
|
* B_PAGING Indicates that bp is being used by the paging system or
|
|
|
|
* some paging system and that the bp is not linked into
|
|
|
|
* the b_vp's clean/dirty linked lists or ref counts.
|
|
|
|
* Buffer vp reassignments are illegal in this case.
|
|
|
|
*
|
|
|
|
* B_CACHE This may only be set if the buffer is entirely valid.
|
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>
1999-05-02 23:57:16 +00:00
|
|
|
* The situation where B_DELWRI is set and B_CACHE is
|
|
|
|
* clear MUST be committed to disk by getblk() so
|
|
|
|
* B_DELWRI can also be cleared. See the comments for
|
|
|
|
* getblk() in kern/vfs_bio.c. If B_CACHE is clear,
|
2000-04-02 15:24:56 +00:00
|
|
|
* the caller is expected to clear BIO_ERROR and B_INVAL,
|
2000-03-20 10:44:49 +00:00
|
|
|
* set BIO_READ, and initiate an I/O.
|
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>
1999-05-02 23:57:16 +00:00
|
|
|
*
|
|
|
|
* The 'entire buffer' is defined to be the range from
|
|
|
|
* 0 through b_bcount.
|
|
|
|
*
|
|
|
|
* B_MALLOC Request that the buffer be allocated from the malloc
|
|
|
|
* pool, DEV_BSIZE aligned instead of PAGE_SIZE aligned.
|
|
|
|
*
|
1999-12-12 06:09:57 +00:00
|
|
|
* B_CLUSTEROK This flag is typically set for B_DELWRI buffers
|
|
|
|
* by filesystems that allow clustering when the buffer
|
|
|
|
* is fully dirty and indicates that it may be clustered
|
|
|
|
* with other adjacent dirty buffers. Note the clustering
|
|
|
|
* may not be used with the stage 1 data write under NFS
|
|
|
|
* but may be used for the commit rpc portion.
|
|
|
|
*
|
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>
1999-05-02 23:57:16 +00:00
|
|
|
* B_VMIO Indicates that the buffer is tied into an VM object.
|
|
|
|
* The buffer's data is always PAGE_SIZE aligned even
|
|
|
|
* if b_bufsize and b_bcount are not. ( b_bufsize is
|
|
|
|
* always at least DEV_BSIZE aligned, though ).
|
2001-05-24 07:22:27 +00:00
|
|
|
*
|
|
|
|
* B_DIRECT Hint that we should attempt to completely free
|
|
|
|
* the pages underlying the buffer. B_DIRECT is
|
|
|
|
* sticky until the buffer is released and typically
|
|
|
|
* only has an effect when B_RELBUF is also set.
|
2001-11-05 18:48:54 +00:00
|
|
|
*
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1999-01-21 08:29:12 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_AGE 0x00000001 /* Move to age queue when I/O done. */
|
1996-03-11 02:04:27 +00:00
|
|
|
#define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
|
2001-05-24 07:22:27 +00:00
|
|
|
#define B_DIRECT 0x00000008 /* direct I/O flag (pls free vmio) */
|
2000-01-10 00:24:24 +00:00
|
|
|
#define B_DEFERRED 0x00000010 /* Skipped over for cleaning */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_CACHE 0x00000020 /* Bread found us in the cache. */
|
2000-07-24 05:28:33 +00:00
|
|
|
#define B_VALIDSUSPWRT 0x00000040 /* Valid write during suspension. */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_DELWRI 0x00000080 /* Delay I/O until buffer reused. */
|
2005-09-08 06:30:05 +00:00
|
|
|
#define B_PERSISTENT 0x00000100 /* Perm. ref'ed while EXT2FS mounted. */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_DONE 0x00000200 /* I/O completed. */
|
|
|
|
#define B_EINTR 0x00000400 /* I/O was interrupted */
|
Implement the concept of the unmapped VMIO buffers, i.e. buffers which
do not map the b_pages pages into buffer_map KVA. The use of the
unmapped buffers eliminate the need to perform TLB shootdown for
mapping on the buffer creation and reuse, greatly reducing the amount
of IPIs for shootdown on big-SMP machines and eliminating up to 25-30%
of the system time on i/o intensive workloads.
The unmapped buffer should be explicitely requested by the GB_UNMAPPED
flag by the consumer. For unmapped buffer, no KVA reservation is
performed at all. The consumer might request unmapped buffer which
does have a KVA reserve, to manually map it without recursing into
buffer cache and blocking, with the GB_KVAALLOC flag.
When the mapped buffer is requested and unmapped buffer already
exists, the cache performs an upgrade, possibly reusing the KVA
reservation.
Unmapped buffer is translated into unmapped bio in g_vfs_strategy().
Unmapped bio carry a pointer to the vm_page_t array, offset and length
instead of the data pointer. The provider which processes the bio
should explicitely specify a readiness to accept unmapped bio,
otherwise g_down geom thread performs the transient upgrade of the bio
request by mapping the pages into the new bio_transient_map KVA
submap.
The bio_transient_map submap claims up to 10% of the buffer map, and
the total buffer_map + bio_transient_map KVA usage stays the
same. Still, it could be manually tuned by kern.bio_transient_maxcnt
tunable, in the units of the transient mappings. Eventually, the
bio_transient_map could be removed after all geom classes and drivers
can accept unmapped i/o requests.
Unmapped support can be turned off by the vfs.unmapped_buf_allowed
tunable, disabling which makes the buffer (or cluster) creation
requests to ignore GB_UNMAPPED and GB_KVAALLOC flags. Unmapped
buffers are only enabled by default on the architectures where
pmap_copy_page() was implemented and tested.
In the rework, filesystem metadata is not the subject to maxbufspace
limit anymore. Since the metadata buffers are always mapped, the
buffers still have to fit into the buffer map, which provides a
reasonable (but practically unreachable) upper bound on it. The
non-metadata buffer allocations, both mapped and unmapped, is
accounted against maxbufspace, as before. Effectively, this means that
the maxbufspace is forced on mapped and unmapped buffers separately.
The pre-patch bufspace limiting code did not worked, because
buffer_map fragmentation does not allow the limit to be reached.
By Jeff Roberson request, the getnewbuf() function was split into
smaller single-purpose functions.
Sponsored by: The FreeBSD Foundation
Discussed with: jeff (previous version)
Tested by: pho, scottl (previous version), jhb, bf
MFC after: 2 weeks
2013-03-19 14:13:12 +00:00
|
|
|
#define B_UNMAPPED 0x00000800 /* KVA is not mapped. */
|
|
|
|
#define B_KVAALLOC 0x00001000 /* But allocated. */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_INVAL 0x00002000 /* Does not contain valid info. */
|
2013-02-16 14:51:30 +00:00
|
|
|
#define B_BARRIER 0x00004000 /* Write this and all preceeding first. */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define B_NOCACHE 0x00008000 /* Do not cache block after use. */
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
#define B_MALLOC 0x00010000 /* malloced b_data */
|
1996-09-06 05:35:00 +00:00
|
|
|
#define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */
|
2003-11-15 09:28:09 +00:00
|
|
|
#define B_000400000 0x00040000 /* Available flag. */
|
2003-08-06 06:53:54 +00:00
|
|
|
#define B_000800000 0x00080000 /* Available flag. */
|
2002-05-04 19:40:34 +00:00
|
|
|
#define B_00100000 0x00100000 /* Available flag. */
|
|
|
|
#define B_DIRTY 0x00200000 /* Needs writing later (in EXT2FS). */
|
1995-04-09 06:03:56 +00:00
|
|
|
#define B_RELBUF 0x00400000 /* Release VMIO buffer. */
|
2002-05-04 19:40:34 +00:00
|
|
|
#define B_00800000 0x00800000 /* Available flag. */
|
2010-04-24 07:05:35 +00:00
|
|
|
#define B_NOCOPY 0x01000000 /* Don't copy-on-write this buf. */
|
2012-10-22 17:50:54 +00:00
|
|
|
#define B_02000000 0x02000000 /* Available flag. */
|
1995-04-19 10:32:11 +00:00
|
|
|
#define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */
|
2005-12-07 03:39:08 +00:00
|
|
|
#define B_MANAGED 0x08000000 /* Managed by FS. */
|
1996-12-29 02:45:28 +00:00
|
|
|
#define B_RAM 0x10000000 /* Read ahead mark (flag) */
|
1994-10-05 09:48:45 +00:00
|
|
|
#define B_VMIO 0x20000000 /* VMIO flag */
|
1994-05-25 09:21:21 +00:00
|
|
|
#define B_CLUSTER 0x40000000 /* pagein op, so swap() can count it */
|
2004-11-18 08:44:09 +00:00
|
|
|
#define B_REMFREE 0x80000000 /* Delayed bremfree */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2012-06-02 18:44:40 +00:00
|
|
|
#define PRINT_BUF_FLAGS "\20\40remfree\37cluster\36vmio\35ram\34managed" \
|
|
|
|
"\33paging\32needsgiant\31nocopy\30b23\27relbuf\26dirty\25b20" \
|
2005-09-08 06:30:05 +00:00
|
|
|
"\24b19\23b18\22clusterok\21malloc\20nocache\17b14\16inval" \
|
|
|
|
"\15b12\14b11\13eintr\12done\11persist\10delwri\7validsuspwrt" \
|
2002-05-04 19:40:34 +00:00
|
|
|
"\6cache\5deferred\4direct\3async\2needcommit\1age"
|
1998-09-05 14:13:12 +00:00
|
|
|
|
1998-10-31 14:05:11 +00:00
|
|
|
/*
|
|
|
|
* These flags are kept in b_xflags.
|
|
|
|
*/
|
1999-12-22 03:11:04 +00:00
|
|
|
#define BX_VNDIRTY 0x00000001 /* On vnode dirty list */
|
|
|
|
#define BX_VNCLEAN 0x00000002 /* On vnode clean list */
|
2003-08-28 06:55:18 +00:00
|
|
|
#define BX_BKGRDWRITE 0x00000010 /* Do writes in background */
|
2002-07-10 17:02:32 +00:00
|
|
|
#define BX_BKGRDMARKER 0x00000020 /* Mark buffer for splay tree */
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
#define BX_ALTDATA 0x00000040 /* Holds extended data */
|
1998-10-31 14:05:11 +00:00
|
|
|
|
2012-06-02 18:44:40 +00:00
|
|
|
#define PRINT_BUF_XFLAGS "\20\7altdata\6bkgrdmarker\5bkgrdwrite\2clean\1dirty"
|
|
|
|
|
1998-03-19 22:49:01 +00:00
|
|
|
#define NOOFFSET (-1LL) /* No buffer offset calculated yet */
|
|
|
|
|
2003-08-28 06:55:18 +00:00
|
|
|
/*
|
|
|
|
* These flags are kept in b_vflags.
|
|
|
|
*/
|
|
|
|
#define BV_SCANNED 0x00000001 /* VOP_FSYNC funcs mark written bufs */
|
|
|
|
#define BV_BKGRDINPROG 0x00000002 /* Background write in progress */
|
|
|
|
#define BV_BKGRDWAIT 0x00000004 /* Background write waiting */
|
2010-06-11 17:03:26 +00:00
|
|
|
#define BV_INFREECNT 0x80000000 /* buf is counted in numfreebufs */
|
2003-02-09 11:28:35 +00:00
|
|
|
|
2012-06-02 19:39:12 +00:00
|
|
|
#define PRINT_BUF_VFLAGS "\20\40infreecnt\3bkgrdwait\2bkgrdinprog\1scanned"
|
2012-06-02 18:44:40 +00:00
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1999-06-26 02:47:16 +00:00
|
|
|
/*
|
|
|
|
* Buffer locking
|
|
|
|
*/
|
2002-03-05 18:20:58 +00:00
|
|
|
extern const char *buf_wmesg; /* Default buffer lock message */
|
1999-06-26 02:47:16 +00:00
|
|
|
#define BUF_WMESG "bufwait"
|
2001-09-12 08:38:13 +00:00
|
|
|
#include <sys/proc.h> /* XXX for curthread */
|
2000-10-20 07:58:15 +00:00
|
|
|
#include <sys/mutex.h>
|
2000-10-04 01:29:17 +00:00
|
|
|
|
1999-06-26 02:47:16 +00:00
|
|
|
/*
|
|
|
|
* Initialize a lock.
|
|
|
|
*/
|
2008-03-28 00:14:33 +00:00
|
|
|
#define BUF_LOCKINIT(bp) \
|
2000-07-26 23:10:02 +00:00
|
|
|
lockinit(&(bp)->b_lock, PRIBIO + 4, buf_wmesg, 0, 0)
|
1999-06-26 02:47:16 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Get a lock sleeping non-interruptably until it becomes available.
|
|
|
|
*/
|
2008-03-28 12:30:12 +00:00
|
|
|
#define BUF_LOCK(bp, locktype, interlock) \
|
|
|
|
_lockmgr_args(&(bp)->b_lock, (locktype), (interlock), \
|
|
|
|
LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, \
|
|
|
|
LOCK_FILE, LOCK_LINE)
|
1999-06-26 02:47:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a lock sleeping with specified interruptably and timeout.
|
|
|
|
*/
|
2008-03-28 12:30:12 +00:00
|
|
|
#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \
|
|
|
|
_lockmgr_args(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \
|
|
|
|
(interlock), (wmesg), (PRIBIO + 4) | (catch), (timo), \
|
|
|
|
LOCK_FILE, LOCK_LINE)
|
1999-06-26 02:47:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Release a lock. Only the acquiring process may free the lock unless
|
|
|
|
* it has been handed off to biodone.
|
|
|
|
*/
|
2008-03-28 00:14:33 +00:00
|
|
|
#define BUF_UNLOCK(bp) do { \
|
|
|
|
KASSERT(((bp)->b_flags & B_REMFREE) == 0, \
|
|
|
|
("BUF_UNLOCK %p while B_REMFREE is still set.", (bp))); \
|
|
|
|
\
|
|
|
|
(void)_lockmgr_args(&(bp)->b_lock, LK_RELEASE, NULL, \
|
|
|
|
LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, \
|
|
|
|
LOCK_FILE, LOCK_LINE); \
|
|
|
|
} while (0)
|
1999-06-27 11:40:03 +00:00
|
|
|
|
2008-01-19 17:36:23 +00:00
|
|
|
/*
|
|
|
|
* Check if a buffer lock is recursed.
|
|
|
|
*/
|
|
|
|
#define BUF_LOCKRECURSED(bp) \
|
2008-03-28 00:14:33 +00:00
|
|
|
lockmgr_recursed(&(bp)->b_lock)
|
2008-01-19 17:36:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if a buffer lock is currently held.
|
|
|
|
*/
|
|
|
|
#define BUF_ISLOCKED(bp) \
|
2008-03-28 00:14:33 +00:00
|
|
|
lockstatus(&(bp)->b_lock)
|
1999-06-26 02:47:16 +00:00
|
|
|
/*
|
|
|
|
* Free a buffer lock.
|
|
|
|
*/
|
2008-02-13 20:44:19 +00:00
|
|
|
#define BUF_LOCKFREE(bp) \
|
2008-03-28 00:14:33 +00:00
|
|
|
lockdestroy(&(bp)->b_lock)
|
|
|
|
|
2011-09-08 12:56:26 +00:00
|
|
|
/*
|
|
|
|
* Print informations on a buffer lock.
|
|
|
|
*/
|
|
|
|
#define BUF_LOCKPRINTINFO(bp) \
|
|
|
|
lockmgr_printinfo(&(bp)->b_lock)
|
|
|
|
|
2008-02-13 20:44:19 +00:00
|
|
|
/*
|
|
|
|
* Buffer lock assertions.
|
|
|
|
*/
|
|
|
|
#if defined(INVARIANTS) && defined(INVARIANT_SUPPORT)
|
|
|
|
#define BUF_ASSERT_LOCKED(bp) \
|
|
|
|
_lockmgr_assert(&(bp)->b_lock, KA_LOCKED, LOCK_FILE, LOCK_LINE)
|
|
|
|
#define BUF_ASSERT_SLOCKED(bp) \
|
|
|
|
_lockmgr_assert(&(bp)->b_lock, KA_SLOCKED, LOCK_FILE, LOCK_LINE)
|
|
|
|
#define BUF_ASSERT_XLOCKED(bp) \
|
|
|
|
_lockmgr_assert(&(bp)->b_lock, KA_XLOCKED, LOCK_FILE, LOCK_LINE)
|
|
|
|
#define BUF_ASSERT_UNLOCKED(bp) \
|
|
|
|
_lockmgr_assert(&(bp)->b_lock, KA_UNLOCKED, LOCK_FILE, LOCK_LINE)
|
2008-03-28 00:14:33 +00:00
|
|
|
#define BUF_ASSERT_HELD(bp)
|
|
|
|
#define BUF_ASSERT_UNHELD(bp)
|
2008-02-13 20:44:19 +00:00
|
|
|
#else
|
|
|
|
#define BUF_ASSERT_LOCKED(bp)
|
|
|
|
#define BUF_ASSERT_SLOCKED(bp)
|
|
|
|
#define BUF_ASSERT_XLOCKED(bp)
|
|
|
|
#define BUF_ASSERT_UNLOCKED(bp)
|
|
|
|
#define BUF_ASSERT_HELD(bp)
|
|
|
|
#define BUF_ASSERT_UNHELD(bp)
|
|
|
|
#endif
|
2000-10-04 01:29:17 +00:00
|
|
|
|
2000-10-29 14:54:55 +00:00
|
|
|
#ifdef _SYS_PROC_H_ /* Avoid #include <sys/proc.h> pollution */
|
1999-06-26 02:47:16 +00:00
|
|
|
/*
|
|
|
|
* When initiating asynchronous I/O, change ownership of the lock to the
|
|
|
|
* kernel. Once done, the lock may legally released by biodone. The
|
|
|
|
* original owning process can no longer acquire it recursively, but must
|
|
|
|
* wait until the I/O is completed and the lock has been freed by biodone.
|
|
|
|
*/
|
2008-03-28 00:14:33 +00:00
|
|
|
#define BUF_KERNPROC(bp) \
|
|
|
|
_lockmgr_disown(&(bp)->b_lock, LOCK_FILE, LOCK_LINE)
|
2000-10-29 14:54:55 +00:00
|
|
|
#endif
|
2006-10-02 02:06:27 +00:00
|
|
|
|
2008-03-28 12:30:12 +00:00
|
|
|
/*
|
|
|
|
* Find out if the lock has waiters or not.
|
|
|
|
*/
|
|
|
|
#define BUF_LOCKWAITERS(bp) \
|
|
|
|
lockmgr_waiters(&(bp)->b_lock)
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1999-06-26 14:25:03 +00:00
|
|
|
|
1998-09-15 08:55:03 +00:00
|
|
|
struct buf_queue_head {
|
2000-05-26 02:09:24 +00:00
|
|
|
TAILQ_HEAD(buf_queue, buf) queue;
|
2002-05-14 11:09:43 +00:00
|
|
|
daddr_t last_pblkno;
|
1997-09-21 22:09:24 +00:00
|
|
|
struct buf *insert_point;
|
|
|
|
struct buf *switch_point;
|
1998-09-15 08:55:03 +00:00
|
|
|
};
|
1997-09-21 22:09:24 +00:00
|
|
|
|
1998-11-13 01:01:44 +00:00
|
|
|
/*
|
|
|
|
* This structure describes a clustered I/O. It is stored in the b_saveaddr
|
|
|
|
* field of the buffer on which I/O is done. At I/O completion, cluster
|
|
|
|
* callback uses the structure to parcel I/O's to individual buffers, and
|
|
|
|
* then free's this structure.
|
|
|
|
*/
|
|
|
|
struct cluster_save {
|
|
|
|
long bs_bcount; /* Saved b_bcount. */
|
|
|
|
long bs_bufsize; /* Saved b_bufsize. */
|
|
|
|
void *bs_saveaddr; /* Saved b_addr. */
|
|
|
|
int bs_nchildren; /* Number of associated buffers. */
|
|
|
|
struct buf **bs_children; /* List of associated buffers. */
|
|
|
|
};
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1997-09-21 22:09:24 +00:00
|
|
|
|
2004-10-24 20:03:41 +00:00
|
|
|
static __inline int
|
|
|
|
bwrite(struct buf *bp)
|
|
|
|
{
|
2004-10-27 08:05:02 +00:00
|
|
|
|
2004-10-24 20:03:41 +00:00
|
|
|
KASSERT(bp->b_bufobj != NULL, ("bwrite: no bufobj bp=%p", bp));
|
|
|
|
KASSERT(bp->b_bufobj->bo_ops != NULL, ("bwrite: no bo_ops bp=%p", bp));
|
|
|
|
KASSERT(bp->b_bufobj->bo_ops->bop_write != NULL,
|
|
|
|
("bwrite: no bop_write bp=%p", bp));
|
2005-01-11 09:10:46 +00:00
|
|
|
return (BO_WRITE(bp->b_bufobj, bp));
|
2004-10-24 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
bstrategy(struct buf *bp)
|
|
|
|
{
|
2004-10-27 08:05:02 +00:00
|
|
|
|
2004-11-03 09:05:55 +00:00
|
|
|
KASSERT(bp->b_bufobj != NULL, ("bstrategy: no bufobj bp=%p", bp));
|
|
|
|
KASSERT(bp->b_bufobj->bo_ops != NULL,
|
|
|
|
("bstrategy: no bo_ops bp=%p", bp));
|
2004-10-24 20:03:41 +00:00
|
|
|
KASSERT(bp->b_bufobj->bo_ops->bop_strategy != NULL,
|
2004-11-03 09:05:55 +00:00
|
|
|
("bstrategy: no bop_strategy bp=%p", bp));
|
2005-01-11 09:10:46 +00:00
|
|
|
BO_STRATEGY(bp->b_bufobj, bp);
|
2004-10-24 20:03:41 +00:00
|
|
|
}
|
2001-04-17 08:56:39 +00:00
|
|
|
|
2000-06-16 08:48:51 +00:00
|
|
|
static __inline void
|
|
|
|
buf_start(struct buf *bp)
|
|
|
|
{
|
|
|
|
if (bioops.io_start)
|
|
|
|
(*bioops.io_start)(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
buf_complete(struct buf *bp)
|
|
|
|
{
|
|
|
|
if (bioops.io_complete)
|
|
|
|
(*bioops.io_complete)(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
buf_deallocate(struct buf *bp)
|
|
|
|
{
|
|
|
|
if (bioops.io_deallocate)
|
|
|
|
(*bioops.io_deallocate)(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
buf_countdeps(struct buf *bp, int i)
|
|
|
|
{
|
|
|
|
if (bioops.io_countdeps)
|
|
|
|
return ((*bioops.io_countdeps)(bp, i));
|
|
|
|
else
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1999-06-26 14:25:03 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Zero out the buffer's data area.
|
|
|
|
*/
|
|
|
|
#define clrbuf(bp) { \
|
1995-12-28 23:34:30 +00:00
|
|
|
bzero((bp)->b_data, (u_int)(bp)->b_bcount); \
|
1994-05-24 10:09:53 +00:00
|
|
|
(bp)->b_resid = 0; \
|
|
|
|
}
|
|
|
|
|
2003-03-04 00:04:44 +00:00
|
|
|
/*
|
|
|
|
* Flags for getblk's last parameter.
|
|
|
|
*/
|
|
|
|
#define GB_LOCK_NOWAIT 0x0001 /* Fail if we block on a buf lock. */
|
2003-08-31 08:50:11 +00:00
|
|
|
#define GB_NOCREAT 0x0002 /* Don't create a buf if not found. */
|
Implement the concept of the unmapped VMIO buffers, i.e. buffers which
do not map the b_pages pages into buffer_map KVA. The use of the
unmapped buffers eliminate the need to perform TLB shootdown for
mapping on the buffer creation and reuse, greatly reducing the amount
of IPIs for shootdown on big-SMP machines and eliminating up to 25-30%
of the system time on i/o intensive workloads.
The unmapped buffer should be explicitely requested by the GB_UNMAPPED
flag by the consumer. For unmapped buffer, no KVA reservation is
performed at all. The consumer might request unmapped buffer which
does have a KVA reserve, to manually map it without recursing into
buffer cache and blocking, with the GB_KVAALLOC flag.
When the mapped buffer is requested and unmapped buffer already
exists, the cache performs an upgrade, possibly reusing the KVA
reservation.
Unmapped buffer is translated into unmapped bio in g_vfs_strategy().
Unmapped bio carry a pointer to the vm_page_t array, offset and length
instead of the data pointer. The provider which processes the bio
should explicitely specify a readiness to accept unmapped bio,
otherwise g_down geom thread performs the transient upgrade of the bio
request by mapping the pages into the new bio_transient_map KVA
submap.
The bio_transient_map submap claims up to 10% of the buffer map, and
the total buffer_map + bio_transient_map KVA usage stays the
same. Still, it could be manually tuned by kern.bio_transient_maxcnt
tunable, in the units of the transient mappings. Eventually, the
bio_transient_map could be removed after all geom classes and drivers
can accept unmapped i/o requests.
Unmapped support can be turned off by the vfs.unmapped_buf_allowed
tunable, disabling which makes the buffer (or cluster) creation
requests to ignore GB_UNMAPPED and GB_KVAALLOC flags. Unmapped
buffers are only enabled by default on the architectures where
pmap_copy_page() was implemented and tested.
In the rework, filesystem metadata is not the subject to maxbufspace
limit anymore. Since the metadata buffers are always mapped, the
buffers still have to fit into the buffer map, which provides a
reasonable (but practically unreachable) upper bound on it. The
non-metadata buffer allocations, both mapped and unmapped, is
accounted against maxbufspace, as before. Effectively, this means that
the maxbufspace is forced on mapped and unmapped buffers separately.
The pre-patch bufspace limiting code did not worked, because
buffer_map fragmentation does not allow the limit to be reached.
By Jeff Roberson request, the getnewbuf() function was split into
smaller single-purpose functions.
Sponsored by: The FreeBSD Foundation
Discussed with: jeff (previous version)
Tested by: pho, scottl (previous version), jhb, bf
MFC after: 2 weeks
2013-03-19 14:13:12 +00:00
|
|
|
#define GB_NOWAIT_BD 0x0004 /* Do not wait for bufdaemon. */
|
|
|
|
#define GB_UNMAPPED 0x0008 /* Do not mmap buffer pages. */
|
|
|
|
#define GB_KVAALLOC 0x0010 /* But allocate KVA. */
|
2003-03-04 00:04:44 +00:00
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1994-08-18 22:36:09 +00:00
|
|
|
extern int nbuf; /* The number of buffer headers */
|
Adjust some variables (mostly related to the buffer cache) that hold
address space sizes to be longs instead of ints. Specifically, the follow
values are now longs: runningbufspace, bufspace, maxbufspace,
bufmallocspace, maxbufmallocspace, lobufspace, hibufspace, lorunningspace,
hirunningspace, maxswzone, maxbcache, and maxpipekva. Previously, a
relatively small number (~ 44000) of buffers set in kern.nbuf would result
in integer overflows resulting either in hangs or bogus values of
hidirtybuffers and lodirtybuffers. Now one has to overflow a long to see
such problems. There was a check for a nbuf setting that would cause
overflows in the auto-tuning of nbuf. I've changed it to always check and
cap nbuf but warn if a user-supplied tunable would cause overflow.
Note that this changes the ABI of several sysctls that are used by things
like top(1), etc., so any MFC would probably require a some gross shims
to allow for that.
MFC after: 1 month
2009-03-09 19:35:20 +00:00
|
|
|
extern long maxswzone; /* Max KVA for swap structures */
|
|
|
|
extern long maxbcache; /* Max KVA for buffer cache */
|
|
|
|
extern long runningbufspace;
|
|
|
|
extern long hibufspace;
|
Cylinder group bitmaps and blocks containing inode for a snapshot
file are after snaplock, while other ffs device buffers are before
snaplock in global lock order. By itself, this could cause deadlock
when bdwrite() tries to flush dirty buffers on snapshotted ffs. If,
during the flush, COW activity for snapshot needs to allocate block
and ffs_alloccg() selects the cylinder group that is being written
by bdwrite(), then kernel would panic due to recursive buffer lock
acquision.
Avoid dealing with buffers in bdwrite() that are from other side of
snaplock divisor in the lock order then the buffer being written. Add
new BOP, bop_bdwrite(), to do dirty buffer flushing for same vnode in
the bdwrite(). Default implementation, bufbdflush(), refactors the code
from bdwrite(). For ffs device buffers, specialized implementation is
used.
Reviewed by: tegge, jeff, Russell Cattelan (cattelan xfs org, xfs changes)
Tested by: Peter Holm
X-MFC after: 3 weeks (if ever: it changes ABI)
2007-01-23 10:01:19 +00:00
|
|
|
extern int dirtybufthresh;
|
|
|
|
extern int bdwriteskip;
|
|
|
|
extern int dirtybufferflushes;
|
|
|
|
extern int altbufferflushes;
|
1994-08-18 22:36:09 +00:00
|
|
|
extern struct buf *buf; /* The buffer headers. */
|
|
|
|
extern struct buf *swbuf; /* Swap I/O buffer headers. */
|
|
|
|
extern int nswbuf; /* Number of swap I/O buffer headers. */
|
2005-08-13 20:21:33 +00:00
|
|
|
extern int cluster_pbuf_freecnt; /* Number of pbufs for clusters */
|
|
|
|
extern int vnode_pbuf_freecnt; /* Number of pbufs for vnode pager */
|
Implement the concept of the unmapped VMIO buffers, i.e. buffers which
do not map the b_pages pages into buffer_map KVA. The use of the
unmapped buffers eliminate the need to perform TLB shootdown for
mapping on the buffer creation and reuse, greatly reducing the amount
of IPIs for shootdown on big-SMP machines and eliminating up to 25-30%
of the system time on i/o intensive workloads.
The unmapped buffer should be explicitely requested by the GB_UNMAPPED
flag by the consumer. For unmapped buffer, no KVA reservation is
performed at all. The consumer might request unmapped buffer which
does have a KVA reserve, to manually map it without recursing into
buffer cache and blocking, with the GB_KVAALLOC flag.
When the mapped buffer is requested and unmapped buffer already
exists, the cache performs an upgrade, possibly reusing the KVA
reservation.
Unmapped buffer is translated into unmapped bio in g_vfs_strategy().
Unmapped bio carry a pointer to the vm_page_t array, offset and length
instead of the data pointer. The provider which processes the bio
should explicitely specify a readiness to accept unmapped bio,
otherwise g_down geom thread performs the transient upgrade of the bio
request by mapping the pages into the new bio_transient_map KVA
submap.
The bio_transient_map submap claims up to 10% of the buffer map, and
the total buffer_map + bio_transient_map KVA usage stays the
same. Still, it could be manually tuned by kern.bio_transient_maxcnt
tunable, in the units of the transient mappings. Eventually, the
bio_transient_map could be removed after all geom classes and drivers
can accept unmapped i/o requests.
Unmapped support can be turned off by the vfs.unmapped_buf_allowed
tunable, disabling which makes the buffer (or cluster) creation
requests to ignore GB_UNMAPPED and GB_KVAALLOC flags. Unmapped
buffers are only enabled by default on the architectures where
pmap_copy_page() was implemented and tested.
In the rework, filesystem metadata is not the subject to maxbufspace
limit anymore. Since the metadata buffers are always mapped, the
buffers still have to fit into the buffer map, which provides a
reasonable (but practically unreachable) upper bound on it. The
non-metadata buffer allocations, both mapped and unmapped, is
accounted against maxbufspace, as before. Effectively, this means that
the maxbufspace is forced on mapped and unmapped buffers separately.
The pre-patch bufspace limiting code did not worked, because
buffer_map fragmentation does not allow the limit to be reached.
By Jeff Roberson request, the getnewbuf() function was split into
smaller single-purpose functions.
Sponsored by: The FreeBSD Foundation
Discussed with: jeff (previous version)
Tested by: pho, scottl (previous version), jhb, bf
MFC after: 2 weeks
2013-03-19 14:13:12 +00:00
|
|
|
extern caddr_t unmapped_buf;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2005-09-30 01:30:01 +00:00
|
|
|
void runningbufwakeup(struct buf *);
|
2005-09-30 18:07:41 +00:00
|
|
|
void waitrunningbufspace(void);
|
2002-08-30 04:04:37 +00:00
|
|
|
caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est);
|
2002-03-19 20:18:42 +00:00
|
|
|
void bufinit(void);
|
Implement the concept of the unmapped VMIO buffers, i.e. buffers which
do not map the b_pages pages into buffer_map KVA. The use of the
unmapped buffers eliminate the need to perform TLB shootdown for
mapping on the buffer creation and reuse, greatly reducing the amount
of IPIs for shootdown on big-SMP machines and eliminating up to 25-30%
of the system time on i/o intensive workloads.
The unmapped buffer should be explicitely requested by the GB_UNMAPPED
flag by the consumer. For unmapped buffer, no KVA reservation is
performed at all. The consumer might request unmapped buffer which
does have a KVA reserve, to manually map it without recursing into
buffer cache and blocking, with the GB_KVAALLOC flag.
When the mapped buffer is requested and unmapped buffer already
exists, the cache performs an upgrade, possibly reusing the KVA
reservation.
Unmapped buffer is translated into unmapped bio in g_vfs_strategy().
Unmapped bio carry a pointer to the vm_page_t array, offset and length
instead of the data pointer. The provider which processes the bio
should explicitely specify a readiness to accept unmapped bio,
otherwise g_down geom thread performs the transient upgrade of the bio
request by mapping the pages into the new bio_transient_map KVA
submap.
The bio_transient_map submap claims up to 10% of the buffer map, and
the total buffer_map + bio_transient_map KVA usage stays the
same. Still, it could be manually tuned by kern.bio_transient_maxcnt
tunable, in the units of the transient mappings. Eventually, the
bio_transient_map could be removed after all geom classes and drivers
can accept unmapped i/o requests.
Unmapped support can be turned off by the vfs.unmapped_buf_allowed
tunable, disabling which makes the buffer (or cluster) creation
requests to ignore GB_UNMAPPED and GB_KVAALLOC flags. Unmapped
buffers are only enabled by default on the architectures where
pmap_copy_page() was implemented and tested.
In the rework, filesystem metadata is not the subject to maxbufspace
limit anymore. Since the metadata buffers are always mapped, the
buffers still have to fit into the buffer map, which provides a
reasonable (but practically unreachable) upper bound on it. The
non-metadata buffer allocations, both mapped and unmapped, is
accounted against maxbufspace, as before. Effectively, this means that
the maxbufspace is forced on mapped and unmapped buffers separately.
The pre-patch bufspace limiting code did not worked, because
buffer_map fragmentation does not allow the limit to be reached.
By Jeff Roberson request, the getnewbuf() function was split into
smaller single-purpose functions.
Sponsored by: The FreeBSD Foundation
Discussed with: jeff (previous version)
Tested by: pho, scottl (previous version), jhb, bf
MFC after: 2 weeks
2013-03-19 14:13:12 +00:00
|
|
|
void bdata2bio(struct buf *bp, struct bio *bip);
|
2002-03-19 20:18:42 +00:00
|
|
|
void bwillwrite(void);
|
|
|
|
int buf_dirty_count_severe(void);
|
|
|
|
void bremfree(struct buf *);
|
2004-11-18 08:44:09 +00:00
|
|
|
void bremfreef(struct buf *); /* XXX Force bremfree, only for nfs. */
|
2012-03-01 18:45:25 +00:00
|
|
|
#define bread(vp, blkno, size, cred, bpp) \
|
2013-03-19 13:21:39 +00:00
|
|
|
breadn_flags(vp, blkno, size, NULL, NULL, 0, cred, 0, bpp)
|
|
|
|
#define bread_gb(vp, blkno, size, cred, gbflags, bpp) \
|
|
|
|
breadn_flags(vp, blkno, size, NULL, NULL, 0, cred, \
|
|
|
|
gbflags, bpp)
|
2012-03-01 18:45:25 +00:00
|
|
|
#define breadn(vp, blkno, size, rablkno, rabsize, cnt, cred, bpp) \
|
|
|
|
breadn_flags(vp, blkno, size, rablkno, rabsize, cnt, cred, 0, bpp)
|
|
|
|
int breadn_flags(struct vnode *, daddr_t, int, daddr_t *, int *, int,
|
|
|
|
struct ucred *, int, struct buf **);
|
2005-12-07 03:39:08 +00:00
|
|
|
void breada(struct vnode *, daddr_t *, int *, int, struct ucred *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void bdwrite(struct buf *);
|
|
|
|
void bawrite(struct buf *);
|
2013-02-16 14:51:30 +00:00
|
|
|
void babarrierwrite(struct buf *);
|
|
|
|
int bbarrierwrite(struct buf *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void bdirty(struct buf *);
|
|
|
|
void bundirty(struct buf *);
|
2004-10-24 20:03:41 +00:00
|
|
|
void bufstrategy(struct bufobj *, struct buf *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void brelse(struct buf *);
|
|
|
|
void bqrelse(struct buf *);
|
|
|
|
int vfs_bio_awrite(struct buf *);
|
|
|
|
struct buf * getpbuf(int *);
|
2004-10-22 08:47:20 +00:00
|
|
|
struct buf *incore(struct bufobj *, daddr_t);
|
|
|
|
struct buf *gbincore(struct bufobj *, daddr_t);
|
2003-03-04 00:04:44 +00:00
|
|
|
struct buf *getblk(struct vnode *, daddr_t, int, int, int, int);
|
Fix two issues with bufdaemon, often causing the processes to hang in
the "nbufkv" sleep.
First, ffs background cg group block write requests a new buffer for
the shadow copy. When ffs_bufwrite() is called from the bufdaemon due
to buffers shortage, requesting the buffer deadlock bufdaemon.
Introduce a new flag for getnewbuf(), GB_NOWAIT_BD, to request getblk
to not block while allocating the buffer, and return failure
instead. Add a flag argument to the geteblk to allow to pass the flags
to getblk(). Do not repeat the getnewbuf() call from geteblk if buffer
allocation failed and either GB_NOWAIT_BD is specified, or geteblk()
is called from bufdaemon (or its helper, see below). In
ffs_bufwrite(), fall back to synchronous cg block write if shadow
block allocation failed.
Since r107847, buffer write assumes that vnode owning the buffer is
locked. The second problem is that buffer cache may accumulate many
buffers belonging to limited number of vnodes. With such workload,
quite often threads that own the mentioned vnodes locks are trying to
read another block from the vnodes, and, due to buffer cache
exhaustion, are asking bufdaemon for help. Bufdaemon is unable to make
any substantial progress because the vnodes are locked.
Allow the threads owning vnode locks to help the bufdaemon by doing
the flush pass over the buffer cache before getnewbuf() is going to
uninterruptible sleep. Move the flushing code from buf_daemon() to new
helper function buf_do_flush(), that is called from getnewbuf(). The
number of buffers flushed by single call to buf_do_flush() from
getnewbuf() is limited by new sysctl vfs.flushbufqtarget. Prevent
recursive calls to buf_do_flush() by marking the bufdaemon and threads
that temporarily help bufdaemon by TDP_BUFNEED flag.
In collaboration with: pho
Reviewed by: tegge (previous version)
Tested by: glebius, yandex ...
MFC after: 3 weeks
2009-03-16 15:39:46 +00:00
|
|
|
struct buf *geteblk(int, int);
|
2002-03-19 20:18:42 +00:00
|
|
|
int bufwait(struct buf *);
|
2004-10-24 20:03:41 +00:00
|
|
|
int bufwrite(struct buf *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void bufdone(struct buf *);
|
2005-12-07 03:39:08 +00:00
|
|
|
void bufdone_finish(struct buf *);
|
2010-04-24 07:05:35 +00:00
|
|
|
void bd_speedup(void);
|
2002-03-19 20:18:42 +00:00
|
|
|
|
|
|
|
int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
|
2013-03-14 20:28:26 +00:00
|
|
|
struct ucred *, long, int, int, struct buf **);
|
|
|
|
int cluster_wbuild(struct vnode *, long, daddr_t, int, int);
|
|
|
|
void cluster_write(struct vnode *, struct buf *, u_quad_t, int, int);
|
2013-03-19 14:27:14 +00:00
|
|
|
void vfs_bio_bzero_buf(struct buf *bp, int base, int size);
|
2009-05-17 20:26:00 +00:00
|
|
|
void vfs_bio_set_valid(struct buf *, int base, int size);
|
2002-03-19 20:18:42 +00:00
|
|
|
void vfs_bio_clrbuf(struct buf *);
|
|
|
|
void vfs_busy_pages(struct buf *, int clear_modify);
|
|
|
|
void vfs_unbusy_pages(struct buf *);
|
2013-03-19 14:43:57 +00:00
|
|
|
int vmapbuf(struct buf *, int);
|
2002-03-19 20:18:42 +00:00
|
|
|
void vunmapbuf(struct buf *);
|
|
|
|
void relpbuf(struct buf *, int *);
|
2008-03-28 12:30:12 +00:00
|
|
|
void brelvp(struct buf *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void bgetvp(struct vnode *, struct buf *);
|
2004-11-15 08:47:18 +00:00
|
|
|
void pbgetbo(struct bufobj *bo, struct buf *bp);
|
2002-03-19 20:18:42 +00:00
|
|
|
void pbgetvp(struct vnode *, struct buf *);
|
2004-11-15 08:47:18 +00:00
|
|
|
void pbrelbo(struct buf *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void pbrelvp(struct buf *);
|
|
|
|
int allocbuf(struct buf *bp, int size);
|
2004-07-25 21:24:23 +00:00
|
|
|
void reassignbuf(struct buf *);
|
2002-03-19 20:18:42 +00:00
|
|
|
struct buf *trypbuf(int *);
|
2003-03-13 07:31:45 +00:00
|
|
|
void bwait(struct buf *, u_char, const char *);
|
|
|
|
void bdone(struct buf *);
|
2005-12-07 03:39:08 +00:00
|
|
|
void bpin(struct buf *);
|
|
|
|
void bunpin(struct buf *);
|
|
|
|
void bunpin_wait(struct buf *);
|
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>
1999-05-02 23:57:16 +00:00
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1996-05-01 02:16:17 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#endif /* !_SYS_BUF_H_ */
|