Skip to contentSkip to conversation

lightnvm: unlock rq and free ppa_list after submission failed

PATCH In review Wenwei Tao 2 participants 5 messages Dec 21, 2015 – Dec 22, 2015

lore
Share & tools
lore

Wenwei Tao

author
#0 lore raw

PATCH 1/1 lightnvm: unlock rq and free ppa_list after submission failed

after io submission failed, before free rq, delete rq from rrpc's inflight list, leave no bad item in the list. And free rq's ppa_list to avoid memory leak.

---
 drivers/lightnvm/rrpc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/lightnvm/rrpc.c +6 -0
index a1e7488..c0886a8 100644
@@ -843,6 +843,12 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
 	if (err) {
 		pr_err("rrpc: I/O submission failed: %d\n", err);
 		bio_put(bio);
+		if (!(flags & NVM_IOTYPE_GC)) {
+			rrpc_unlock_rq(rrpc, rqd);
+			if (rqd->nr_pages > 1)
+				nvm_dev_dma_free(rrpc->dev,
+			rqd->ppa_list, rqd->dma_ppa_list);
+		}
 		return NVM_IO_ERR;
 	}
 
Signature · 1 line
1.8.3.1
author
#1 lore raw

This patch is based on [PATCH] lightnvm: fix bio submission issue
https://lkml.org/lkml/2015/12/9/394

2015-12-21 15:32 GMT+08:00 Wenwei Tao <[email protected]>:

Quoted 29 lines

after io submission failed, before free rq, delete rq from rrpc's inflight list, leave no bad item in the list. And free rq's ppa_list to avoid memory leak.

---
 drivers/lightnvm/rrpc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/lightnvm/rrpc.c +6 -1
index a1e7488..c0886a8 100644
@@ -843,6 +843,12 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
        if (err) {
                pr_err("rrpc: I/O submission failed: %d\n", err);
                bio_put(bio);
+               if (!(flags & NVM_IOTYPE_GC)) {
+                       rrpc_unlock_rq(rrpc, rqd);
+                       if (rqd->nr_pages > 1)
+                               nvm_dev_dma_free(rrpc->dev,
+                       rqd->ppa_list, rqd->dma_ppa_list);
+               }
                return NVM_IO_ERR;
        }
 
--

1.8.3.1

#2 lore raw
In reply to Wenwei Tao
Quoted 17 lines · Wenwei Tao

after io submission failed, before free rq, delete rq from rrpc's inflight list, leave no bad item in the list. And free rq's ppa_list to avoid memory leak.

---
  drivers/lightnvm/rrpc.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/lightnvm/rrpc.c +0 -0
index a1e7488..c0886a8 100644
@@ -843,6 +843,12 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
  	if (err) {
  		pr_err("rrpc: I/O submission failed: %d\n", err);

drivers/lightnvm/rrpc.c static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, · line 854

Quoted 10 lines
drivers/lightnvm/rrpc.c +6 -0
  		bio_put(bio);
+		if (!(flags & NVM_IOTYPE_GC)) {
+			rrpc_unlock_rq(rrpc, rqd);
+			if (rqd->nr_pages > 1)
+				nvm_dev_dma_free(rrpc->dev,
+			rqd->ppa_list, rqd->dma_ppa_list);
+		}
  		return NVM_IO_ERR;
  	}
 

I can't seem to find the bug. nvm_dev_dma_free is called when rrpc_write_ppalist_rq and rrpc_read_ppalist_rq fails. Where is it missing?

author
#3 lore raw

When rrpc_write_ppalist_rq and rrpc_read_ppalist_rq succeed, we setup rq correctly, but nvm_submit_io failed due to cannot allocate request or nvme_nvm_command, we return error but forget to do the cleanup job this patch mentioned.

2015-12-21 19:22 GMT+08:00 Matias Bjørling <[email protected]>:

Quoted 33 lines · Wenwei Tao
Quoted 19 lines

after io submission failed, before free rq, delete rq from rrpc's inflight list, leave no bad item in the list. And free rq's ppa_list to avoid memory leak.

---
  drivers/lightnvm/rrpc.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/lightnvm/rrpc.c +0 -0
index a1e7488..c0886a8 100644
@@ -843,6 +843,12 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct
 bio *bio,
        if (err) {

drivers/lightnvm/rrpc.c static int rrpc_submit_io(struct rrpc *rrpc, struct · line 854

Quoted 10 lines
drivers/lightnvm/rrpc.c +6 -0
                pr_err("rrpc: I/O submission failed: %d\n", err);
                bio_put(bio);
+               if (!(flags & NVM_IOTYPE_GC)) {
+                       rrpc_unlock_rq(rrpc, rqd);
+                       if (rqd->nr_pages > 1)
+                               nvm_dev_dma_free(rrpc->dev,
+                       rqd->ppa_list, rqd->dma_ppa_list);
+               }
                return NVM_IO_ERR;
        }

I can't seem to find the bug. nvm_dev_dma_free is called when rrpc_write_ppalist_rq and rrpc_read_ppalist_rq fails. Where is it missing?

#4 lore raw
Quoted 4 lines

When rrpc_write_ppalist_rq and rrpc_read_ppalist_rq succeed, we setup rq correctly, but nvm_submit_io failed due to cannot allocate request or nvme_nvm_command, we return error but forget to do the cleanup job this patch mentioned.

Thanks. I've included that explanation instead for the commit message. I've applied it for 4.5 (together with your previous patch).