Commit 64ac28dd authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] make a few more routines private to scsi_lib.c

parent 6295e6cf
...@@ -445,10 +445,6 @@ void scsi_free_sgtable(struct scatterlist *sgl, int index); ...@@ -445,10 +445,6 @@ void scsi_free_sgtable(struct scatterlist *sgl, int index);
* Prototypes for functions in scsi_lib.c * Prototypes for functions in scsi_lib.c
*/ */
extern int scsi_maybe_unblock_host(Scsi_Device * SDpnt); extern int scsi_maybe_unblock_host(Scsi_Device * SDpnt);
extern Scsi_Cmnd *scsi_end_request(Scsi_Cmnd * SCpnt, int uptodate,
int sectors);
extern struct Scsi_Device_Template *scsi_get_request_dev(struct request *);
extern int scsi_init_cmd_errh(Scsi_Cmnd * SCpnt);
extern void scsi_setup_cmd_retry(Scsi_Cmnd *SCpnt); extern void scsi_setup_cmd_retry(Scsi_Cmnd *SCpnt);
extern int scsi_insert_special_cmd(Scsi_Cmnd * SCpnt, int); extern int scsi_insert_special_cmd(Scsi_Cmnd * SCpnt, int);
extern void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, extern void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
......
...@@ -95,7 +95,7 @@ int scsi_insert_special_req(Scsi_Request * SRpnt, int at_head) ...@@ -95,7 +95,7 @@ int scsi_insert_special_req(Scsi_Request * SRpnt, int at_head)
* fields related to error handling. Typically this will * fields related to error handling. Typically this will
* be called once for each command, as required. * be called once for each command, as required.
*/ */
int scsi_init_cmd_errh(Scsi_Cmnd * SCpnt) static int scsi_init_cmd_errh(Scsi_Cmnd * SCpnt)
{ {
SCpnt->owner = SCSI_OWNER_MIDLEVEL; SCpnt->owner = SCSI_OWNER_MIDLEVEL;
SCpnt->reset_chain = NULL; SCpnt->reset_chain = NULL;
...@@ -306,11 +306,10 @@ void scsi_queue_next_request(request_queue_t * q, Scsi_Cmnd * SCpnt) ...@@ -306,11 +306,10 @@ void scsi_queue_next_request(request_queue_t * q, Scsi_Cmnd * SCpnt)
* We are guaranteeing that the request queue will be goosed * We are guaranteeing that the request queue will be goosed
* at some point during this call. * at some point during this call.
*/ */
static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt, static Scsi_Cmnd *scsi_end_request(Scsi_Cmnd * SCpnt,
int uptodate, int uptodate,
int sectors, int sectors,
int requeue, int requeue)
int frequeue)
{ {
request_queue_t *q = &SCpnt->device->request_queue; request_queue_t *q = &SCpnt->device->request_queue;
struct request *req = SCpnt->request; struct request *req = SCpnt->request;
...@@ -337,12 +336,9 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt, ...@@ -337,12 +336,9 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt,
add_disk_randomness(req->rq_disk); add_disk_randomness(req->rq_disk);
spin_lock_irqsave(q->queue_lock, flags); spin_lock_irqsave(q->queue_lock, flags);
if (blk_rq_tagged(req)) if (blk_rq_tagged(req))
blk_queue_end_tag(q, req); blk_queue_end_tag(q, req);
end_that_request_last(req); end_that_request_last(req);
spin_unlock_irqrestore(q->queue_lock, flags); spin_unlock_irqrestore(q->queue_lock, flags);
/* /*
...@@ -350,38 +346,10 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt, ...@@ -350,38 +346,10 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt,
* need to worry about launching another command. * need to worry about launching another command.
*/ */
__scsi_release_command(SCpnt); __scsi_release_command(SCpnt);
scsi_queue_next_request(q, NULL);
if (frequeue)
scsi_queue_next_request(q, NULL);
return NULL; return NULL;
} }
/*
* Function: scsi_end_request()
*
* Purpose: Post-processing of completed commands called from interrupt
* handler or a bottom-half handler.
*
* Arguments: SCpnt - command that is complete.
* uptodate - 1 if I/O indicates success, 0 for I/O error.
* sectors - number of sectors we want to mark.
*
* Lock status: Assumed that lock is not held upon entry.
*
* Returns: Nothing
*
* Notes: This is called for block device requests in order to
* mark some number of sectors as complete.
*
* We are guaranteeing that the request queue will be goosed
* at some point during this call.
*/
Scsi_Cmnd *scsi_end_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors)
{
return __scsi_end_request(SCpnt, uptodate, sectors, 1, 1);
}
/* /*
* Function: scsi_release_buffers() * Function: scsi_release_buffers()
* *
...@@ -428,6 +396,29 @@ static void scsi_release_buffers(Scsi_Cmnd * SCpnt) ...@@ -428,6 +396,29 @@ static void scsi_release_buffers(Scsi_Cmnd * SCpnt)
SCpnt->request_bufflen = 0; SCpnt->request_bufflen = 0;
} }
/*
* Function: scsi_get_request_dev()
*
* Purpose: Find the upper-level driver that is responsible for this
* request
*
* Arguments: request - I/O request we are preparing to queue.
*
* Lock status: No locks assumed to be held, but as it happens the
* q->queue_lock is held when this is called.
*
* Returns: Nothing
*
* Notes: The requests in the request queue may have originated
* from any block device driver. We need to find out which
* one so that we can later form the appropriate command.
*/
static struct Scsi_Device_Template *scsi_get_request_dev(struct request *req)
{
struct gendisk *p = req->rq_disk;
return p ? *(struct Scsi_Device_Template **)p->private_data : NULL;
}
/* /*
* Function: scsi_io_completion() * Function: scsi_io_completion()
* *
...@@ -527,11 +518,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -527,11 +518,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
* requeueing right here - we will requeue down below * requeueing right here - we will requeue down below
* when we handle the bad sectors. * when we handle the bad sectors.
*/ */
SCpnt = __scsi_end_request(SCpnt, SCpnt = scsi_end_request(SCpnt, 1, good_sectors, result == 0);
1,
good_sectors,
result == 0,
1);
/* /*
* If the command completed without error, then either finish off the * If the command completed without error, then either finish off the
...@@ -574,7 +561,8 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -574,7 +561,8 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
* and quietly refuse further access. * and quietly refuse further access.
*/ */
SCpnt->device->changed = 1; SCpnt->device->changed = 1;
SCpnt = scsi_end_request(SCpnt, 0, this_count); SCpnt = scsi_end_request(SCpnt, 0,
this_count, 1);
return; return;
} else { } else {
/* /*
...@@ -606,14 +594,14 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -606,14 +594,14 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
scsi_queue_next_request(q, SCpnt); scsi_queue_next_request(q, SCpnt);
result = 0; result = 0;
} else { } else {
SCpnt = scsi_end_request(SCpnt, 0, this_count); SCpnt = scsi_end_request(SCpnt, 0, this_count, 1);
return; return;
} }
break; break;
case NOT_READY: case NOT_READY:
printk(KERN_INFO "Device %s not ready.\n", printk(KERN_INFO "Device %s not ready.\n",
req->rq_disk ? req->rq_disk->disk_name : ""); req->rq_disk ? req->rq_disk->disk_name : "");
SCpnt = scsi_end_request(SCpnt, 0, this_count); SCpnt = scsi_end_request(SCpnt, 0, this_count, 1);
return; return;
break; break;
case MEDIUM_ERROR: case MEDIUM_ERROR:
...@@ -623,7 +611,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -623,7 +611,7 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
(int) SCpnt->target, (int) SCpnt->lun); (int) SCpnt->target, (int) SCpnt->lun);
print_command(SCpnt->data_cmnd); print_command(SCpnt->data_cmnd);
print_sense("sd", SCpnt); print_sense("sd", SCpnt);
SCpnt = scsi_end_request(SCpnt, 0, block_sectors); SCpnt = scsi_end_request(SCpnt, 0, block_sectors, 1);
return; return;
default: default:
break; break;
...@@ -656,34 +644,11 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors, ...@@ -656,34 +644,11 @@ void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
* We sometimes get this cruft in the event that a medium error * We sometimes get this cruft in the event that a medium error
* isn't properly reported. * isn't properly reported.
*/ */
SCpnt = scsi_end_request(SCpnt, 0, req->current_nr_sectors); SCpnt = scsi_end_request(SCpnt, 0, req->current_nr_sectors, 1);
return; return;
} }
} }
/*
* Function: scsi_get_request_dev()
*
* Purpose: Find the upper-level driver that is responsible for this
* request
*
* Arguments: request - I/O request we are preparing to queue.
*
* Lock status: No locks assumed to be held, but as it happens the
* q->queue_lock is held when this is called.
*
* Returns: Nothing
*
* Notes: The requests in the request queue may have originated
* from any block device driver. We need to find out which
* one so that we can later form the appropriate command.
*/
struct Scsi_Device_Template *scsi_get_request_dev(struct request *req)
{
struct gendisk *p = req->rq_disk;
return p ? *(struct Scsi_Device_Template **)p->private_data : NULL;
}
/* /*
* Function: scsi_init_io() * Function: scsi_init_io()
* *
...@@ -763,7 +728,7 @@ static int scsi_init_io(Scsi_Cmnd *SCpnt) ...@@ -763,7 +728,7 @@ static int scsi_init_io(Scsi_Cmnd *SCpnt)
/* /*
* kill it. there should be no leftover blocks in this request * kill it. there should be no leftover blocks in this request
*/ */
SCpnt = scsi_end_request(SCpnt, 0, req->nr_sectors); SCpnt = scsi_end_request(SCpnt, 0, req->nr_sectors, 1);
BUG_ON(SCpnt); BUG_ON(SCpnt);
ret = BLKPREP_KILL; ret = BLKPREP_KILL;
out: out:
......
...@@ -75,7 +75,6 @@ EXPORT_SYMBOL(scsi_free_host_dev); ...@@ -75,7 +75,6 @@ EXPORT_SYMBOL(scsi_free_host_dev);
EXPORT_SYMBOL(scsi_sleep); EXPORT_SYMBOL(scsi_sleep);
EXPORT_SYMBOL(scsi_io_completion); EXPORT_SYMBOL(scsi_io_completion);
EXPORT_SYMBOL(scsi_end_request);
EXPORT_SYMBOL(scsi_register_blocked_host); EXPORT_SYMBOL(scsi_register_blocked_host);
EXPORT_SYMBOL(scsi_deregister_blocked_host); EXPORT_SYMBOL(scsi_deregister_blocked_host);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment