This source file includes following definitions.
- buf_start
- buf_complete
- buf_deallocate
- buf_movedeps
- buf_countdeps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #ifndef _SYS_BUF_H_
41 #define _SYS_BUF_H_
42 #include <sys/queue.h>
43
44 #define NOLIST ((struct buf *)0x87654321)
45
46 struct buf;
47 struct vnode;
48
49 LIST_HEAD(bufhead, buf);
50
51
52
53
54
55 LIST_HEAD(workhead, worklist);
56
57
58
59
60
61
62
63 extern struct bio_ops {
64 void (*io_start)(struct buf *);
65 void (*io_complete)(struct buf *);
66 void (*io_deallocate)(struct buf *);
67 void (*io_movedeps)(struct buf *, struct buf *);
68 int (*io_countdeps)(struct buf *, int, int);
69 } bioops;
70
71
72
73
74 struct buf {
75 LIST_ENTRY(buf) b_list;
76 LIST_ENTRY(buf) b_hash;
77 LIST_ENTRY(buf) b_vnbufs;
78 TAILQ_ENTRY(buf) b_freelist;
79 time_t b_synctime;
80 struct buf *b_actf, **b_actb;
81 struct proc *b_proc;
82 volatile long b_flags;
83 int b_error;
84 long b_bufsize;
85 long b_bcount;
86 size_t b_resid;
87 dev_t b_dev;
88 caddr_t b_data;
89 void *b_saveaddr;
90 daddr64_t b_lblkno;
91 daddr64_t b_blkno;
92
93
94 void (*b_iodone)(struct buf *);
95 struct vnode *b_vp;
96 int b_dirtyoff;
97 int b_dirtyend;
98 int b_validoff;
99 int b_validend;
100 struct workhead b_dep;
101 };
102
103
104
105
106
107 struct bufq {
108 void (*bufq_free)(struct bufq *);
109 void (*bufq_add)(struct bufq *, struct buf *);
110 struct buf *(*bufq_get)(struct bufq *);
111 };
112
113 struct bufq_default {
114 struct bufq bufq;
115 struct buf bufq_head[3];
116 };
117
118 #define BUFQ_ALLOC(_type) bufq_default_alloc()
119 #define BUFQ_FREE(_bufq) (_bufq)->bufq_free(_bufq)
120 #define BUFQ_ADD(_bufq, _bp) (_bufq)->bufq_add(_bufq, _bp)
121 #define BUFQ_GET(_bufq) (_bufq)->bufq_get(_bufq)
122
123 struct bufq *bufq_default_alloc(void);
124 void bufq_default_free(struct bufq *);
125 void bufq_default_add(struct bufq *, struct buf *);
126 struct buf *bufq_default_get(struct bufq *);
127
128
129
130
131
132 #define b_cylinder b_resid
133
134
135 #define b_active b_bcount
136 #define b_errcnt b_resid
137
138
139
140
141 #define B_AGE 0x00000001
142 #define B_NEEDCOMMIT 0x00000002
143 #define B_ASYNC 0x00000004
144 #define B_BAD 0x00000008
145 #define B_BUSY 0x00000010
146 #define B_CACHE 0x00000020
147 #define B_CALL 0x00000040
148 #define B_DELWRI 0x00000080
149 #define B_DONE 0x00000200
150 #define B_EINTR 0x00000400
151 #define B_ERROR 0x00000800
152 #define B_INVAL 0x00002000
153 #define B_NOCACHE 0x00008000
154 #define B_PHYS 0x00040000
155 #define B_RAW 0x00080000
156 #define B_READ 0x00100000
157 #define B_WANTED 0x00800000
158 #define B_WRITE 0x00000000
159 #define B_WRITEINPROG 0x01000000
160 #define B_XXX 0x02000000
161 #define B_DEFERRED 0x04000000
162 #define B_SCANNED 0x08000000
163 #define B_PDAEMON 0x10000000
164
165 #define B_BITS "\010\001AGE\002NEEDCOMMIT\003ASYNC\004BAD\005BUSY\006CACHE" \
166 "\007CALL\010DELWRI\012DONE\013EINTR\014ERROR" \
167 "\016INVAL\020NOCACHE\023PHYS\024RAW\025READ" \
168 "\030WANTED\031WRITEINPROG\032XXX\033DEFERRED" \
169 "\034SCANNED\035PDAEMON"
170
171
172
173
174
175
176
177 struct cluster_save {
178 long bs_bcount;
179 long bs_bufsize;
180 void *bs_saveaddr;
181 int bs_nchildren;
182 struct buf **bs_children;
183 };
184
185
186
187
188 #define clrbuf(bp) { \
189 bzero((bp)->b_data, (u_int)(bp)->b_bcount); \
190 (bp)->b_resid = 0; \
191 }
192
193
194
195 #define B_CLRBUF 0x01
196 #define B_SYNC 0x02
197
198 struct cluster_info {
199 daddr64_t ci_lastr;
200 daddr64_t ci_lastw;
201 daddr64_t ci_cstart;
202 daddr64_t ci_lasta;
203 int ci_clen;
204 int ci_ralen;
205 daddr64_t ci_maxra;
206 };
207
208 #ifdef _KERNEL
209 __BEGIN_DECLS
210 extern int bufpages;
211 extern struct pool bufpool;
212 extern struct bufhead bufhead;
213
214 void bawrite(struct buf *);
215 void bdwrite(struct buf *);
216 void biodone(struct buf *);
217 int biowait(struct buf *);
218 int bread(struct vnode *, daddr64_t, int, struct ucred *, struct buf **);
219 int breadn(struct vnode *, daddr64_t, int, daddr64_t *, int *, int,
220 struct ucred *, struct buf **);
221 void brelse(struct buf *);
222 void bremfree(struct buf *);
223 void bufinit(void);
224 void buf_dirty(struct buf *);
225 void buf_undirty(struct buf *);
226 int bwrite(struct buf *);
227 struct buf *getblk(struct vnode *, daddr64_t, int, int, int);
228 struct buf *geteblk(int);
229 struct buf *incore(struct vnode *, daddr64_t);
230
231 void minphys(struct buf *bp);
232 int physio(void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
233 int flags, void (*minphys)(struct buf *), struct uio *uio);
234 void brelvp(struct buf *);
235 void reassignbuf(struct buf *);
236 void bgetvp(struct vnode *, struct buf *);
237
238 void buf_replacevnode(struct buf *, struct vnode *);
239 void buf_daemon(struct proc *);
240 void buf_replacevnode(struct buf *, struct vnode *);
241 void buf_daemon(struct proc *);
242 int bread_cluster(struct vnode *, daddr64_t, int, struct buf **);
243
244 #ifdef DEBUG
245 void buf_print(struct buf *);
246 #endif
247
248 static __inline void
249 buf_start(struct buf *bp)
250 {
251 if (bioops.io_start)
252 (*bioops.io_start)(bp);
253 }
254
255 static __inline void
256 buf_complete(struct buf *bp)
257 {
258 if (bioops.io_complete)
259 (*bioops.io_complete)(bp);
260 }
261
262 static __inline void
263 buf_deallocate(struct buf *bp)
264 {
265 if (bioops.io_deallocate)
266 (*bioops.io_deallocate)(bp);
267 }
268
269 static __inline void
270 buf_movedeps(struct buf *bp, struct buf *bp2)
271 {
272 if (bioops.io_movedeps)
273 (*bioops.io_movedeps)(bp, bp2);
274 }
275
276 static __inline int
277 buf_countdeps(struct buf *bp, int i, int islocked)
278 {
279 if (bioops.io_countdeps)
280 return ((*bioops.io_countdeps)(bp, i, islocked));
281 else
282 return (0);
283 }
284
285 void cluster_write(struct buf *, struct cluster_info *, u_quad_t);
286
287 __END_DECLS
288 #endif
289 #endif