Lines Matching defs:fdb

50 static void fdb_zero_holes(fdbuffer_t *fdb);
56 fdbuffer_t *fdb = buf;
58 mutex_init(&fdb->fd_mutex, NULL, MUTEX_DEFAULT, NULL);
67 fdbuffer_t *fdb = buf;
69 mutex_destroy(&fdb->fd_mutex);
81 fdb_prepare(fdbuffer_t *fdb)
83 fdb->fd_holes = NULL;
84 fdb->fd_iofunc = NULL;
85 fdb->fd_iargp = NULL;
86 fdb->fd_parentbp = NULL;
87 fdb->fd_resid = 0;
88 fdb->fd_iocount = 0;
89 fdb->fd_iodispatch = 0;
90 fdb->fd_err = 0;
96 fdbuffer_t *fdb;
104 fdb = kmem_cache_alloc(fdb_cache, KM_SLEEP);
106 fdb_prepare(fdb);
108 fdb->fd_type = FDB_PAGEIO;
109 fdb->fd_len = len;
110 fdb->fd_state = flags;
111 fdb->fd_pages = pp;
113 return (fdb);
124 fdbuffer_t *fdb;
132 fdb = kmem_cache_alloc(fdb_cache, KM_SLEEP);
134 fdb_prepare(fdb);
136 fdb->fd_type = FDB_VADDR;
137 fdb->fd_len = len;
138 fdb->fd_state = flags;
139 fdb->fd_addr = addr;
140 fdb->fd_shadow = pplist;
141 fdb->fd_procp = procp;
143 return (fdb);
147 fdb_set_iofunc(fdbuffer_t *fdb, fdb_iodone_t iofunc, void *ioargp, int flag)
149 ASSERT(fdb);
153 fdb->fd_iofunc = iofunc;
154 fdb->fd_iargp = ioargp;
156 mutex_enter(&fdb->fd_mutex);
159 fdb->fd_state |= FDB_ICALLBACK;
161 fdb->fd_state |= FDB_ASYNC;
163 mutex_exit(&fdb->fd_mutex);
167 fdb_get_error(fdbuffer_t *fdb)
169 return (fdb->fd_err);
173 fdb_free(fdbuffer_t *fdb)
178 (void *)fdb, fdb->fd_state));
180 ASSERT(fdb);
181 ASSERT(fdb->fd_iodispatch == 0);
183 if (fdb->fd_state & FDB_ZEROHOLE) {
184 fdb_zero_holes(fdb);
187 for (fdh = fdb->fd_holes; fdh; ) {
193 if (fdb->fd_parentbp != NULL) {
194 switch (fdb->fd_type) {
196 pageio_done(fdb->fd_parentbp);
199 kmem_free(fdb->fd_parentbp, sizeof (struct buf));
202 cmn_err(CE_CONT, "?fdb_free: Unknown fdb type.");
207 kmem_cache_free(fdb_cache, fdb);
218 fdb_add_hole(fdbuffer_t *fdb, u_offset_t off, size_t len)
222 ASSERT(fdb);
223 ASSERT(off < fdb->fd_len);
232 if (fdb->fd_holes == NULL || off < fdb->fd_holes->off) {
233 this_hole->next_hole = fdb->fd_holes;
234 fdb->fd_holes = this_hole;
236 fdb_holes_t *fdhp = fdb->fd_holes;
245 mutex_enter(&fdb->fd_mutex);
247 fdb->fd_iocount += len;
249 mutex_exit(&fdb->fd_mutex);
253 fdb_get_holes(fdbuffer_t *fdb)
255 ASSERT(fdb);
257 if (fdb->fd_state & FDB_ZEROHOLE) {
258 fdb_zero_holes(fdb);
261 return (fdb->fd_holes);
270 fdb_zero_holes(fdbuffer_t *fdb)
272 fdb_holes_t *fdh = fdb->fd_holes;
275 ASSERT(fdb);
280 switch (fdb->fd_type) {
282 pp = fdb->fd_pages;
330 bzero(fdb->fd_addr + fdh->off, fdh->len);
336 panic("fdb_zero_holes: Unknown fdb type.");
343 fdb_iosetup(fdbuffer_t *fdb, u_offset_t off, size_t len, struct vnode *vp,
349 "?fdb_iosetup: off: %llx len: %lux fdb: len: %lux flags: %x",
350 off, len, fdb->fd_len, fdb->fd_state));
352 ASSERT(fdb);
354 mutex_enter(&fdb->fd_mutex);
356 ASSERT(((b_flags & B_READ) && (fdb->fd_state & FDB_READ)) ||
357 ((b_flags & B_WRITE) && (fdb->fd_state & FDB_WRITE)));
359 * The fdb can be used either in sync or async mode, if the
366 ((fdb->fd_state & FDB_ASYNC) || !(fdb->fd_state & FDB_SYNC))) ||
368 ((fdb->fd_state & FDB_SYNC) || !(fdb->fd_state & FDB_ASYNC))));
371 fdb->fd_state |= b_flags & B_ASYNC ? FDB_ASYNC : FDB_SYNC;
373 fdb->fd_iodispatch++;
375 ASSERT((fdb->fd_state & FDB_ASYNC && fdb->fd_iofunc != NULL) ||
376 fdb->fd_state & FDB_SYNC);
378 mutex_exit(&fdb->fd_mutex);
381 ASSERT(off+len <= fdb->fd_len);
383 switch (fdb->fd_type) {
385 if (fdb->fd_parentbp == NULL) {
386 bp = pageio_setup(fdb->fd_pages, len, vp, b_flags);
387 fdb->fd_parentbp = bp;
391 if (fdb->fd_parentbp == NULL) {
396 bp->b_proc = fdb->fd_procp;
399 bp->b_un.b_addr = fdb->fd_addr;
400 bp->b_shadow = fdb->fd_shadow;
401 if (fdb->fd_shadow != NULL)
403 fdb->fd_parentbp = bp;
407 panic("fdb_iosetup: Unsupported fdb type.");
411 bp = bioclone(fdb->fd_parentbp, off, len, 0, 0,
415 bp->b_forw = (struct buf *)fdb;
424 fdb_get_iolen(fdbuffer_t *fdb)
426 ASSERT(fdb);
427 ASSERT(fdb->fd_iodispatch == 0);
429 return (fdb->fd_iocount - fdb->fd_resid);
433 fdb_ioerrdone(fdbuffer_t *fdb, int error)
435 ASSERT(fdb);
436 ASSERT(fdb->fd_state & FDB_ASYNC);
439 "?fdb_ioerrdone: fdb: len: %lux flags: %x error: %d",
440 fdb->fd_len, fdb->fd_state, error));
442 mutex_enter(&fdb->fd_mutex);
444 fdb->fd_err = error;
447 fdb->fd_state |= FDB_ERROR;
449 fdb->fd_state |= FDB_DONE;
454 if (fdb->fd_iodispatch > 0) {
455 mutex_exit(&fdb->fd_mutex);
459 mutex_exit(&fdb->fd_mutex);
460 fdb->fd_iofunc(fdb, fdb->fd_iargp, NULL);
466 fdbuffer_t *fdb = (fdbuffer_t *)bp->b_forw;
470 ASSERT(fdb);
473 "?fdb_iodone: fdb: len: %lux flags: %x error: %d",
474 fdb->fd_len, fdb->fd_state, geterror(bp)));
479 mutex_enter(&fdb->fd_mutex);
481 icallback = fdb->fd_state & FDB_ICALLBACK;
482 isasync = fdb->fd_state & FDB_ASYNC;
484 ASSERT(fdb->fd_iodispatch > 0);
485 fdb->fd_iodispatch--;
488 fdb->fd_err = error;
490 fdb->fd_resid += bp->b_resid;
492 fdb->fd_resid += bp->b_bcount;
495 fdb->fd_iocount += bp->b_bcount;
506 * call the async function associated with the fdb.
510 if ((fdb->fd_iodispatch == 0) &&
511 (fdb->fd_state & (FDB_ERROR|FDB_DONE))) {
513 mutex_exit(&fdb->fd_mutex);
516 fdb->fd_iofunc(fdb, fdb->fd_iargp, bp);
521 mutex_exit(&fdb->fd_mutex);
524 fdb->fd_iofunc(fdb, fdb->fd_iargp, bp);