From: Richard Weinberger <richard@nod.at>
To: linux-mtd@lists.infradead.org
Cc: boris.brezillon@free-electrons.com, dedekind1@gmail.com,
goliath@sigma-star.at, alex@nextthing.co, beanhuo@micron.com,
David Gstir <david@sigma-star.at>,
Richard Weinberger <richard@nod.at>
Subject: [PATCH 12/13] ubi: Add debugfs knob to force LEB consolidation
Date: Mon, 30 May 2016 14:04:33 +0200 [thread overview]
Message-ID: <1464609874-15488-13-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1464609874-15488-1-git-send-email-richard@nod.at>
From: David Gstir <david@sigma-star.at>
Normally UBI only consolidates LEB when free space is running low. This debugfs
knob changes this behaviour to always consolidate LEBs when possible.
Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
drivers/mtd/ubi/consolidate.c | 3 +++
drivers/mtd/ubi/debug.c | 10 ++++++++++
drivers/mtd/ubi/debug.h | 5 +++++
drivers/mtd/ubi/ubi.h | 4 ++++
4 files changed, 22 insertions(+)
diff --git a/drivers/mtd/ubi/consolidate.c b/drivers/mtd/ubi/consolidate.c
index de1479d..7313be0 100644
--- a/drivers/mtd/ubi/consolidate.c
+++ b/drivers/mtd/ubi/consolidate.c
@@ -333,6 +333,9 @@ bool ubi_conso_consolidation_needed(struct ubi_device *ubi)
if (!consolidation_possible(ubi))
return false;
+ if (ubi_dbg_force_leb_consolidation(ubi))
+ return true;
+
return ubi->free_count - ubi->beb_rsvd_pebs <=
ubi->consolidation_threshold;
}
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 6178fa1..14b0ce5 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -281,6 +281,8 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
val = d->emulate_bitflips;
else if (dent == d->dfs_emulate_io_failures)
val = d->emulate_io_failures;
+ else if (dent == d->dfs_force_leb_consolidation)
+ val = d->force_leb_consolidation;
else if (dent == d->dfs_emulate_power_cut) {
snprintf(buf, sizeof(buf), "%u\n", d->emulate_power_cut);
count = simple_read_from_buffer(user_buf, count, ppos,
@@ -374,6 +376,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
d->emulate_bitflips = val;
else if (dent == d->dfs_emulate_io_failures)
d->emulate_io_failures = val;
+ else if (dent == d->dfs_force_leb_consolidation)
+ d->force_leb_consolidation = val;
else
count = -EINVAL;
@@ -480,6 +484,12 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
goto out_remove;
d->dfs_power_cut_max = dent;
+ fname = "force_leb_consolidation";
+ dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, (void *)ubi_num,
+ &dfs_fops);
+ if (IS_ERR_OR_NULL(dent))
+ goto out_remove;
+ d->dfs_force_leb_consolidation = dent;
return 0;
out_remove:
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index c3ed0d5..c9bace4 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -121,6 +121,11 @@ static inline int ubi_dbg_chk_fastmap(const struct ubi_device *ubi)
return ubi->dbg.chk_fastmap;
}
+static inline int ubi_dbg_force_leb_consolidation(struct ubi_device *ubi)
+{
+ return ubi->dbg.force_leb_consolidation;
+}
+
static inline void ubi_enable_dbg_chk_fastmap(struct ubi_device *ubi)
{
ubi->dbg.chk_fastmap = 1;
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 47e5219..15c8ff6 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -414,6 +414,7 @@ struct ubi_wl_entry;
* @emulate_bitflips: emulate bit-flips for testing purposes
* @emulate_io_failures: emulate write/erase failures for testing purposes
* @emulate_power_cut: emulate power cut for testing purposes
+ * @force_leb_consolidation: always consolidate LEBs
* @power_cut_counter: count down for writes left until emulated power cut
* @power_cut_min: minimum number of writes before emulating a power cut
* @power_cut_max: maximum number of writes until emulating a power cut
@@ -424,6 +425,7 @@ struct ubi_wl_entry;
* @dfs_chk_fastmap: debugfs knob to enable UBI fastmap extra checks
* @dfs_emulate_bitflips: debugfs knob to emulate bit-flips
* @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures
+ * @dfs_force_leb_consolidation: debugfs knob to enable constant LEB conso.
* @dfs_emulate_power_cut: debugfs knob to emulate power cuts
* @dfs_power_cut_min: debugfs knob for minimum writes before power cut
* @dfs_power_cut_max: debugfs knob for maximum writes until power cut
@@ -435,6 +437,7 @@ struct ubi_debug_info {
unsigned int emulate_bitflips:1;
unsigned int emulate_io_failures:1;
unsigned int emulate_power_cut:2;
+ unsigned int force_leb_consolidation:1;
unsigned int power_cut_counter;
unsigned int power_cut_min;
unsigned int power_cut_max;
@@ -445,6 +448,7 @@ struct ubi_debug_info {
struct dentry *dfs_chk_fastmap;
struct dentry *dfs_emulate_bitflips;
struct dentry *dfs_emulate_io_failures;
+ struct dentry *dfs_force_leb_consolidation;
struct dentry *dfs_emulate_power_cut;
struct dentry *dfs_power_cut_min;
struct dentry *dfs_power_cut_max;
--
2.7.3
next prev parent reply other threads:[~2016-05-30 12:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 12:04 [RFC] UBI: MLC Support v0 Richard Weinberger
2016-05-30 12:04 ` [PATCH 01/13] ubi: Undo "UBI: modify ubi_wl_flush function to clear work queue for a lnum" Richard Weinberger
2016-05-30 12:04 ` [PATCH 02/13] ubi: Rework UBI worker Richard Weinberger
2016-05-30 12:04 ` [PATCH 03/13] ubi: auto re-size after UBI thread is ready Richard Weinberger
2016-05-30 12:04 ` [PATCH 04/13] ubi: Kill ubi->alc_mutex Richard Weinberger
2016-05-30 14:05 ` Richard Weinberger
2016-05-30 12:04 ` [PATCH 05/13] ubi: Get rid of __schedule_ubi_work() Richard Weinberger
2016-05-30 12:04 ` [PATCH 06/13] ubi: Remove tst_disable_bgt debugfs knob Richard Weinberger
2016-05-30 12:04 ` [PATCH 07/13] ubi: Move work related functions to work.c Richard Weinberger
2016-05-30 12:04 ` [PATCH 08/13] ubi: Remove lnum and vol_id from erase work Richard Weinberger
2016-05-30 12:04 ` [PATCH 09/13] ubi: Remove usless debug info from wear_leveling_worker() Richard Weinberger
2016-05-30 12:04 ` [PATCH 10/13] ubi: SLC mode Richard Weinberger
2016-05-30 12:04 ` [PATCH 11/13] ubi: LEB consolidation Richard Weinberger
2016-06-07 12:20 ` Boris Brezillon
2016-05-30 12:04 ` Richard Weinberger [this message]
2016-05-30 12:04 ` [PATCH 13/13] ubi: Add debugfs knob to trigger " Richard Weinberger
2016-06-03 12:40 ` [RFC] UBI: MLC Support v0 Boris Brezillon
2016-06-24 14:48 ` Bean Huo (beanhuo)
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=1464609874-15488-13-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=alex@nextthing.co \
--cc=beanhuo@micron.com \
--cc=boris.brezillon@free-electrons.com \
--cc=david@sigma-star.at \
--cc=dedekind1@gmail.com \
--cc=goliath@sigma-star.at \
--cc=linux-mtd@lists.infradead.org \
/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).