Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288934
b: refs/heads/master
c: c77b63b
h: refs/heads/master
v: v3
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent 5821b01 commit a5e9fcc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 59d22950b274182b006e4071d6690bfbc94d7267
refs/heads/master: c77b63b639f52b2e92d0bbaa94f33a78939f3e7c
48 changes: 22 additions & 26 deletions trunk/drivers/staging/hv/storvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,13 +1239,16 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
mempool_free(cmd_request, memp->request_mempool);
}

static bool storvsc_check_scsi_cmd(struct scsi_cmnd *scmnd)
static bool storvsc_scsi_cmd_ok(struct scsi_cmnd *scmnd)
{
bool allowed = true;
u8 scsi_op = scmnd->cmnd[0];

switch (scsi_op) {
/* smartd sends this command, which will offline the device */
/*
* smartd sends this command and the host does not handle
* this. So, don't send it.
*/
case SET_WINDOW:
scmnd->result = ILLEGAL_REQUEST << 16;
allowed = false;
Expand All @@ -1270,32 +1273,26 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
struct vmscsi_request *vm_srb;
struct stor_mem_pools *memp = scmnd->device->hostdata;

if (storvsc_check_scsi_cmd(scmnd) == false) {
if (!storvsc_scsi_cmd_ok(scmnd)) {
scmnd->scsi_done(scmnd);
return 0;
}

/* If retrying, no need to prep the cmd */
if (scmnd->host_scribble) {

cmd_request =
(struct storvsc_cmd_request *)scmnd->host_scribble;

goto retry_request;
}

request_size = sizeof(struct storvsc_cmd_request);

cmd_request = mempool_alloc(memp->request_mempool,
GFP_ATOMIC);

/*
* We might be invoked in an interrupt context; hence
* mempool_alloc() can fail.
*/
if (!cmd_request)
return SCSI_MLQUEUE_DEVICE_BUSY;

memset(cmd_request, 0, sizeof(struct storvsc_cmd_request));

/* Setup the cmd request */
cmd_request->bounce_sgl_count = 0;
cmd_request->bounce_sgl = NULL;
cmd_request->cmd = scmnd;

scmnd->host_scribble = (unsigned char *)cmd_request;
Expand Down Expand Up @@ -1344,11 +1341,8 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
scsi_bufflen(scmnd),
vm_srb->data_in);
if (!cmd_request->bounce_sgl) {
scmnd->host_scribble = NULL;
mempool_free(cmd_request,
memp->request_mempool);

return SCSI_MLQUEUE_HOST_BUSY;
ret = SCSI_MLQUEUE_HOST_BUSY;
goto queue_error;
}

cmd_request->bounce_sgl_count =
Expand Down Expand Up @@ -1377,24 +1371,26 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
}

retry_request:
/* Invokes the vsc to start an IO */
ret = storvsc_do_io(dev, &cmd_request->request);

if (ret == -EAGAIN) {
/* no more space */

if (cmd_request->bounce_sgl_count)
if (cmd_request->bounce_sgl_count) {
destroy_bounce_buffer(cmd_request->bounce_sgl,
cmd_request->bounce_sgl_count);

mempool_free(cmd_request, memp->request_mempool);

scmnd->host_scribble = NULL;

ret = SCSI_MLQUEUE_DEVICE_BUSY;
ret = SCSI_MLQUEUE_DEVICE_BUSY;
goto queue_error;
}
}

return 0;

queue_error:
mempool_free(cmd_request, memp->request_mempool);
scmnd->host_scribble = NULL;
return ret;
}

Expand Down

0 comments on commit a5e9fcc

Please sign in to comment.