Lines Matching refs:bp

68 static int	g_io_transient_map_bio(struct bio *bp);
132 struct bio *bp;
134 bp = TAILQ_FIRST(&bq->bio_queue);
135 if (bp != NULL) {
136 KASSERT((bp->bio_flags & BIO_ONQUEUE),
137 ("Bio not on queue bp=%p target %p", bp, bq));
138 bp->bio_flags &= ~BIO_ONQUEUE;
139 TAILQ_REMOVE(&bq->bio_queue, bp, bio_queue);
142 return (bp);
148 struct bio *bp;
150 bp = uma_zalloc(biozone, M_NOWAIT | M_ZERO);
155 CTR1(KTR_GEOM, "g_new_bio(): %p", bp);
160 return (bp);
166 struct bio *bp;
168 bp = uma_zalloc(biozone, M_WAITOK | M_ZERO);
173 CTR1(KTR_GEOM, "g_alloc_bio(): %p", bp);
178 return (bp);
182 g_destroy_bio(struct bio *bp)
188 CTR1(KTR_GEOM, "g_destroy_bio(): %p", bp);
193 uma_zfree(biozone, bp);
197 g_clone_bio(struct bio *bp)
203 bp2->bio_parent = bp;
204 bp2->bio_cmd = bp->bio_cmd;
212 bp2->bio_flags = bp->bio_flags &
214 bp2->bio_length = bp->bio_length;
215 bp2->bio_offset = bp->bio_offset;
216 bp2->bio_data = bp->bio_data;
217 bp2->bio_ma = bp->bio_ma;
218 bp2->bio_ma_n = bp->bio_ma_n;
219 bp2->bio_ma_offset = bp->bio_ma_offset;
220 bp2->bio_attribute = bp->bio_attribute;
221 if (bp->bio_cmd == BIO_ZONE)
222 bcopy(&bp->bio_zone, &bp2->bio_zone,
223 sizeof(bp->bio_zone));
225 bp2->bio_classifier1 = bp->bio_classifier1;
226 bp2->bio_classifier2 = bp->bio_classifier2;
227 bp->bio_children++;
233 CTR2(KTR_GEOM, "g_clone_bio(%p): %p", bp, bp2);
242 g_duplicate_bio(struct bio *bp)
247 bp2->bio_flags = bp->bio_flags & (BIO_UNMAPPED | BIO_VLIST);
248 bp2->bio_parent = bp;
249 bp2->bio_cmd = bp->bio_cmd;
250 bp2->bio_length = bp->bio_length;
251 bp2->bio_offset = bp->bio_offset;
252 bp2->bio_data = bp->bio_data;
253 bp2->bio_ma = bp->bio_ma;
254 bp2->bio_ma_n = bp->bio_ma_n;
255 bp2->bio_ma_offset = bp->bio_ma_offset;
256 bp2->bio_attribute = bp->bio_attribute;
257 bp->bio_children++;
262 CTR2(KTR_GEOM, "g_duplicate_bio(%p): %p", bp, bp2);
271 g_reset_bio(struct bio *bp)
274 bzero(bp, sizeof(*bp));
293 struct bio *bp;
297 bp = g_alloc_bio();
298 bp->bio_cmd = BIO_GETATTR;
299 bp->bio_done = NULL;
300 bp->bio_attribute = attr;
301 bp->bio_length = *len;
302 bp->bio_data = ptr;
303 g_io_request(bp, cp);
304 error = biowait(bp, "ggetattr");
305 *len = bp->bio_completed;
306 g_destroy_bio(bp);
313 struct bio *bp;
317 bp = g_alloc_bio();
318 bp->bio_cmd = BIO_ZONE;
319 bp->bio_done = NULL;
323 bcopy(zone_args, &bp->bio_zone, sizeof(*zone_args));
325 bp->bio_length =
329 bp->bio_length = 0;
331 g_io_request(bp, cp);
332 error = biowait(bp, "gzone");
333 bcopy(&bp->bio_zone, zone_args, sizeof(*zone_args));
334 g_destroy_bio(bp);
341 struct bio *bp;
345 bp = g_alloc_bio();
346 bp->bio_cmd = BIO_FLUSH;
347 bp->bio_flags |= BIO_ORDERED;
348 bp->bio_done = NULL;
349 bp->bio_attribute = NULL;
350 bp->bio_offset = cp->provider->mediasize;
351 bp->bio_length = 0;
352 bp->bio_data = NULL;
353 g_io_request(bp, cp);
354 error = biowait(bp, "gflush");
355 g_destroy_bio(bp);
360 g_io_check(struct bio *bp)
367 cp = bp->bio_from;
368 pp = bp->bio_to;
371 switch(bp->bio_cmd) {
384 if ((bp->bio_zone.zone_cmd == DISK_ZONE_REPORT_ZONES) ||
385 (bp->bio_zone.zone_cmd == DISK_ZONE_GET_PARAMS)) {
400 switch(bp->bio_cmd) {
408 if (bp->bio_offset % pp->sectorsize)
411 if (bp->bio_length % pp->sectorsize)
414 if (bp->bio_offset < 0)
416 if (bp->bio_offset > pp->mediasize)
420 excess = bp->bio_offset + bp->bio_length;
421 if (excess > bp->bio_to->mediasize) {
422 KASSERT((bp->bio_flags & BIO_UNMAPPED) == 0 ||
423 round_page(bp->bio_ma_offset +
424 bp->bio_length) / PAGE_SIZE == bp->bio_ma_n,
425 ("excess bio %p too short", bp));
426 excess -= bp->bio_to->mediasize;
427 bp->bio_length -= excess;
428 if ((bp->bio_flags & BIO_UNMAPPED) != 0) {
429 bp->bio_ma_n = round_page(bp->bio_ma_offset +
430 bp->bio_length) / PAGE_SIZE;
434 "%p provider %s by %d", bp,
435 bp->bio_to->name, excess);
439 if (bp->bio_length == 0) {
441 "bp %p provider %s", bp, bp->bio_to->name);
445 if ((bp->bio_flags & BIO_UNMAPPED) != 0 &&
446 (bp->bio_to->flags & G_PF_ACCEPT_UNMAPPED) == 0 &&
447 (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)) {
448 if ((error = g_io_transient_map_bio(bp)) >= 0)
503 g_run_classifiers(struct bio *bp)
509 classified |= hook->func(hook->arg, bp);
512 bp->bio_classifier1 = BIO_NOTCLASSIFIED;
516 g_io_request(struct bio *bp, struct g_consumer *cp)
524 KASSERT(bp != NULL, ("NULL bp in g_io_request"));
528 KASSERT(bp->bio_driver1 == NULL,
530 KASSERT(bp->bio_driver2 == NULL,
532 KASSERT(bp->bio_pflags == 0,
538 bp->_bio_caller1 = bp->bio_caller1;
539 bp->_bio_caller2 = bp->bio_caller2;
540 bp->_bio_cflags = bp->bio_cflags;
543 cmd = bp->bio_cmd;
545 KASSERT(bp->bio_data != NULL,
546 ("NULL bp->data in g_io_request(cmd=%hu)", bp->bio_cmd));
549 KASSERT(bp->bio_data == NULL,
550 ("non-NULL bp->data in g_io_request(cmd=%hu)",
551 bp->bio_cmd));
554 KASSERT(bp->bio_offset % cp->provider->sectorsize == 0,
556 bp->bio_offset, cp->provider->sectorsize));
557 KASSERT(bp->bio_length % cp->provider->sectorsize == 0,
559 bp->bio_length, cp->provider->sectorsize));
563 bp, cp, cp->geom->name, pp, pp->name, bp->bio_cmd);
565 bp->bio_from = cp;
566 bp->bio_to = pp;
567 bp->bio_error = 0;
568 bp->bio_completed = 0;
570 KASSERT(!(bp->bio_flags & BIO_ONQUEUE),
571 ("Bio already on queue bp=%p", bp));
574 binuptime(&bp->bio_t0);
576 getbinuptime(&bp->bio_t0);
583 (bp->bio_flags & BIO_UNMAPPED) == 0 || THREAD_CAN_SLEEP()) &&
596 if (!TAILQ_EMPTY(&g_classifier_tailq) && !bp->bio_classifier1) {
598 g_run_classifiers(bp);
610 devstat_start_transaction(pp->stat, &bp->bio_t0);
612 devstat_start_transaction(cp->stat, &bp->bio_t0);
618 error = g_io_check(bp);
620 CTR3(KTR_GEOM, "g_io_request g_io_check on bp %p "
621 "provider %s returned %d", bp, bp->bio_to->name,
623 g_io_deliver(bp, error);
626 bp->bio_to->geom->start(bp);
630 TAILQ_INSERT_TAIL(&g_bio_run_down.bio_queue, bp, bio_queue);
631 bp->bio_flags |= BIO_ONQUEUE;
641 g_io_deliver(struct bio *bp, int error)
649 KASSERT(bp != NULL, ("NULL bp in g_io_deliver"));
650 pp = bp->bio_to;
652 cp = bp->bio_from;
654 bp->bio_error = error;
655 bp->bio_done(bp);
667 KASSERT(bp->bio_caller1 == bp->_bio_caller1,
669 KASSERT(bp->bio_caller2 == bp->_bio_caller2,
671 KASSERT(bp->bio_cflags == bp->_bio_cflags,
675 KASSERT(bp->bio_completed >= 0, ("bio_completed can't be less than 0"));
676 KASSERT(bp->bio_completed <= bp->bio_length,
681 bp, cp, cp->geom->name, pp, pp->name, bp->bio_cmd, error,
682 (intmax_t)bp->bio_offset, (intmax_t)bp->bio_length);
684 KASSERT(!(bp->bio_flags & BIO_ONQUEUE),
685 ("Bio already on queue bp=%p", bp));
690 bp->bio_bcount = bp->bio_length;
691 bp->bio_resid = bp->bio_bcount - bp->bio_completed;
719 devstat_end_transaction_bio_bt(pp->stat, bp, &now);
721 devstat_end_transaction_bio_bt(cp->stat, bp, &now);
727 bp->bio_error = error;
729 biodone(bp);
733 TAILQ_INSERT_TAIL(&g_bio_run_up.bio_queue, bp, bio_queue);
734 bp->bio_flags |= BIO_ONQUEUE;
744 printf("ENOMEM %p on %p(%s)\n", bp, pp, pp->name);
745 bp->bio_children = 0;
746 bp->bio_inbed = 0;
747 bp->bio_driver1 = NULL;
748 bp->bio_driver2 = NULL;
749 bp->bio_pflags = 0;
750 g_io_request(bp, cp);
780 g_io_transient_map_bio(struct bio *bp)
788 size = round_page(bp->bio_ma_offset + bp->bio_length);
789 KASSERT(size / PAGE_SIZE == bp->bio_ma_n, ("Bio too short %p", bp));
797 CTR2(KTR_GEOM, "g_down cannot map bp %p provider %s",
798 bp, bp->bio_to->name);
807 CTR3(KTR_GEOM, "g_down retrymap bp %p provider %s r %d",
808 bp, bp->bio_to->name, retried);
816 pmap_qenter((vm_offset_t)addr, bp->bio_ma, OFF_TO_IDX(size));
817 bp->bio_data = (caddr_t)addr + bp->bio_ma_offset;
818 bp->bio_flags |= BIO_TRANSIENT_MAPPING;
819 bp->bio_flags &= ~BIO_UNMAPPED;
826 struct bio *bp;
831 bp = g_bioq_first(&g_bio_run_down);
832 if (bp == NULL) {
868 CTR2(KTR_GEOM, "g_down processing bp %p provider %s", bp,
869 bp->bio_to->name);
870 error = g_io_check(bp);
872 CTR3(KTR_GEOM, "g_down g_io_check on bp %p provider "
873 "%s returned %d", bp, bp->bio_to->name, error);
874 g_io_deliver(bp, error);
878 CTR4(KTR_GEOM, "g_down starting bp %p provider %s off %ld "
879 "len %ld", bp, bp->bio_to->name, bp->bio_offset,
880 bp->bio_length);
881 bp->bio_to->geom->start(bp);
887 bio_taskqueue(struct bio *bp, bio_task_t *func, void *arg)
889 bp->bio_task = func;
890 bp->bio_task_arg = arg;
896 KASSERT(!(bp->bio_flags & BIO_ONQUEUE),
897 ("Bio already on queue bp=%p target taskq", bp));
898 bp->bio_flags |= BIO_ONQUEUE;
899 TAILQ_INSERT_TAIL(&g_bio_run_task.bio_queue, bp, bio_queue);
909 struct bio *bp;
912 bp = g_bioq_first(&g_bio_run_task);
913 if (bp != NULL) {
916 CTR1(KTR_GEOM, "g_up processing task bp %p", bp);
917 bp->bio_task(bp->bio_task_arg);
921 bp = g_bioq_first(&g_bio_run_up);
922 if (bp != NULL) {
925 CTR4(KTR_GEOM, "g_up biodone bp %p provider %s off "
926 "%jd len %ld", bp, bp->bio_to->name,
927 bp->bio_offset, bp->bio_length);
928 biodone(bp);
941 struct bio *bp;
949 bp = g_alloc_bio();
950 bp->bio_cmd = BIO_READ;
951 bp->bio_done = NULL;
952 bp->bio_offset = offset;
953 bp->bio_length = length;
955 bp->bio_data = ptr;
956 g_io_request(bp, cp);
957 errorc = biowait(bp, "gread");
960 g_destroy_bio(bp);
971 struct bio *bp;
978 bp = g_alloc_bio();
979 bp->bio_cmd = BIO_WRITE;
980 bp->bio_done = NULL;
981 bp->bio_offset = offset;
982 bp->bio_length = length;
983 bp->bio_data = ptr;
984 g_io_request(bp, cp);
985 error = biowait(bp, "gwrite");
986 g_destroy_bio(bp);
993 struct bio *bp;
999 bp = g_alloc_bio();
1000 bp->bio_cmd = BIO_DELETE;
1001 bp->bio_done = NULL;
1002 bp->bio_offset = offset;
1003 bp->bio_length = length;
1004 bp->bio_data = NULL;
1005 g_io_request(bp, cp);
1006 error = biowait(bp, "gdelete");
1007 g_destroy_bio(bp);
1012 g_print_bio(struct bio *bp)
1016 if (bp->bio_to != NULL)
1017 pname = bp->bio_to->name;
1021 switch (bp->bio_cmd) {
1024 printf("%s[%s(attr=%s)]", pname, cmd, bp->bio_attribute);
1033 switch (bp->bio_zone.zone_cmd) {
1074 (intmax_t)bp->bio_offset, (intmax_t)bp->bio_length);