patch-2.3.41 linux/drivers/block/DAC960.c
Next file: linux/drivers/block/alim15x3.c
Previous file: linux/drivers/block/Config.in
Back to the patch index
Back to the overall index
- Lines: 79
- Date:
Wed Jan 26 12:43:03 2000
- Orig file:
v2.3.40/linux/drivers/block/DAC960.c
- Orig date:
Fri Jan 21 18:19:16 2000
diff -u --recursive --new-file v2.3.40/linux/drivers/block/DAC960.c linux/drivers/block/DAC960.c
@@ -1009,6 +1009,45 @@
}
+static int DAC_merge_fn(request_queue_t *q, struct request *req,
+ struct buffer_head *bh)
+{
+ int max_segments;
+ DAC960_Controller_T * Controller = q->queuedata;
+
+ max_segments = Controller->MaxSegmentsPerRequest[MINOR(req->rq_dev)];
+
+ if (req->bhtail->b_data + req->bhtail->b_size != bh->b_data) {
+ if (req->nr_segments < max_segments) {
+ req->nr_segments++;
+ return 1;
+ }
+ return 0;
+ }
+
+ return 1;
+}
+
+static int DAC_merge_requests_fn(request_queue_t *q,
+ struct request *req,
+ struct request *next)
+{
+ int max_segments;
+ DAC960_Controller_T * Controller = q->queuedata;
+ int total_segments = req->nr_segments + next->nr_segments;
+
+ max_segments = Controller->MaxSegmentsPerRequest[MINOR(req->rq_dev)];
+
+ if (req->bhtail->b_data + req->bhtail->b_size == next->bh->b_data)
+ total_segments--;
+
+ if (total_segments > max_segments)
+ return 0;
+
+ req->nr_segments = total_segments;
+ return 1;
+}
+
/*
DAC960_RegisterBlockDevice registers the Block Device structures
associated with Controller.
@@ -1016,6 +1055,8 @@
static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
{
+ request_queue_t * q;
+
static void (*RequestFunctions[DAC960_MaxControllers])(request_queue_t *) =
{ DAC960_RequestFunction0, DAC960_RequestFunction1,
DAC960_RequestFunction2, DAC960_RequestFunction3,
@@ -1036,8 +1077,13 @@
/*
Initialize the I/O Request Function.
*/
- blk_init_queue(BLK_DEFAULT_QUEUE(MajorNumber),
- RequestFunctions[Controller->ControllerNumber]);
+ q = BLK_DEFAULT_QUEUE(MajorNumber);
+ blk_init_queue(q, RequestFunctions[Controller->ControllerNumber]);
+ blk_queue_headactive(q, 0);
+ q->merge_fn = DAC_merge_fn;
+ q->merge_requests_fn = DAC_merge_requests_fn;
+ q->queuedata = (void *) Controller;
+
/*
Initialize the Disk Partitions array, Partition Sizes array, Block Sizes
array, Max Sectors per Request array, and Max Segments per Request array.
@@ -1054,7 +1100,6 @@
Controller->GenericDiskInfo.sizes = Controller->PartitionSizes;
blksize_size[MajorNumber] = Controller->BlockSizes;
max_sectors[MajorNumber] = Controller->MaxSectorsPerRequest;
- max_segments[MajorNumber] = Controller->MaxSegmentsPerRequest;
/*
Initialize Read Ahead to 128 sectors.
*/
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)