Commit fc8183c1 authored by Jens Axboe's avatar Jens Axboe

[PATCH] scsi_ioctl reference counting

Now that we properly track queue references, that showed a bug in
scsi_ioctl.c, where it was dropping queues that it had never properly
gotten in the first place.
parent ace416a3
...@@ -406,26 +406,37 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar ...@@ -406,26 +406,37 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
if (!q) if (!q)
return -ENXIO; return -ENXIO;
if (blk_get_queue(q))
return -ENXIO;
switch (cmd) { switch (cmd) {
/* /*
* new sgv3 interface * new sgv3 interface
*/ */
case SG_GET_VERSION_NUM: case SG_GET_VERSION_NUM:
return sg_get_version((int *) arg); err = sg_get_version((int *) arg);
break;
case SCSI_IOCTL_GET_IDLUN: case SCSI_IOCTL_GET_IDLUN:
return scsi_get_idlun(q, (int *) arg); err = scsi_get_idlun(q, (int *) arg);
break;
case SCSI_IOCTL_GET_BUS_NUMBER: case SCSI_IOCTL_GET_BUS_NUMBER:
return scsi_get_bus(q, (int *) arg); err = scsi_get_bus(q, (int *) arg);
break;
case SG_SET_TIMEOUT: case SG_SET_TIMEOUT:
return sg_set_timeout(q, (int *) arg); err = sg_set_timeout(q, (int *) arg);
break;
case SG_GET_TIMEOUT: case SG_GET_TIMEOUT:
return sg_get_timeout(q); err = sg_get_timeout(q);
break;
case SG_GET_RESERVED_SIZE: case SG_GET_RESERVED_SIZE:
return sg_get_reserved_size(q, (int *) arg); err = sg_get_reserved_size(q, (int *) arg);
break;
case SG_SET_RESERVED_SIZE: case SG_SET_RESERVED_SIZE:
return sg_set_reserved_size(q, (int *) arg); err = sg_set_reserved_size(q, (int *) arg);
break;
case SG_EMULATED_HOST: case SG_EMULATED_HOST:
return sg_emulated_host(q, (int *) arg); err = sg_emulated_host(q, (int *) arg);
break;
case SG_IO: case SG_IO:
err = bd_claim(bdev, current); err = bd_claim(bdev, current);
if (err) if (err)
...@@ -437,8 +448,9 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar ...@@ -437,8 +448,9 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
* old junk scsi send command ioctl * old junk scsi send command ioctl
*/ */
case SCSI_IOCTL_SEND_COMMAND: case SCSI_IOCTL_SEND_COMMAND:
err = -EINVAL;
if (!arg) if (!arg)
return -EINVAL; break;
err = bd_claim(bdev, current); err = bd_claim(bdev, current);
if (err) if (err)
...@@ -449,11 +461,6 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar ...@@ -449,11 +461,6 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
case CDROMCLOSETRAY: case CDROMCLOSETRAY:
close = 1; close = 1;
case CDROMEJECT: case CDROMEJECT:
if (blk_get_queue(q)) {
err = -ENXIO;
break;
}
rq = blk_get_request(q, WRITE, __GFP_WAIT); rq = blk_get_request(q, WRITE, __GFP_WAIT);
rq->flags |= REQ_BLOCK_PC; rq->flags |= REQ_BLOCK_PC;
rq->data = NULL; rq->data = NULL;
...@@ -467,7 +474,7 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar ...@@ -467,7 +474,7 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
blk_put_request(rq); blk_put_request(rq);
break; break;
default: default:
return -ENOTTY; err = -ENOTTY;
} }
blk_put_queue(q); blk_put_queue(q);
......
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