Index: sys/kern/subr_disk.c =================================================================== --- sys/kern/subr_disk.c +++ sys/kern/subr_disk.c @@ -21,8 +21,13 @@ #include #include #include +#include #include +static int bioq_batchsize = 128; +SYSCTL_INT(_debug, OID_AUTO, bioq_batchsize, CTLFLAG_RW, + &bioq_batchsize, 0, "BIOQ batch size"); + /*- * Disk error is the preface to plaintive error messages * about failing disk transfers. It prints messages of the form @@ -150,6 +155,7 @@ TAILQ_INIT(&head->queue); head->last_offset = 0; head->insert_point = NULL; + head->batched = 0; } void @@ -188,6 +194,7 @@ { TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue); + head->batched = 0; head->insert_point = bp; head->last_offset = bp->bio_offset; } @@ -246,6 +253,16 @@ return; } + /* + * Impose a maximum number of passengers in any given + * elevator car. This limits the maximum latency for any + * given request without signficantly affecting the average. + */ + if (bioq_batchsize > 0 && head->batched > bioq_batchsize) { + bioq_insert_tail(head, bp); + return; + } + prev = NULL; key = bioq_bio_key(head, bp); cur = TAILQ_FIRST(&head->queue); @@ -264,4 +281,6 @@ TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); else TAILQ_INSERT_AFTER(&head->queue, prev, bp, bio_queue); + + head->batched++; } Index: sys/sys/bio.h =================================================================== --- sys/sys/bio.h +++ sys/sys/bio.h @@ -129,6 +129,7 @@ TAILQ_HEAD(bio_queue, bio) queue; off_t last_offset; struct bio *insert_point; + int batched; }; extern struct vm_map *bio_transient_map;