aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/kapi.c
diff options
context:
space:
mode:
authorJoel Reardon <joel@clambassador.com>2012-05-20 15:27:11 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-21 04:34:41 -0400
commit62f384552b6756cf1ea71f8762d1e97dc77dbd90 (patch)
tree6ebd89f4f18eca1724e8a50b8fc6cdefc29de18a /drivers/mtd/ubi/kapi.c
parent05a3cb7dcec5a15ed9b18a5317ba2075355c7547 (diff)
UBI: modify ubi_wl_flush function to clear work queue for a lnum
This patch modifies ubi_wl_flush to force the erasure of particular volume id / logical eraseblock number pairs. Previous functionality is preserved when passing UBI_ALL for both values. The locations where ubi_wl_flush were called are appropriately changed: ubi_leb_erase only flushes for the erased LEB, and ubi_create_volume forces only flushing for its volume id. External code can call this new feature via the new function ubi_flush() added to kapi.c, which simply passes through to ubi_wl_flush(). This was tested by disabling the call to do_work in ubi thread, which results in the work queue remaining unless explicitly called to remove. UBIFS was changed to call ubifs_leb_change 50 times for four different LEBs. Then the new function was called to clear the queue: passing wrong volume ids / lnum, correct ones, and finally UBI_ALL for both to ensure it was finally all cleard. The work queue was dumped each time and the selective removal of the particular LEB numbers was observed. Extra checks were enabled and ubifs's integck was also run. Finally, the drive was repeatedly filled and emptied to ensure that the queue was cleared normally. Artem: amended the patch. Signed-off-by: Joel Reardon <reardonj@inf.ethz.ch> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r--drivers/mtd/ubi/kapi.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index d76fe47477e5..3aac1acceeb4 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -551,7 +551,7 @@ int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum)
551 if (err) 551 if (err)
552 return err; 552 return err;
553 553
554 return ubi_wl_flush(ubi); 554 return ubi_wl_flush(ubi, vol->vol_id, lnum);
555} 555}
556EXPORT_SYMBOL_GPL(ubi_leb_erase); 556EXPORT_SYMBOL_GPL(ubi_leb_erase);
557 557
@@ -704,6 +704,33 @@ int ubi_sync(int ubi_num)
704} 704}
705EXPORT_SYMBOL_GPL(ubi_sync); 705EXPORT_SYMBOL_GPL(ubi_sync);
706 706
707/**
708 * ubi_flush - flush UBI work queue.
709 * @ubi_num: UBI device to flush work queue
710 * @vol_id: volume id to flush for
711 * @lnum: logical eraseblock number to flush for
712 *
713 * This function executes all pending works for a particular volume id / logical
714 * eraseblock number pair. If either value is set to %UBI_ALL, then it acts as
715 * a wildcard for all of the corresponding volume numbers or logical
716 * eraseblock numbers. It returns zero in case of success and a negative error
717 * code in case of failure.
718 */
719int ubi_flush(int ubi_num, int vol_id, int lnum)
720{
721 struct ubi_device *ubi;
722 int err = 0;
723
724 ubi = ubi_get_device(ubi_num);
725 if (!ubi)
726 return -ENODEV;
727
728 err = ubi_wl_flush(ubi, vol_id, lnum);
729 ubi_put_device(ubi);
730 return err;
731}
732EXPORT_SYMBOL_GPL(ubi_flush);
733
707BLOCKING_NOTIFIER_HEAD(ubi_notifiers); 734BLOCKING_NOTIFIER_HEAD(ubi_notifiers);
708 735
709/** 736/**