Preparation commit before I start on the bioqueue lockdown:

Collect all the bits of bioqueue handing in subr_disk.c, vfs_bio.c is big
enough as it is and disksort already lives in subr_disk.c.
This commit is contained in:
Poul-Henning Kamp 2003-03-30 08:51:23 +00:00
parent d938c3689d
commit d086f85ac4
3 changed files with 46 additions and 43 deletions

View File

@ -61,6 +61,49 @@ disk_err(struct bio *bp, const char *what, int blkdone, int nl)
printf("\n");
}
/*
* BIO queue implementation
*/
void
bioq_init(struct bio_queue_head *head)
{
TAILQ_INIT(&head->queue);
head->last_pblkno = 0;
head->insert_point = NULL;
head->switch_point = NULL;
}
void
bioq_remove(struct bio_queue_head *head, struct bio *bp)
{
if (bp == head->switch_point)
head->switch_point = TAILQ_NEXT(bp, bio_queue);
if (bp == head->insert_point) {
head->insert_point = TAILQ_PREV(bp, bio_queue, bio_queue);
if (head->insert_point == NULL)
head->last_pblkno = 0;
} else if (bp == TAILQ_FIRST(&head->queue))
head->last_pblkno = bp->bio_pblkno;
TAILQ_REMOVE(&head->queue, bp, bio_queue);
if (TAILQ_FIRST(&head->queue) == head->switch_point)
head->switch_point = NULL;
}
void
bioq_insert_tail(struct bio_queue_head *head, struct bio *bp)
{
TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue);
}
struct bio *
bioq_first(struct bio_queue_head *head)
{
return (TAILQ_FIRST(&head->queue));
}
/*
* Seek sort for disks.
*

View File

@ -2986,31 +2986,6 @@ biofinish(struct bio *bp, struct devstat *stat, int error)
biodone(bp);
}
void
bioq_init(struct bio_queue_head *head)
{
TAILQ_INIT(&head->queue);
head->last_pblkno = 0;
head->insert_point = NULL;
head->switch_point = NULL;
}
void
bioq_remove(struct bio_queue_head *head, struct bio *bp)
{
if (bp == head->switch_point)
head->switch_point = TAILQ_NEXT(bp, bio_queue);
if (bp == head->insert_point) {
head->insert_point = TAILQ_PREV(bp, bio_queue, bio_queue);
if (head->insert_point == NULL)
head->last_pblkno = 0;
} else if (bp == TAILQ_FIRST(&head->queue))
head->last_pblkno = bp->bio_pblkno;
TAILQ_REMOVE(&head->queue, bp, bio_queue);
if (TAILQ_FIRST(&head->queue) == head->switch_point)
head->switch_point = NULL;
}
/*
* bufwait:
*

View File

@ -114,30 +114,15 @@ struct bio_queue_head {
int busy;
};
static __inline void bioq_insert_tail(struct bio_queue_head *head,
struct bio *bp);
static __inline struct bio *bioq_first(struct bio_queue_head *head);
static __inline void
bioq_insert_tail(struct bio_queue_head *head, struct bio *bp)
{
TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue);
}
static __inline struct bio *
bioq_first(struct bio_queue_head *head)
{
return (TAILQ_FIRST(&head->queue));
}
void biodone(struct bio *bp);
void biofinish(struct bio *bp, struct devstat *stat, int error);
int biowait(struct bio *bp, const char *wchan);
void bioq_disksort(struct bio_queue_head *ap, struct bio *bp);
#define bioqdisksort(foo, bar) bioq_disksort(foo, bar)
struct bio *bioq_first(struct bio_queue_head *head);
void bioq_init(struct bio_queue_head *head);
void bioq_insert_tail(struct bio_queue_head *head, struct bio *bp);
void bioq_remove(struct bio_queue_head *head, struct bio *bp);
void bio_taskqueue(struct bio *bp, bio_task_t *fund, void *arg);