26#include <sys/sysctl.h>
27#include <geom/geom_disk.h>
41disk_err(
struct bio *bp,
const char *what,
int blkdone,
int nl)
45 if (bp->bio_dev != NULL)
47 else if (bp->bio_disk != NULL)
49 bp->bio_disk->d_name, bp->bio_disk->d_unit, what);
51 printf(
"disk??: %s ", what);
53 case BIO_READ:
printf(
"cmd=read ");
break;
54 case BIO_WRITE:
printf(
"cmd=write ");
break;
55 case BIO_DELETE:
printf(
"cmd=delete ");
break;
56 case BIO_GETATTR:
printf(
"cmd=getattr ");
break;
57 case BIO_FLUSH:
printf(
"cmd=flush ");
break;
58 default:
printf(
"cmd=%x ", bp->bio_cmd);
break;
61 if (bp->bio_bcount <= DEV_BSIZE) {
62 printf(
"fsbn %jd%s", (intmax_t)sn, nl ?
"\n" :
"");
67 printf(
"fsbn %jd of ", (intmax_t)sn);
69 printf(
"%jd-%jd", (intmax_t)bp->bio_pblkno,
70 (intmax_t)(bp->bio_pblkno + (bp->bio_bcount - 1) / DEV_BSIZE));
157 TAILQ_INIT(&head->queue);
158 head->last_offset = 0;
159 head->insert_point = NULL;
168 if (head->insert_point == NULL) {
169 if (bp == TAILQ_FIRST(&head->queue))
170 head->last_offset = bp->bio_offset + bp->bio_length;
171 }
else if (bp == head->insert_point)
172 head->insert_point = NULL;
174 TAILQ_REMOVE(&head->queue, bp, bio_queue);
175 if (TAILQ_EMPTY(&head->queue))
181bioq_flush(
struct bio_queue_head *head,
struct devstat *stp,
int error)
193 if (head->insert_point == NULL)
194 head->last_offset = bp->bio_offset;
195 TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue);
204 TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue);
207 head->insert_point = bp;
208 head->last_offset = bp->bio_offset;
215 return (TAILQ_FIRST(&head->queue));
223 bp = TAILQ_FIRST(&head->queue);
238 return ((uoff_t)(bp->bio_offset - head->last_offset));
251 struct bio *cur, *prev;
254 if ((bp->bio_flags & BIO_ORDERED) != 0) {
270 if (bp->bio_cmd != BIO_READ && bp->bio_cmd != BIO_WRITE &&
271 bp->bio_cmd != BIO_DELETE) {
283 cur = TAILQ_FIRST(&head->queue);
285 if (head->insert_point) {
286 prev = head->insert_point;
287 cur = TAILQ_NEXT(head->insert_point, bio_queue);
292 cur = TAILQ_NEXT(cur, bio_queue);
296 TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue);
298 TAILQ_INSERT_AFTER(&head->queue, prev, bp, bio_queue);
const char * devtoname(struct cdev *dev)
SYSCTL_INT(_debug, OID_AUTO, bioq_batchsize, CTLFLAG_RW, &bioq_batchsize, 0, "BIOQ batch size")
void bioq_remove(struct bio_queue_head *head, struct bio *bp)
void bioq_init(struct bio_queue_head *head)
static int bioq_batchsize
void bioq_disksort(struct bio_queue_head *head, struct bio *bp)
void bioq_flush(struct bio_queue_head *head, struct devstat *stp, int error)
void bioq_insert_tail(struct bio_queue_head *head, struct bio *bp)
struct bio * bioq_takefirst(struct bio_queue_head *head)
void disk_err(struct bio *bp, const char *what, int blkdone, int nl)
void bioq_insert_head(struct bio_queue_head *head, struct bio *bp)
static uoff_t bioq_bio_key(struct bio_queue_head *head, struct bio *bp)
struct bio * bioq_first(struct bio_queue_head *head)
int printf(const char *fmt,...)
void biofinish(struct bio *bp, struct devstat *stat, int error)