[PATCH] NVMe: Add rw_page support

Matthew Wilcox willy at linux.intel.com
Fri Nov 14 06:55:44 PST 2014


On Thu, Nov 13, 2014 at 05:05:38PM -0700, Keith Busch wrote:
> +static void pgrd_completion(struct nvme_queue *nvmeq, void *ctx,
> +						struct nvme_completion *cqe)
> +{
> +	struct request *req = ctx;
> +	struct nvme_cmd_info *cmd_rq = blk_mq_rq_to_pdu(req);
> +	struct page *page = req->special;
> +	u16 status = le16_to_cpup(&cqe->status) >> 1;
> +
> +	dma_unmap_page(nvmeq->q_dmadev, cmd_rq->dma, PAGE_CACHE_SIZE, DMA_FROM_DEVICE);
> +	page_endio(page, READ, status != NVME_SC_SUCCESS);

The third parameter to page_endio() is supposed to be an errno.  This will
happen to work fine since anything other than 0 and -ENOSPC gets translated
to -EIO, but it'd be better to make this line:

	page_endio(page, READ, nvme_error_status(status));

> +static void pgwr_completion(struct nvme_queue *nvmeq, void *ctx,
> +						struct nvme_completion *cqe)
> +{
> +	struct request *req = ctx;
> +	struct nvme_cmd_info *cmd_rq = blk_mq_rq_to_pdu(req);
> +	struct page *page = req->special;
> +	u16 status = le16_to_cpup(&cqe->status) >> 1;
> +
> +	dma_unmap_page(nvmeq->q_dmadev, cmd_rq->dma, PAGE_CACHE_SIZE, DMA_TO_DEVICE);
> +	page_endio(page, WRITE, status != NVME_SC_SUCCESS);

Here too.




More information about the Linux-nvme mailing list