Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 286287
b: refs/heads/master
c: 6c7d494
h: refs/heads/master
i:
  286285: 64e7af1
  286283: 47a23a1
  286279: b060022
  286271: aacdc5d
v: v3
  • Loading branch information
Matthew Wilcox committed Nov 4, 2011
1 parent 5abfc32 commit c1fabb3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 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: 9d4af1b7796ba02b73a79a8694399e5a3cd1c55d
refs/heads/master: 6c7d49455ceb63064f992347d9185ff5bf43497a
27 changes: 17 additions & 10 deletions trunk/drivers/block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,29 +1035,37 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
struct nvme_user_io io;
struct nvme_command c;
unsigned length;
u32 result;
int nents, status;
struct scatterlist *sg;
struct nvme_prps *prps;

if (copy_from_user(&io, uio, sizeof(io)))
return -EFAULT;
length = io.nblocks << io.block_shift;
nents = nvme_map_user_pages(dev, io.opcode & 1, io.addr, length, &sg);
length = (io.nblocks + 1) << ns->lba_shift;

switch (io.opcode) {
case nvme_cmd_write:
case nvme_cmd_read:
nents = nvme_map_user_pages(dev, io.opcode & 1, io.addr,
length, &sg);
default:
return -EFAULT;
}

if (nents < 0)
return nents;

memset(&c, 0, sizeof(c));
c.rw.opcode = io.opcode;
c.rw.flags = io.flags;
c.rw.nsid = cpu_to_le32(io.nsid);
c.rw.nsid = cpu_to_le32(ns->ns_id);
c.rw.slba = cpu_to_le64(io.slba);
c.rw.length = cpu_to_le16(io.nblocks - 1);
c.rw.length = cpu_to_le16(io.nblocks);
c.rw.control = cpu_to_le16(io.control);
c.rw.dsmgmt = cpu_to_le16(io.dsmgmt);
c.rw.reftag = cpu_to_le32(io.reftag); /* XXX: endian? */
c.rw.apptag = cpu_to_le16(io.apptag);
c.rw.appmask = cpu_to_le16(io.appmask);
c.rw.reftag = io.reftag;
c.rw.apptag = io.apptag;
c.rw.appmask = io.appmask;
/* XXX: metadata */
prps = nvme_setup_prps(dev, &c.common, sg, length);

Expand All @@ -1069,11 +1077,10 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
* additional races since q_lock already protects against other CPUs.
*/
put_nvmeq(nvmeq);
status = nvme_submit_sync_cmd(nvmeq, &c, &result, IO_TIMEOUT);
status = nvme_submit_sync_cmd(nvmeq, &c, NULL, IO_TIMEOUT);

nvme_unmap_user_pages(dev, io.opcode & 1, io.addr, length, sg, nents);
nvme_free_prps(dev, prps);
put_user(result, &uio->result);
return status;
}

Expand Down
8 changes: 3 additions & 5 deletions trunk/include/linux/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,15 @@ struct nvme_user_io {
__u8 opcode;
__u8 flags;
__u16 control;
__u32 nsid;
__u16 nblocks;
__u16 rsvd;
__u64 metadata;
__u64 addr;
__u64 slba;
__u16 nblocks;
__u16 block_shift;
__u32 dsmgmt;
__u32 reftag;
__u16 apptag;
__u16 appmask;
__u32 result;
};

struct nvme_dlfw {
Expand All @@ -395,7 +393,7 @@ struct nvme_dlfw {
#define NVME_IOCTL_IDENTIFY_NS _IOW('N', 0x40, struct nvme_id_ns)
#define NVME_IOCTL_IDENTIFY_CTRL _IOW('N', 0x41, struct nvme_id_ctrl)
#define NVME_IOCTL_GET_RANGE_TYPE _IOW('N', 0x42, struct nvme_lba_range_type)
#define NVME_IOCTL_SUBMIT_IO _IOWR('N', 0x43, struct nvme_user_io)
#define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x43, struct nvme_user_io)
#define NVME_IOCTL_DOWNLOAD_FW _IOW('N', 0x44, struct nvme_dlfw)
#define NVME_IOCTL_ACTIVATE_FW _IO('N', 0x45)

Expand Down

0 comments on commit c1fabb3

Please sign in to comment.