aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2014-09-22 04:45:35 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-09-26 06:43:32 -0400
commit849271a4e4b723c521df0f55d67614d8ffd5e125 (patch)
treef79e33b8a7b2ad7bad60a065df92915450cc6036
parent170505f58f01d89dea2667d484cb5da18fb9ffd9 (diff)
UBI: wl: Rename cancel flag to shutdown
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>
-rw-r--r--drivers/mtd/ubi/ubi.h9
-rw-r--r--drivers/mtd/ubi/wl.c24
2 files changed, 18 insertions, 15 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index f2933df15f9c..320fc38fa2a1 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -714,14 +714,15 @@ struct ubi_attach_info {
714 * @torture: if the physical eraseblock has to be tortured 714 * @torture: if the physical eraseblock has to be tortured
715 * @anchor: produce a anchor PEB to by used by fastmap 715 * @anchor: produce a anchor PEB to by used by fastmap
716 * 716 *
717 * The @func pointer points to the worker function. If the @cancel argument is 717 * The @func pointer points to the worker function. If the @shutdown argument is
718 * not zero, the worker has to free the resources and exit immediately. The 718 * not zero, the worker has to free the resources and exit immediately as the
719 * worker has to return zero in case of success and a negative error code in 719 * WL sub-system is shutting down.
720 * The worker has to return zero in case of success and a negative error code in
720 * case of failure. 721 * case of failure.
721 */ 722 */
722struct ubi_work { 723struct ubi_work {
723 struct list_head list; 724 struct list_head list;
724 int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int cancel); 725 int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int shutdown);
725 /* The below fields are only relevant to erasure works */ 726 /* The below fields are only relevant to erasure works */
726 struct ubi_wl_entry *e; 727 struct ubi_wl_entry *e;
727 int vol_id; 728 int vol_id;
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 32b3c1486a05..c04b7f62fae5 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -864,7 +864,7 @@ static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
864} 864}
865 865
866static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, 866static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
867 int cancel); 867 int shutdown);
868 868
869#ifdef CONFIG_MTD_UBI_FASTMAP 869#ifdef CONFIG_MTD_UBI_FASTMAP
870/** 870/**
@@ -990,14 +990,15 @@ int ubi_wl_put_fm_peb(struct ubi_device *ubi, struct ubi_wl_entry *fm_e,
990 * wear_leveling_worker - wear-leveling worker function. 990 * wear_leveling_worker - wear-leveling worker function.
991 * @ubi: UBI device description object 991 * @ubi: UBI device description object
992 * @wrk: the work object 992 * @wrk: the work object
993 * @cancel: non-zero if the worker has to free memory and exit 993 * @shutdown: non-zero if the worker has to free memory and exit
994 * because the WL-subsystem is shutting down
994 * 995 *
995 * This function copies a more worn out physical eraseblock to a less worn out 996 * This function copies a more worn out physical eraseblock to a less worn out
996 * one. Returns zero in case of success and a negative error code in case of 997 * one. Returns zero in case of success and a negative error code in case of
997 * failure. 998 * failure.
998 */ 999 */
999static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, 1000static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
1000 int cancel) 1001 int shutdown)
1001{ 1002{
1002 int err, scrubbing = 0, torture = 0, protect = 0, erroneous = 0; 1003 int err, scrubbing = 0, torture = 0, protect = 0, erroneous = 0;
1003 int vol_id = -1, uninitialized_var(lnum); 1004 int vol_id = -1, uninitialized_var(lnum);
@@ -1008,7 +1009,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
1008 struct ubi_vid_hdr *vid_hdr; 1009 struct ubi_vid_hdr *vid_hdr;
1009 1010
1010 kfree(wrk); 1011 kfree(wrk);
1011 if (cancel) 1012 if (shutdown)
1012 return 0; 1013 return 0;
1013 1014
1014 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); 1015 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
@@ -1407,7 +1408,8 @@ int ubi_ensure_anchor_pebs(struct ubi_device *ubi)
1407 * erase_worker - physical eraseblock erase worker function. 1408 * erase_worker - physical eraseblock erase worker function.
1408 * @ubi: UBI device description object 1409 * @ubi: UBI device description object
1409 * @wl_wrk: the work object 1410 * @wl_wrk: the work object
1410 * @cancel: non-zero if the worker has to free memory and exit 1411 * @shutdown: non-zero if the worker has to free memory and exit
1412 * because the WL sub-system is shutting down
1411 * 1413 *
1412 * This function erases a physical eraseblock and perform torture testing if 1414 * This function erases a physical eraseblock and perform torture testing if
1413 * needed. It also takes care about marking the physical eraseblock bad if 1415 * needed. It also takes care about marking the physical eraseblock bad if
@@ -1415,7 +1417,7 @@ int ubi_ensure_anchor_pebs(struct ubi_device *ubi)
1415 * failure. 1417 * failure.
1416 */ 1418 */
1417static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, 1419static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1418 int cancel) 1420 int shutdown)
1419{ 1421{
1420 struct ubi_wl_entry *e = wl_wrk->e; 1422 struct ubi_wl_entry *e = wl_wrk->e;
1421 int pnum = e->pnum; 1423 int pnum = e->pnum;
@@ -1423,7 +1425,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1423 int lnum = wl_wrk->lnum; 1425 int lnum = wl_wrk->lnum;
1424 int err, available_consumed = 0; 1426 int err, available_consumed = 0;
1425 1427
1426 if (cancel) { 1428 if (shutdown) {
1427 dbg_wl("cancel erasure of PEB %d EC %d", pnum, e->ec); 1429 dbg_wl("cancel erasure of PEB %d EC %d", pnum, e->ec);
1428 kfree(wl_wrk); 1430 kfree(wl_wrk);
1429 kmem_cache_free(ubi_wl_entry_slab, e); 1431 kmem_cache_free(ubi_wl_entry_slab, e);
@@ -1845,10 +1847,10 @@ int ubi_thread(void *u)
1845} 1847}
1846 1848
1847/** 1849/**
1848 * cancel_pending - cancel all pending works. 1850 * shutdown_work - shutdown all pending works.
1849 * @ubi: UBI device description object 1851 * @ubi: UBI device description object
1850 */ 1852 */
1851static void cancel_pending(struct ubi_device *ubi) 1853static void shutdown_work(struct ubi_device *ubi)
1852{ 1854{
1853 while (!list_empty(&ubi->works)) { 1855 while (!list_empty(&ubi->works)) {
1854 struct ubi_work *wrk; 1856 struct ubi_work *wrk;
@@ -1997,7 +1999,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
1997 return 0; 1999 return 0;
1998 2000
1999out_free: 2001out_free:
2000 cancel_pending(ubi); 2002 shutdown_work(ubi);
2001 tree_destroy(&ubi->used); 2003 tree_destroy(&ubi->used);
2002 tree_destroy(&ubi->free); 2004 tree_destroy(&ubi->free);
2003 tree_destroy(&ubi->scrub); 2005 tree_destroy(&ubi->scrub);
@@ -2029,7 +2031,7 @@ static void protection_queue_destroy(struct ubi_device *ubi)
2029void ubi_wl_close(struct ubi_device *ubi) 2031void ubi_wl_close(struct ubi_device *ubi)
2030{ 2032{
2031 dbg_wl("close the WL sub-system"); 2033 dbg_wl("close the WL sub-system");
2032 cancel_pending(ubi); 2034 shutdown_work(ubi);
2033 protection_queue_destroy(ubi); 2035 protection_queue_destroy(ubi);
2034 tree_destroy(&ubi->used); 2036 tree_destroy(&ubi->used);
2035 tree_destroy(&ubi->erroneous); 2037 tree_destroy(&ubi->erroneous);