Lines Matching refs:head
152 bioq_init(struct bio_queue_head *head) in bioq_init() argument
155 TAILQ_INIT(&head->queue); in bioq_init()
156 head->last_offset = 0; in bioq_init()
157 head->insert_point = NULL; in bioq_init()
158 head->total = 0; in bioq_init()
159 head->batched = 0; in bioq_init()
163 bioq_remove(struct bio_queue_head *head, struct bio *bp) in bioq_remove() argument
166 if (head->insert_point == NULL) { in bioq_remove()
167 if (bp == TAILQ_FIRST(&head->queue)) in bioq_remove()
168 head->last_offset = bp->bio_offset + bp->bio_length; in bioq_remove()
169 } else if (bp == head->insert_point) in bioq_remove()
170 head->insert_point = NULL; in bioq_remove()
172 TAILQ_REMOVE(&head->queue, bp, bio_queue); in bioq_remove()
173 if (TAILQ_EMPTY(&head->queue)) in bioq_remove()
174 head->batched = 0; in bioq_remove()
175 head->total--; in bioq_remove()
179 bioq_flush(struct bio_queue_head *head, struct devstat *stp, int error) in bioq_flush() argument
183 while ((bp = bioq_takefirst(head)) != NULL) in bioq_flush()
188 bioq_insert_head(struct bio_queue_head *head, struct bio *bp) in bioq_insert_head() argument
191 if (head->insert_point == NULL) in bioq_insert_head()
192 head->last_offset = bp->bio_offset; in bioq_insert_head()
193 TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); in bioq_insert_head()
194 head->total++; in bioq_insert_head()
195 head->batched = 0; in bioq_insert_head()
199 bioq_insert_tail(struct bio_queue_head *head, struct bio *bp) in bioq_insert_tail() argument
202 TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue); in bioq_insert_tail()
203 head->total++; in bioq_insert_tail()
204 head->batched = 0; in bioq_insert_tail()
205 head->insert_point = bp; in bioq_insert_tail()
206 head->last_offset = bp->bio_offset; in bioq_insert_tail()
210 bioq_first(struct bio_queue_head *head) in bioq_first() argument
213 return (TAILQ_FIRST(&head->queue)); in bioq_first()
217 bioq_takefirst(struct bio_queue_head *head) in bioq_takefirst() argument
221 bp = TAILQ_FIRST(&head->queue); in bioq_takefirst()
223 bioq_remove(head, bp); in bioq_takefirst()
233 bioq_bio_key(struct bio_queue_head *head, struct bio *bp) in bioq_bio_key() argument
236 return ((uoff_t)(bp->bio_offset - head->last_offset)); in bioq_bio_key()
247 bioq_disksort(struct bio_queue_head *head, struct bio *bp) in bioq_disksort() argument
259 bioq_insert_tail(head, bp); in bioq_disksort()
270 bioq_insert_tail(head, bp); in bioq_disksort()
274 if (bioq_batchsize > 0 && head->batched > bioq_batchsize) { in bioq_disksort()
275 bioq_insert_tail(head, bp); in bioq_disksort()
280 key = bioq_bio_key(head, bp); in bioq_disksort()
281 cur = TAILQ_FIRST(&head->queue); in bioq_disksort()
283 if (head->insert_point) { in bioq_disksort()
284 prev = head->insert_point; in bioq_disksort()
285 cur = TAILQ_NEXT(head->insert_point, bio_queue); in bioq_disksort()
288 while (cur != NULL && key >= bioq_bio_key(head, cur)) { in bioq_disksort()
294 TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); in bioq_disksort()
296 TAILQ_INSERT_AFTER(&head->queue, prev, bp, bio_queue); in bioq_disksort()
297 head->total++; in bioq_disksort()
298 head->batched++; in bioq_disksort()