block/deadline-iosched.c | 55 ++++++++++++++++++++++++----------------------- 1 files changed, 29 insertions(+), 26 deletions(-) diff -puN drivers/block/deadline-iosched.c~deadline-np-43 drivers/block/deadline-iosched.c --- 25/drivers/block/deadline-iosched.c~deadline-np-43 2003-01-28 21:35:14.000000000 -0800 +++ 25-akpm/drivers/block/deadline-iosched.c 2003-01-28 21:35:14.000000000 -0800 @@ -24,9 +24,9 @@ */ static int read_expire = HZ / 2; /* max time before a read is submitted. */ static int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */ +static int batch_expire = HZ / 4; /* Interval between recalculation of + writes_starved */ static int writes_starved = 2; /* max times reads can starve a write */ -static int fifo_batch = 16; /* # of sequential requests treated as one - by the above parameters. For throughput. */ static const int deadline_hash_shift = 10; #define DL_HASH_BLOCK(sec) ((sec) >> 3) @@ -58,7 +58,7 @@ struct deadline_data { struct list_head *dispatch; /* driver dispatch queue */ struct list_head *hash; /* request hash */ unsigned long hash_valid_count; /* barrier hash count */ - unsigned int batching; /* number of sequential requests made */ + unsigned int batch_expires; /* time until this batch expires */ int batch_data_dir; /* current/last batch READ or WRITE */ unsigned int starved; /* times reads have starved writes */ @@ -66,7 +66,7 @@ struct deadline_data { * settings that change how the i/o scheduler behaves */ int fifo_expire[2]; - int fifo_batch; + int batch_expire; int writes_starved; int front_merges; }; @@ -497,8 +497,20 @@ static inline int deadline_check_fifo(st } /* + * deadline_check_batch returns 0 if the current batch has not expired, + * 1 otherwise. + */ +static inline int deadline_check_batch(struct deadline_data *dd) +{ + if (time_after(jiffies, dd->batch_expires)) + return 1; + + return 0; +} + +/* * deadline_dispatch_requests selects the best request according to - * read/write expire, fifo_batch, etc + * read/write expire, batch expire, etc */ static int deadline_dispatch_requests(struct deadline_data *dd) { @@ -512,24 +524,16 @@ static int deadline_dispatch_requests(st */ drq = dd->next_drq[dd->batch_data_dir]; - if (drq) { - /* we have a "next request" */ - - if (dd->last_sector[dd->batch_data_dir] != drq->request->sector) - /* end the batch on a non sequential request */ - dd->batching += dd->fifo_batch; - - if (dd->batching < dd->fifo_batch) - /* we are still entitled to batch */ - goto dispatch_request; - } + if (drq && !deadline_check_batch(dd)) + /* we have a "next request" and our batch is still running */ + goto dispatch_request; /* * at this point we are not running a batch. select the appropriate * data direction (read / write) */ - dd->batching = 0; /* start a new batch */ + dd->batch_expires = jiffies + dd->batch_expire; /* start a new batch */ if (reads) { BUG_ON(RB_EMPTY(&dd->sort_list[READ])); @@ -577,7 +581,6 @@ dispatch_request: /* * drq is the selected appropriate request. */ - dd->batching++; deadline_move_request(dd, drq); return 1; @@ -736,7 +739,7 @@ static int deadline_init(request_queue_t dd->hash_valid_count = 1; dd->writes_starved = writes_starved; dd->front_merges = 1; - dd->fifo_batch = fifo_batch; + dd->batch_expire = batch_expire; e->elevator_data = dd; for (i = READ; i <= WRITE; i++) { @@ -800,7 +803,7 @@ SHOW_FUNCTION(deadline_readexpire_show, SHOW_FUNCTION(deadline_writeexpire_show, dd->fifo_expire[WRITE]); SHOW_FUNCTION(deadline_writesstarved_show, dd->writes_starved); SHOW_FUNCTION(deadline_frontmerges_show, dd->front_merges); -SHOW_FUNCTION(deadline_fifobatch_show, dd->fifo_batch); +SHOW_FUNCTION(deadline_batchexpire_show, dd->batch_expire); #undef SHOW_FUNCTION #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \ @@ -817,7 +820,7 @@ STORE_FUNCTION(deadline_readexpire_store STORE_FUNCTION(deadline_writeexpire_store, &dd->fifo_expire[WRITE], 0, INT_MAX); STORE_FUNCTION(deadline_writesstarved_store, &dd->writes_starved, INT_MIN, INT_MAX); STORE_FUNCTION(deadline_frontmerges_store, &dd->front_merges, 0, 1); -STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX); +STORE_FUNCTION(deadline_batchexpire_store, &dd->batch_expire, 0, INT_MAX); #undef STORE_FUNCTION static struct deadline_fs_entry deadline_readexpire_entry = { @@ -840,10 +843,10 @@ static struct deadline_fs_entry deadline .show = deadline_frontmerges_show, .store = deadline_frontmerges_store, }; -static struct deadline_fs_entry deadline_fifobatch_entry = { - .attr = {.name = "fifo_batch", .mode = S_IRUGO | S_IWUSR }, - .show = deadline_fifobatch_show, - .store = deadline_fifobatch_store, +static struct deadline_fs_entry deadline_batchexpire_entry = { + .attr = {.name = "batch_expire", .mode = S_IRUGO | S_IWUSR }, + .show = deadline_batchexpire_show, + .store = deadline_batchexpire_store, }; static struct attribute *default_attrs[] = { @@ -851,7 +854,7 @@ static struct attribute *default_attrs[] &deadline_writeexpire_entry.attr, &deadline_writesstarved_entry.attr, &deadline_frontmerges_entry.attr, - &deadline_fifobatch_entry.attr, + &deadline_batchexpire_entry.attr, NULL, }; _