Skip to content

Commit

Permalink
nvme/scsi: don't rely on BLK_MAX_CDB
Browse files Browse the repository at this point in the history
The NVMe SCSI emulation doesn't use BLOCK_PC requests, so BLK_MAX_CDB
doesn't have a meaning for it.  Instead opencode the value of 16
and refactor the code a bit so that related checks are next to each
other and we only need to use the value in one place.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jan 30, 2017
1 parent f605208 commit 1a7347c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/nvme/host/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2348,12 +2348,14 @@ static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr,

static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr)
{
u8 cmd[BLK_MAX_CDB];
u8 cmd[16];
int retcode;
unsigned int opcode;

if (hdr->cmdp == NULL)
return -EMSGSIZE;
if (hdr->cmd_len > sizeof(cmd))
return -EINVAL;
if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len))
return -EFAULT;

Expand Down Expand Up @@ -2452,8 +2454,6 @@ int nvme_sg_io(struct nvme_ns *ns, struct sg_io_hdr __user *u_hdr)
return -EFAULT;
if (hdr.interface_id != 'S')
return -EINVAL;
if (hdr.cmd_len > BLK_MAX_CDB)
return -EINVAL;

/*
* A positive return code means a NVMe status, which has been
Expand Down

0 comments on commit 1a7347c

Please sign in to comment.