From: "Javier González" <jg@lightnvm.io>
To: mb@lightnvm.io
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Javier González" <javier@cnexlabs.com>
Subject: [PATCH 4/5] lightnvm: pblk: free metadata on line alloc failure
Date: Sat, 22 Apr 2017 01:32:48 +0200 [thread overview]
Message-ID: <1492817569-13532-5-git-send-email-javier@cnexlabs.com> (raw)
In-Reply-To: <1492817569-13532-1-git-send-email-javier@cnexlabs.com>
When a line allocation fails, for example, due to having too many bad
blocks, free its metadata correctly.
Fixes: a4bd217b4326 "lightnvm: physical block device (pblk) target"
Signed-off-by: Javier González <javier@cnexlabs.com>
---
drivers/lightnvm/pblk-core.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 7eb62ec..ac3742b 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1127,6 +1127,7 @@ static struct pblk_line *pblk_line_retry(struct pblk *pblk,
spin_lock(&l_mg->free_lock);
retry_line = pblk_line_get(pblk);
if (!retry_line) {
+ l_mg->data_line = NULL;
spin_unlock(&l_mg->free_lock);
return NULL;
}
@@ -1134,18 +1135,17 @@ static struct pblk_line *pblk_line_retry(struct pblk *pblk,
retry_line->smeta = line->smeta;
retry_line->emeta = line->emeta;
retry_line->meta_line = line->meta_line;
- retry_line->map_bitmap = line->map_bitmap;
- retry_line->invalid_bitmap = line->invalid_bitmap;
- line->map_bitmap = NULL;
- line->invalid_bitmap = NULL;
- line->smeta = NULL;
- line->emeta = NULL;
+ pblk_line_free(pblk, line);
l_mg->data_line = retry_line;
spin_unlock(&l_mg->free_lock);
- if (pblk_line_erase(pblk, retry_line))
+ if (pblk_line_erase(pblk, retry_line)) {
+ spin_lock(&l_mg->free_lock);
+ l_mg->data_line = NULL;
+ spin_unlock(&l_mg->free_lock);
return NULL;
+ }
pblk_rl_free_lines_dec(&pblk->rl, retry_line);
@@ -1299,6 +1299,8 @@ void pblk_line_free(struct pblk *pblk, struct pblk_line *line)
line->map_bitmap = NULL;
line->invalid_bitmap = NULL;
+ line->smeta = NULL;
+ line->emeta = NULL;
}
void pblk_line_put(struct kref *ref)
--
2.7.4
next prev parent reply other threads:[~2017-04-21 23:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 23:32 [PATCH 0/5] lightnvm: pblk extra patches for 4.12 Javier González
2017-04-21 23:32 ` [PATCH 1/5] lightnvm: pblk: fix race condition on line retry Javier González
2017-04-22 8:51 ` Matias Bjørling
2017-04-21 23:32 ` [PATCH 2/5] lightnvm: pblk: fix bad error check Javier González
2017-04-22 8:52 ` Matias Bjørling
2017-04-21 23:32 ` [PATCH 3/5] lightnvm: pblk: fix memory leak on error path Javier González
2017-04-22 8:57 ` Matias Bjørling
2017-04-21 23:32 ` Javier González [this message]
2017-04-22 9:02 ` [PATCH 4/5] lightnvm: pblk: free metadata on line alloc failure Matias Bjørling
2017-04-21 23:32 ` [PATCH 5/5] lightnvm: pblk: fix erase counters on error fail Javier González
2017-04-22 9:22 ` Matias Bjørling
2017-04-22 9:31 ` Javier González
2017-04-23 17:59 ` Matias Bjørling
2017-04-23 18:18 ` Javier González
2017-04-23 18:00 ` [PATCH 0/5] lightnvm: pblk extra patches for 4.12 Matias Bjørling
2017-04-23 22:58 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1492817569-13532-5-git-send-email-javier@cnexlabs.com \
--to=jg@lightnvm.io \
--cc=javier@cnexlabs.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).