patch-2.3.46 linux/drivers/block/DAC960.c
Next file: linux/drivers/block/acsi.c
Previous file: linux/drivers/block/Config.in
Back to the patch index
Back to the overall index
- Lines: 151
- Date:
Wed Feb 16 15:42:05 2000
- Orig file:
v2.3.45/linux/drivers/block/DAC960.c
- Orig date:
Fri Jan 28 15:09:07 2000
diff -u --recursive --new-file v2.3.45/linux/drivers/block/DAC960.c linux/drivers/block/DAC960.c
@@ -1009,37 +1009,58 @@
}
-static int DAC_merge_fn(request_queue_t *q, struct request *req,
- struct buffer_head *bh)
+static inline int DAC_new_segment(request_queue_t *q, struct request *req,
+ int __max_segments)
{
int max_segments;
DAC960_Controller_T * Controller = q->queuedata;
max_segments = Controller->MaxSegmentsPerRequest[MINOR(req->rq_dev)];
+ if (__max_segments < max_segments)
+ max_segments = __max_segments;
- 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;
+ if (req->nr_segments < max_segments) {
+ req->nr_segments++;
+ q->nr_segments++;
+ return 1;
}
+ return 0;
+}
- return 1;
+static int DAC_back_merge_fn(request_queue_t *q, struct request *req,
+ struct buffer_head *bh, int __max_segments)
+{
+ if (req->bhtail->b_data + req->bhtail->b_size == bh->b_data)
+ return 1;
+ return DAC_new_segment(q, req, __max_segments);
+}
+
+static int DAC_front_merge_fn(request_queue_t *q, struct request *req,
+ struct buffer_head *bh, int __max_segments)
+{
+ if (bh->b_data + bh->b_size == req->bh->b_data)
+ return 1;
+ return DAC_new_segment(q, req, __max_segments);
}
static int DAC_merge_requests_fn(request_queue_t *q,
struct request *req,
- struct request *next)
+ struct request *next,
+ int __max_segments)
{
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 (__max_segments < max_segments)
+ max_segments = __max_segments;
if (req->bhtail->b_data + req->bhtail->b_size == next->bh->b_data)
+ {
total_segments--;
+ q->nr_segments--;
+ }
if (total_segments > max_segments)
return 0;
@@ -1068,7 +1089,7 @@
/*
Register the Block Device Major Number for this DAC960 Controller.
*/
- if (register_blkdev(MajorNumber, "rd", &DAC960_FileOperations) < 0)
+ if (devfs_register_blkdev(MajorNumber, "dac960", &DAC960_FileOperations) < 0)
{
DAC960_Error("UNABLE TO ACQUIRE MAJOR NUMBER %d - DETACHING\n",
Controller, MajorNumber);
@@ -1080,7 +1101,8 @@
q = BLK_DEFAULT_QUEUE(MajorNumber);
blk_init_queue(q, RequestFunctions[Controller->ControllerNumber]);
blk_queue_headactive(q, 0);
- q->merge_fn = DAC_merge_fn;
+ q->back_merge_fn = DAC_back_merge_fn;
+ q->front_merge_fn = DAC_front_merge_fn;
q->merge_requests_fn = DAC_merge_requests_fn;
q->queuedata = (void *) Controller;
@@ -1108,12 +1130,13 @@
Complete initialization of the Generic Disk Information structure.
*/
Controller->GenericDiskInfo.major = MajorNumber;
- Controller->GenericDiskInfo.major_name = "rd";
+ Controller->GenericDiskInfo.major_name = "dac960";
Controller->GenericDiskInfo.minor_shift = DAC960_MaxPartitionsBits;
Controller->GenericDiskInfo.max_p = DAC960_MaxPartitions;
Controller->GenericDiskInfo.nr_real = Controller->LogicalDriveCount;
Controller->GenericDiskInfo.real_devices = Controller;
Controller->GenericDiskInfo.next = NULL;
+ Controller->GenericDiskInfo.fops = &DAC960_FileOperations;
/*
Install the Generic Disk Information structure at the end of the list.
*/
@@ -1142,7 +1165,7 @@
/*
Unregister the Block Device Major Number for this DAC960 Controller.
*/
- unregister_blkdev(MajorNumber, "rd");
+ devfs_unregister_blkdev(MajorNumber, "dac960");
/*
Remove the I/O Request Function.
*/
@@ -1156,7 +1179,6 @@
blk_size[MajorNumber] = NULL;
blksize_size[MajorNumber] = NULL;
max_sectors[MajorNumber] = NULL;
- max_segments[MajorNumber] = NULL;
/*
Remove the Generic Disk Information structure from the list.
*/
@@ -1305,15 +1327,17 @@
static boolean DAC960_ProcessRequest(DAC960_Controller_T *Controller,
boolean WaitForCommand)
{
- IO_Request_T **RequestQueuePointer =
- &blk_dev[DAC960_MAJOR + Controller->ControllerNumber].request_queue.current_request;
+ struct list_head * queue_head;
IO_Request_T *Request;
DAC960_Command_T *Command;
char *RequestBuffer;
+
+ queue_head = &blk_dev[DAC960_MAJOR + Controller->ControllerNumber].request_queue.queue_head;
while (true)
{
- Request = *RequestQueuePointer;
- if (Request == NULL || Request->rq_status == RQ_INACTIVE) return false;
+ if (list_empty(queue_head)) return false;
+ Request = blkdev_entry_next_request(queue_head);
+ if (Request->rq_status == RQ_INACTIVE) return false;
Command = DAC960_AllocateCommand(Controller);
if (Command != NULL) break;
if (!WaitForCommand) return false;
@@ -1335,7 +1359,7 @@
Command->BufferHeader = Request->bh;
RequestBuffer = Request->buffer;
Request->rq_status = RQ_INACTIVE;
- *RequestQueuePointer = Request->next;
+ blkdev_dequeue_request(Request);
wake_up(&wait_for_request);
if (Command->SegmentCount == 1)
{
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)