From: Teresa Remmet <t.remmet@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH 04/62] UBI: wl: Rename cancel flag to shutdown
Date: Mon, 23 May 2016 10:25:52 +0200 [thread overview]
Message-ID: <1463992010-31537-5-git-send-email-t.remmet@phytec.de> (raw)
In-Reply-To: <1463992010-31537-1-git-send-email-t.remmet@phytec.de>
From: Richard Weinberger <richard@nod.at>
It confused me more than once that the cancel flag of the
work function does not indicate the cancellation of a single work.
In fact it indicates the WL sub-system shutdown and therefore
worker functions have to free their wl_entries too.
That's why you cannot cancel a single work, you can only shutdown
all works.
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
drivers/mtd/ubi/ubi.h | 9 +++++----
drivers/mtd/ubi/wl.c | 24 +++++++++++++-----------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 51a0112..df104db 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -691,14 +691,15 @@ struct ubi_attach_info {
* @torture: if the physical eraseblock has to be tortured
* @anchor: produce a anchor PEB to by used by fastmap
*
- * The @func pointer points to the worker function. If the @cancel argument is
- * not zero, the worker has to free the resources and exit immediately. The
- * worker has to return zero in case of success and a negative error code in
+ * The @func pointer points to the worker function. If the @shutdown argument is
+ * not zero, the worker has to free the resources and exit immediately as the
+ * WL sub-system is shutting down.
+ * The worker has to return zero in case of success and a negative error code in
* case of failure.
*/
struct ubi_work {
struct list_head list;
- int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int cancel);
+ int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int shutdown);
/* The below fields are only relevant to erasure works */
struct ubi_wl_entry *e;
int vol_id;
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index cb2f9d7..cdfc41c0 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -816,7 +816,7 @@ static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
}
static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
- int cancel);
+ int shutdown);
#ifdef CONFIG_MTD_UBI_FASTMAP
/**
@@ -939,14 +939,15 @@ int ubi_wl_put_fm_peb(struct ubi_device *ubi, struct ubi_wl_entry *fm_e,
* wear_leveling_worker - wear-leveling worker function.
* @ubi: UBI device description object
* @wrk: the work object
- * @cancel: non-zero if the worker has to free memory and exit
+ * @shutdown: non-zero if the worker has to free memory and exit
+ * because the WL-subsystem is shutting down
*
* This function copies a more worn out physical eraseblock to a less worn out
* one. Returns zero in case of success and a negative error code in case of
* failure.
*/
static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
- int cancel)
+ int shutdown)
{
int err, scrubbing = 0, torture = 0, protect = 0, erroneous = 0;
int vol_id = -1, uninitialized_var(lnum);
@@ -957,7 +958,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
struct ubi_vid_hdr *vid_hdr;
kfree(wrk);
- if (cancel)
+ if (shutdown)
return 0;
vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
@@ -1333,7 +1334,8 @@ int ubi_ensure_anchor_pebs(struct ubi_device *ubi)
* erase_worker - physical eraseblock erase worker function.
* @ubi: UBI device description object
* @wl_wrk: the work object
- * @cancel: non-zero if the worker has to free memory and exit
+ * @shutdown: non-zero if the worker has to free memory and exit
+ * because the WL sub-system is shutting down
*
* This function erases a physical eraseblock and perform torture testing if
* needed. It also takes care about marking the physical eraseblock bad if
@@ -1341,7 +1343,7 @@ int ubi_ensure_anchor_pebs(struct ubi_device *ubi)
* failure.
*/
static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
- int cancel)
+ int shutdown)
{
struct ubi_wl_entry *e = wl_wrk->e;
int pnum = e->pnum;
@@ -1349,7 +1351,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
int lnum = wl_wrk->lnum;
int err, available_consumed = 0;
- if (cancel) {
+ if (shutdown) {
dbg_wl("cancel erasure of PEB %d EC %d", pnum, e->ec);
kfree(wl_wrk);
kfree(e);
@@ -1667,10 +1669,10 @@ static void tree_destroy(struct rb_root *root)
}
/**
- * cancel_pending - cancel all pending works.
+ * shutdown_work - shutdown all pending works.
* @ubi: UBI device description object
*/
-static void cancel_pending(struct ubi_device *ubi)
+static void shutdown_work(struct ubi_device *ubi)
{
while (!list_empty(&ubi->works)) {
struct ubi_work *wrk;
@@ -1807,7 +1809,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
return 0;
out_free:
- cancel_pending(ubi);
+ shutdown_work(ubi);
tree_destroy(&ubi->used);
tree_destroy(&ubi->free);
tree_destroy(&ubi->scrub);
@@ -1839,7 +1841,7 @@ static void protection_queue_destroy(struct ubi_device *ubi)
void ubi_wl_close(struct ubi_device *ubi)
{
dbg_wl("close the WL sub-system");
- cancel_pending(ubi);
+ shutdown_work(ubi);
protection_queue_destroy(ubi);
tree_destroy(&ubi->used);
tree_destroy(&ubi->erroneous);
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-05-23 8:28 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-23 8:25 [PATCH 00/62] Update UBI Teresa Remmet
2016-05-23 8:25 ` [PATCH 01/62] UBI: add missing kmem_cache_free() in process_pool_aeb error path Teresa Remmet
2016-05-23 8:25 ` [PATCH 02/62] UBI: Improve comment on work_sem Teresa Remmet
2016-05-23 8:25 ` [PATCH 03/62] UBI: ubi_eba_read_leb: Remove in vain variable assignment Teresa Remmet
2016-05-23 8:25 ` Teresa Remmet [this message]
2016-05-23 8:25 ` [PATCH 05/62] UBI: Fix trivial typo in __schedule_ubi_work Teresa Remmet
2016-05-23 8:25 ` [PATCH 06/62] UBI: Fastmap: Calc fastmap size correctly Teresa Remmet
2016-05-23 8:25 ` [PATCH 07/62] UBI: Extend UBI layer debug/messaging capabilities Teresa Remmet
2016-05-23 8:25 ` [PATCH 08/62] UBI: vtbl: Use ubi_eba_atomic_leb_change() Teresa Remmet
2016-05-23 8:25 ` [PATCH 09/62] UBI: Fix double free after do_sync_erase() Teresa Remmet
2016-05-23 8:25 ` [PATCH 10/62] UBI: Fix invalid vfree() Teresa Remmet
2016-05-23 8:25 ` [PATCH 11/62] UBI: extend UBI layer debug/messaging capabilities - cosmetics Teresa Remmet
2016-05-23 8:26 ` [PATCH 12/62] UBI: clean-up printing helpers Teresa Remmet
2016-05-23 8:26 ` [PATCH 13/62] UBI: do propagate positive error codes up Teresa Remmet
2016-05-23 8:26 ` [PATCH 14/62] UBI: Fastmap: Care about the protection queue Teresa Remmet
2016-05-23 8:26 ` [PATCH 15/62] UBI: fix missing brace control flow Teresa Remmet
2016-05-23 8:26 ` [PATCH 16/62] UBI: account for bitflips in both the VID header and data Teresa Remmet
2016-05-23 8:26 ` [PATCH 17/62] UBI: fix out of bounds write Teresa Remmet
2016-05-23 8:26 ` [PATCH 18/62] UBI: initialize LEB number variable Teresa Remmet
2016-05-23 8:26 ` [PATCH 19/62] UBI: align comment for readability Teresa Remmet
2016-05-23 8:26 ` [PATCH 20/62] UBI: Split __wl_get_peb() Teresa Remmet
2016-05-23 8:26 ` [PATCH 21/62] UBI: Fastmap: Make ubi_refill_pools() fair Teresa Remmet
2016-05-23 8:26 ` [PATCH 22/62] UBI: Fastmap: Don't allocate new ubi_wl_entry objects Teresa Remmet
2016-05-23 8:26 ` [PATCH 23/62] UBI: Fastmap: Fix memory leaks while closing the WL sub-system Teresa Remmet
2016-05-23 8:26 ` [PATCH 24/62] UBI: Fastmap: Notify user in case of an ubi_update_fastmap() failure Teresa Remmet
2016-05-23 8:26 ` [PATCH 25/62] UBI: Fastmap: Wrap fastmap specific function in a ifdef Teresa Remmet
2016-05-23 8:26 ` [PATCH 26/62] UBI: Fastmap: Fix fastmap usage in ubi_volume_notify() Teresa Remmet
2016-05-23 8:26 ` [PATCH 27/62] UBI: Fastmap: Fix race in ubi_eba_atomic_leb_change() Teresa Remmet
2016-05-23 8:26 ` [PATCH 28/62] UBI: Fastmap: Remove bogus ubi_assert() Teresa Remmet
2016-05-23 8:26 ` [PATCH 29/62] UBI: Fastmap: Remove eba_orphans logic Teresa Remmet
2016-05-23 8:26 ` [PATCH 30/62] UBI: Fastmap: Switch to ro mode if invalidate_fastmap() fails Teresa Remmet
2016-05-23 8:26 ` [PATCH 31/62] UBI: Fastmap: Make WL pool size 50% of user pool size Teresa Remmet
2016-05-23 8:26 ` [PATCH 32/62] UBI: Fastmap: Fix leb_count unbalance Teresa Remmet
2016-05-23 8:26 ` [PATCH 33/62] UBI: Fastmap: Set used_ebs only for static volumes Teresa Remmet
2016-05-23 8:26 ` [PATCH 34/62] UBI: Fastmap: Prepare for variable sized fastmaps Teresa Remmet
2016-05-23 8:26 ` [PATCH 35/62] UBI: Fastmap: Rework fastmap error paths Teresa Remmet
2016-05-23 8:26 ` [PATCH 36/62] UBI: Fix stale pointers in ubi->lookuptbl Teresa Remmet
2016-05-23 8:26 ` [PATCH 37/62] UBI: Move fastmap specific functions out of wl.c Teresa Remmet
2016-05-23 8:26 ` [PATCH 38/62] UBI: Add accessor functions for WL data structures Teresa Remmet
2016-05-23 8:26 ` [PATCH 39/62] UBI: Fastmap: Wire up WL accessor functions Teresa Remmet
2016-05-23 8:26 ` [PATCH 40/62] UBI: Fastmap: Introduce ubi_fastmap_init() Teresa Remmet
2016-05-23 8:26 ` [PATCH 41/62] UBI: Fastmap: Introduce may_reserve_for_fm() Teresa Remmet
2016-05-23 8:26 ` [PATCH 42/62] UBI: Fastmap: Remove is_fm_block() Teresa Remmet
2016-05-23 8:26 ` [PATCH 43/62] UBI: Fastmap: Fall back to scanning mode after ECC error Teresa Remmet
2016-05-23 8:26 ` [PATCH 44/62] UBI: Fastmap: Use max() to get the larger value Teresa Remmet
2016-05-23 8:26 ` [PATCH 45/62] UBI: Fastmap: Remove unnecessary `\' Teresa Remmet
2016-05-23 8:26 ` [PATCH 46/62] UBI: Fastmap: Rename variables to make them meaningful Teresa Remmet
2016-05-23 8:26 ` [PATCH 47/62] UBI: Init vol->reserved_pebs by assignment Teresa Remmet
2016-05-23 8:26 ` [PATCH 48/62] UBI: Fastmap: Do not add vol if it already exists Teresa Remmet
2016-05-23 8:26 ` [PATCH 49/62] UBI: add a helper function for updatting on-flash layout volumes Teresa Remmet
2016-05-23 8:26 ` [PATCH 50/62] UBI: Remove unnecessary `\' Teresa Remmet
2016-05-23 8:26 ` [PATCH 51/62] UBI: Validate data_size Teresa Remmet
2016-05-23 8:26 ` [PATCH 52/62] UBI: return ENOSPC if no enough space available Teresa Remmet
2016-05-23 8:26 ` [PATCH 53/62] UBI: Fastmap: Simplify expression Teresa Remmet
2016-05-23 8:26 ` [PATCH 54/62] UBI: Fix typo in comment Teresa Remmet
2016-05-23 8:26 ` [PATCH 55/62] UBI: Fix debug message Teresa Remmet
2016-05-23 8:26 ` [PATCH 56/62] UBI: Fastmap: Fix PEB array type Teresa Remmet
2016-05-23 8:26 ` [PATCH 57/62] UBI: fix use of "VID" vs. "EC" in header self-check Teresa Remmet
2016-05-23 8:26 ` [PATCH 58/62] mtd: ubi: fixup error correction in do_sync_erase() Teresa Remmet
2016-05-23 8:26 ` [PATCH 59/62] mtd: ubi: don't leak e if schedule_erase() fails Teresa Remmet
2016-05-23 8:26 ` [PATCH 60/62] mtd: ubi: wl: avoid erasing a PEB which is empty Teresa Remmet
2016-05-23 8:26 ` [PATCH 61/62] ubi: Fix out of bounds write in volume update code Teresa Remmet
2016-05-23 8:26 ` [PATCH 62/62] mtd: UBI: Remove ubi_free_fastmap Teresa Remmet
2016-05-25 7:29 ` [PATCH 00/62] Update UBI Sascha Hauer
2016-05-25 11:38 ` Teresa Remmet
2016-05-25 13:33 ` Robert Schwebel
2016-05-25 14:42 ` Teresa Remmet
2016-05-25 14:54 ` Robert Schwebel
2016-05-25 20:22 ` Sam Ravnborg
2016-05-27 7:26 ` Teresa Remmet
2016-05-26 17:23 ` Sascha Hauer
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=1463992010-31537-5-git-send-email-t.remmet@phytec.de \
--to=t.remmet@phytec.de \
--cc=barebox@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