Deleted Added
full compact
buf.h (58926) buf.h (58934)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)buf.h 8.9 (Berkeley) 3/30/95
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)buf.h 8.9 (Berkeley) 3/30/95
39 * $FreeBSD: head/sys/sys/buf.h 58926 2000-04-02 09:26:51Z phk $
39 * $FreeBSD: head/sys/sys/buf.h 58934 2000-04-02 15:24:56Z phk $
40 */
41
42#ifndef _SYS_BUF_H_
43#define _SYS_BUF_H_
44
45#include <sys/queue.h>
46#include <sys/lock.h>
47

--- 27 unchanged lines hidden (view full) ---

75 void *ic_prev_iodone_chain;
76 struct {
77 long ia_long;
78 void *ia_ptr;
79 } ic_args[5];
80};
81
82/*
40 */
41
42#ifndef _SYS_BUF_H_
43#define _SYS_BUF_H_
44
45#include <sys/queue.h>
46#include <sys/lock.h>
47

--- 27 unchanged lines hidden (view full) ---

75 void *ic_prev_iodone_chain;
76 struct {
77 long ia_long;
78 void *ia_ptr;
79 } ic_args[5];
80};
81
82/*
83 * The bio structure descripes an I/O operation in the kernel.
83 * The bio structure describes an I/O operation in the kernel.
84 */
84 */
85
86struct bio {
85struct bio {
87 u_int bio_cmd; /* BIO_READ, BIO_WRITE, BIO_DELETE */
88 dev_t bio_dev; /* Device to do I/O on */
86 u_int bio_cmd; /* I/O operation. */
87 dev_t bio_dev; /* Device to do I/O on. */
89 daddr_t bio_blkno; /* Underlying physical block number. */
88 daddr_t bio_blkno; /* Underlying physical block number. */
90 u_int bio_flags; /* BIO_ORDERED, BIO_ERROR */
91 struct buf *__bio_buf; /* Parent buffer */
92 int bio_error; /* Errno for BIO_ERROR */
93 long bio_resid; /* Remaining I/0 in bytes */
89 u_int bio_flags; /* BIO_ flags. */
90 struct buf *_bio_buf; /* Parent buffer. */
91 int bio_error; /* Errno for BIO_ERROR. */
92 long bio_resid; /* Remaining I/0 in bytes. */
94 void (*bio_done) __P((struct buf *));
93 void (*bio_done) __P((struct buf *));
95 void *bio_driver1; /* for private use by the driver */
96 void *bio_driver2; /* for private use by the driver */
97 void *bio_caller1; /* for private use by the caller */
98 void *bio_caller2; /* for private use by the caller */
94 void *bio_driver1; /* Private use by the callee. */
95 void *bio_driver2; /* Private use by the callee. */
96 void *bio_caller1; /* Private use by the caller. */
97 void *bio_caller2; /* Private use by the caller. */
98 TAILQ_ENTRY(bio) bio_queue; /* Disksort queue. */
99
100 /* XXX: these go away when bio chaining is introduced */
101 daddr_t bio_pblkno; /* physical block number */
102 struct iodone_chain *bio_done_chain;
99};
100
101/*
102 * The buffer header describes an I/O operation in the kernel.
103 *
104 * NOTES:
105 * b_bufsize, b_bcount. b_bufsize is the allocation size of the
106 * buffer, either DEV_BSIZE or PAGE_SIZE aligned. b_bcount is the
107 * originally requested buffer size and can serve as a bounds check
108 * against EOF. For most, but not all uses, b_bcount == b_bufsize.
109 *
110 * b_dirtyoff, b_dirtyend. Buffers support piecemeal, unaligned
111 * ranges of dirty data that need to be written to backing store.
112 * The range is typically clipped at b_bcount ( not b_bufsize ).
113 *
114 * b_resid. Number of bytes remaining in I/O. After an I/O operation
115 * completes, b_resid is usually 0 indicating 100% success.
116 */
117struct buf {
103};
104
105/*
106 * The buffer header describes an I/O operation in the kernel.
107 *
108 * NOTES:
109 * b_bufsize, b_bcount. b_bufsize is the allocation size of the
110 * buffer, either DEV_BSIZE or PAGE_SIZE aligned. b_bcount is the
111 * originally requested buffer size and can serve as a bounds check
112 * against EOF. For most, but not all uses, b_bcount == b_bufsize.
113 *
114 * b_dirtyoff, b_dirtyend. Buffers support piecemeal, unaligned
115 * ranges of dirty data that need to be written to backing store.
116 * The range is typically clipped at b_bcount ( not b_bufsize ).
117 *
118 * b_resid. Number of bytes remaining in I/O. After an I/O operation
119 * completes, b_resid is usually 0 indicating 100% success.
120 */
121struct buf {
118 struct bio b_bio; /* I/O request
119 * XXX: Must be first element for now
120 */
121#define b_iocmd b_bio.bio_cmd
122#define b_ioflags b_bio.bio_flags
123#define b_iodone b_bio.bio_done
124#define b_error b_bio.bio_error
125#define b_resid b_bio.bio_resid
126#define b_blkno b_bio.bio_blkno
127#define b_driver1 b_bio.bio_driver1
128#define b_driver2 b_bio.bio_driver2
129#define b_caller1 b_bio.bio_caller1
130#define b_caller2 b_bio.bio_caller2
131#define b_dev b_bio.bio_dev
122 /* XXX: b_io must be the first element of struct buf for now /phk */
123 struct bio b_io; /* "Builtin" I/O request. */
124#define b_blkno b_io.bio_blkno
125#define b_caller1 b_io.bio_caller1
126#define b_caller2 b_io.bio_caller2
127#define b_dev b_io.bio_dev
128#define b_driver1 b_io.bio_driver1
129#define b_driver2 b_io.bio_driver2
130#define b_error b_io.bio_error
131#define b_iocmd b_io.bio_cmd
132#define b_iodone b_io.bio_done
133#define b_iodone_chain b_io.bio_done_chain
134#define b_ioflags b_io.bio_flags
135#define b_pblkno b_io.bio_pblkno
136#define b_resid b_io.bio_resid
132 LIST_ENTRY(buf) b_hash; /* Hash chain. */
133 TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
134 TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
135 TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
136 long b_flags; /* B_* flags. */
137 unsigned short b_qindex; /* buffer queue index */
138 unsigned char b_xflags; /* extra flags */
139 struct lock b_lock; /* Buffer lock */
140 long b_bufsize; /* Allocated buffer size. */
141 long b_bcount; /* Valid bytes in buffer. */
142 caddr_t b_data; /* Memory, superblocks, indirect etc. */
143 caddr_t b_kvabase; /* base kva for buffer */
144 int b_kvasize; /* size of kva for buffer */
145 daddr_t b_lblkno; /* Logical block number. */
146 off_t b_offset; /* Offset into file */
137 LIST_ENTRY(buf) b_hash; /* Hash chain. */
138 TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
139 TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
140 TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
141 long b_flags; /* B_* flags. */
142 unsigned short b_qindex; /* buffer queue index */
143 unsigned char b_xflags; /* extra flags */
144 struct lock b_lock; /* Buffer lock */
145 long b_bufsize; /* Allocated buffer size. */
146 long b_bcount; /* Valid bytes in buffer. */
147 caddr_t b_data; /* Memory, superblocks, indirect etc. */
148 caddr_t b_kvabase; /* base kva for buffer */
149 int b_kvasize; /* size of kva for buffer */
150 daddr_t b_lblkno; /* Logical block number. */
151 off_t b_offset; /* Offset into file */
147 /* Function to call upon completion. */
148 struct iodone_chain *b_iodone_chain;
149 struct vnode *b_vp; /* Device vnode. */
150 int b_dirtyoff; /* Offset in buffer of dirty region. */
151 int b_dirtyend; /* Offset of end of dirty region. */
152 struct ucred *b_rcred; /* Read credentials reference. */
153 struct ucred *b_wcred; /* Write credentials reference. */
152 struct vnode *b_vp; /* Device vnode. */
153 int b_dirtyoff; /* Offset in buffer of dirty region. */
154 int b_dirtyend; /* Offset of end of dirty region. */
155 struct ucred *b_rcred; /* Read credentials reference. */
156 struct ucred *b_wcred; /* Write credentials reference. */
154 daddr_t b_pblkno; /* physical block number */
155 void *b_saveaddr; /* Original b_addr for physio. */
156 union pager_info {
157 void *pg_spc;
158 int pg_reqpage;
159 } b_pager;
160 union cluster_info {
161 TAILQ_HEAD(cluster_list_head, buf) cluster_head;
162 TAILQ_ENTRY(buf) cluster_entry;

--- 24 unchanged lines hidden (view full) ---

187 * the b_vp's clean/dirty linked lists or ref counts.
188 * Buffer vp reassignments are illegal in this case.
189 *
190 * B_CACHE This may only be set if the buffer is entirely valid.
191 * The situation where B_DELWRI is set and B_CACHE is
192 * clear MUST be committed to disk by getblk() so
193 * B_DELWRI can also be cleared. See the comments for
194 * getblk() in kern/vfs_bio.c. If B_CACHE is clear,
157 void *b_saveaddr; /* Original b_addr for physio. */
158 union pager_info {
159 void *pg_spc;
160 int pg_reqpage;
161 } b_pager;
162 union cluster_info {
163 TAILQ_HEAD(cluster_list_head, buf) cluster_head;
164 TAILQ_ENTRY(buf) cluster_entry;

--- 24 unchanged lines hidden (view full) ---

189 * the b_vp's clean/dirty linked lists or ref counts.
190 * Buffer vp reassignments are illegal in this case.
191 *
192 * B_CACHE This may only be set if the buffer is entirely valid.
193 * The situation where B_DELWRI is set and B_CACHE is
194 * clear MUST be committed to disk by getblk() so
195 * B_DELWRI can also be cleared. See the comments for
196 * getblk() in kern/vfs_bio.c. If B_CACHE is clear,
195 * the caller is expected to clear B_ERROR|B_INVAL,
197 * the caller is expected to clear BIO_ERROR and B_INVAL,
196 * set BIO_READ, and initiate an I/O.
197 *
198 * The 'entire buffer' is defined to be the range from
199 * 0 through b_bcount.
200 *
201 * B_MALLOC Request that the buffer be allocated from the malloc
202 * pool, DEV_BSIZE aligned instead of PAGE_SIZE aligned.
203 *

--- 10 unchanged lines hidden (view full) ---

214 * always at least DEV_BSIZE aligned, though ).
215 *
216 */
217
218#define BIO_READ 1
219#define BIO_WRITE 2
220#define BIO_DELETE 4
221
198 * set BIO_READ, and initiate an I/O.
199 *
200 * The 'entire buffer' is defined to be the range from
201 * 0 through b_bcount.
202 *
203 * B_MALLOC Request that the buffer be allocated from the malloc
204 * pool, DEV_BSIZE aligned instead of PAGE_SIZE aligned.
205 *

--- 10 unchanged lines hidden (view full) ---

216 * always at least DEV_BSIZE aligned, though ).
217 *
218 */
219
220#define BIO_READ 1
221#define BIO_WRITE 2
222#define BIO_DELETE 4
223
224#define BIO_ERROR 0x00000001
225#define BIO_ORDERED 0x00000002
226
222#define B_AGE 0x00000001 /* Move to age queue when I/O done. */
223#define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */
224#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
225#define B_UNUSED0 0x00000008 /* Old B_BAD */
226#define B_DEFERRED 0x00000010 /* Skipped over for cleaning */
227#define B_CACHE 0x00000020 /* Bread found us in the cache. */
228#define B_UNUSED40 0x00000040 /* Old B_CALL */
229#define B_DELWRI 0x00000080 /* Delay I/O until buffer reused. */

--- 182 unchanged lines hidden (view full) ---

412 head->last_pblkno = 0;
413 head->insert_point = NULL;
414 head->switch_point = NULL;
415}
416
417static __inline void
418bufq_insert_tail(struct buf_queue_head *head, struct buf *bp)
419{
227#define B_AGE 0x00000001 /* Move to age queue when I/O done. */
228#define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */
229#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
230#define B_UNUSED0 0x00000008 /* Old B_BAD */
231#define B_DEFERRED 0x00000010 /* Skipped over for cleaning */
232#define B_CACHE 0x00000020 /* Bread found us in the cache. */
233#define B_UNUSED40 0x00000040 /* Old B_CALL */
234#define B_DELWRI 0x00000080 /* Delay I/O until buffer reused. */

--- 182 unchanged lines hidden (view full) ---

417 head->last_pblkno = 0;
418 head->insert_point = NULL;
419 head->switch_point = NULL;
420}
421
422static __inline void
423bufq_insert_tail(struct buf_queue_head *head, struct buf *bp)
424{
420 if ((bp->b_flags & B_ORDERED) != 0) {
425 if ((bp->b_ioflags & BIO_ORDERED) != 0) {
421 head->insert_point = bp;
422 head->switch_point = NULL;
423 }
424 TAILQ_INSERT_TAIL(&head->queue, bp, b_act);
425}
426
427static __inline void
428bufq_remove(struct buf_queue_head *head, struct buf *bp)

--- 116 unchanged lines hidden ---
426 head->insert_point = bp;
427 head->switch_point = NULL;
428 }
429 TAILQ_INSERT_TAIL(&head->queue, bp, b_act);
430}
431
432static __inline void
433bufq_remove(struct buf_queue_head *head, struct buf *bp)

--- 116 unchanged lines hidden ---