From: Hans Holmberg <hans.ml.holmberg@owltronix.com>
To: Matias Bjorling <mb@lightnvm.io>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Javier Gonzales <jg@lightnvm.io>,
Hans Holmberg <hans.ml.holmberg@owltronix.com>,
Hans Holmberg <hans.holmberg@cnexlabs.com>
Subject: [PATCH 3/9] lightnvm: pblk: free full lines during recovery
Date: Tue, 3 Oct 2017 12:05:07 +0200 [thread overview]
Message-ID: <1507025113-13351-4-git-send-email-hans.ml.holmberg@owltronix.com> (raw)
In-Reply-To: <1507025113-13351-1-git-send-email-hans.ml.holmberg@owltronix.com>
From: Hans Holmberg <hans.holmberg@cnexlabs.com>
When rebuilding the L2P table, any full lines(lines without any
valid sectors) will be identified. If these lines are not freed,
we risk not being able to allocate the first data line.
This patch refactors the part of GC that frees empty lines
into a separate function and adds a call to this after the
L2P table has been rebuilt.
Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
drivers/lightnvm/pblk-gc.c | 32 ++++++++++++++++++++------------
drivers/lightnvm/pblk-init.c | 3 +++
drivers/lightnvm/pblk.h | 1 +
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
index 81efac1..374089f 100644
--- a/drivers/lightnvm/pblk-gc.c
+++ b/drivers/lightnvm/pblk-gc.c
@@ -330,26 +330,16 @@ static bool pblk_gc_should_run(struct pblk_gc *gc, struct pblk_rl *rl)
return ((gc->gc_active) && (nr_blocks_need > nr_blocks_free));
}
-/*
- * Lines with no valid sectors will be returned to the free list immediately. If
- * GC is activated - either because the free block count is under the determined
- * threshold, or because it is being forced from user space - only lines with a
- * high count of invalid sectors will be recycled.
- */
-static void pblk_gc_run(struct pblk *pblk)
+void pblk_gc_free_full_lines(struct pblk *pblk)
{
struct pblk_line_mgmt *l_mg = &pblk->l_mg;
- struct pblk_gc *gc = &pblk->gc;
struct pblk_line *line;
- struct list_head *group_list;
- bool run_gc;
- int inflight_gc, gc_group = 0, prev_group = 0;
do {
spin_lock(&l_mg->gc_lock);
if (list_empty(&l_mg->gc_full_list)) {
spin_unlock(&l_mg->gc_lock);
- break;
+ return;
}
line = list_first_entry(&l_mg->gc_full_list,
@@ -365,6 +355,24 @@ static void pblk_gc_run(struct pblk *pblk)
kref_put(&line->ref, pblk_line_put);
} while (1);
+}
+
+/*
+ * Lines with no valid sectors will be returned to the free list immediately. If
+ * GC is activated - either because the free block count is under the determined
+ * threshold, or because it is being forced from user space - only lines with a
+ * high count of invalid sectors will be recycled.
+ */
+static void pblk_gc_run(struct pblk *pblk)
+{
+ struct pblk_line_mgmt *l_mg = &pblk->l_mg;
+ struct pblk_gc *gc = &pblk->gc;
+ struct pblk_line *line;
+ struct list_head *group_list;
+ bool run_gc;
+ int inflight_gc, gc_group = 0, prev_group = 0;
+
+ pblk_gc_free_full_lines(pblk);
run_gc = pblk_gc_should_run(&pblk->gc, &pblk->rl);
if (!run_gc || (atomic_read(&gc->inflight_gc) >= PBLK_GC_L_QD))
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index ec7974b..1cc3de4 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -508,6 +508,9 @@ static int pblk_lines_configure(struct pblk *pblk, int flags)
}
}
+ /* Free full lines directly as GC has not been started yet */
+ pblk_gc_free_full_lines(pblk);
+
if (!line) {
/* Configure next line for user data */
line = pblk_line_get_first_data(pblk);
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index eaf5397..f76583b 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -831,6 +831,7 @@ void pblk_gc_should_start(struct pblk *pblk);
void pblk_gc_should_stop(struct pblk *pblk);
void pblk_gc_should_kick(struct pblk *pblk);
void pblk_gc_kick(struct pblk *pblk);
+void pblk_gc_free_full_lines(struct pblk *pblk);
void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled,
int *gc_active);
int pblk_gc_sysfs_force(struct pblk *pblk, int force);
--
2.7.4
next prev parent reply other threads:[~2017-10-03 10:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 10:05 [PATCH 0/9] recovery robustness improvements Hans Holmberg
2017-10-03 10:05 ` [PATCH 1/9] lightnvm: pblk: prevent gc kicks when gc is not operational Hans Holmberg
2017-10-03 10:27 ` Javier González
2017-10-03 10:05 ` [PATCH 2/9] lightnvm: pblk: recover partially written lines correctly Hans Holmberg
2017-10-03 10:28 ` Javier González
2017-10-03 10:05 ` Hans Holmberg [this message]
2017-10-03 10:36 ` [PATCH 3/9] lightnvm: pblk: free full lines during recovery Javier González
2017-10-03 10:05 ` [PATCH 4/9] lightnvm: pblk: start gc if needed during init Hans Holmberg
2017-10-03 10:36 ` Javier González
2017-10-03 10:05 ` [PATCH 5/9] lightnvm: pblk: consider bad sectors in emeta during recovery Hans Holmberg
2017-10-03 10:38 ` Javier González
2017-10-03 10:05 ` [PATCH 6/9] lightnvm: pblk: shut down gc gracefully during exit Hans Holmberg
2017-10-03 10:38 ` Javier González
2017-10-03 10:05 ` [PATCH 7/9] lightnvm: pblk: add l2p crc debug printouts Hans Holmberg
2017-10-03 10:39 ` Javier González
2017-10-03 10:05 ` [PATCH 8/9] lightnvm: pblk: gc all lines in the pipeline before exit Hans Holmberg
2017-10-03 10:40 ` Javier González
2017-10-03 10:05 ` [PATCH 9/9] lightnvm: pblk: correct valid lba count calculation Hans Holmberg
2017-10-03 10:41 ` Javier González
2017-10-03 10:51 ` [PATCH 0/9] recovery robustness improvements Javier González
2017-10-03 13:53 ` Hans Holmberg
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=1507025113-13351-4-git-send-email-hans.ml.holmberg@owltronix.com \
--to=hans.ml.holmberg@owltronix.com \
--cc=hans.holmberg@cnexlabs.com \
--cc=jg@lightnvm.io \
--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
all inboxes | Powered by JetHome®