nvme: add helper nvme_cleanup_cmd()
authorMing Lin <ming.l@ssi.samsung.com>
Mon, 25 Apr 2016 21:33:20 +0000 (14:33 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 2 May 2016 15:11:58 +0000 (09:11 -0600)
This hides command cleanup into nvme.h and fabrics drivers will
also use it.

Signed-off-by: Ming Lin <ming.l@ssi.samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index 631a11e15b7c2824941da21000995f44141c314a..114b928738946b9c6c00a00b13651914ffa27d6d 100644 (file)
@@ -182,6 +182,12 @@ static inline unsigned nvme_map_len(struct request *rq)
                return blk_rq_bytes(rq);
 }
 
+static inline void nvme_cleanup_cmd(struct request *req)
+{
+       if (req->cmd_flags & REQ_DISCARD)
+               kfree(req->completion_data);
+}
+
 static inline int nvme_error_status(u16 status)
 {
        switch (status & 0x7ff) {
index 82a0fc200f4468b83142a4a1398982da67a3a029..077e9bf6a1b82bf085b0d9503aa55a482e9873ea 100644 (file)
@@ -321,8 +321,7 @@ static void nvme_free_iod(struct nvme_dev *dev, struct request *req)
        __le64 **list = iod_list(req);
        dma_addr_t prp_dma = iod->first_dma;
 
-       if (req->cmd_flags & REQ_DISCARD)
-               kfree(req->completion_data);
+       nvme_cleanup_cmd(req);
 
        if (iod->npages == 0)
                dma_pool_free(dev->prp_small_pool, list[0], prp_dma);