mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] UBI: Fix livelock in produce_free_peb()
@ 2014-09-19 15:37 Richard Weinberger
  2014-09-24 12:36 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2014-09-19 15:37 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd, linux-kernel, Richard Weinberger

The while loop in produce_free_peb() assumes that each work will produce a
free PEB. This is not true.
If ubi->works_count is 1 and the only scheduled work is the
wear_leveling_worker() produce_free_peb() can loop forever in case
nobody schedules an erase work.
Fix this issue by checking in the while loop whether work is scheduled.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/ubi/wl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 0509c8a..6add739 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -272,7 +272,7 @@ static int produce_free_peb(struct ubi_device *ubi)
 {
 	int err;
 
-	while (!ubi->free.rb_node) {
+	while (!ubi->free.rb_node && ubi->works_count) {
 		spin_unlock(&ubi->wl_lock);
 
 		dbg_wl("do one work synchronously");
-- 
1.8.4.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] UBI: Fix livelock in produce_free_peb()
  2014-09-19 15:37 [PATCH] UBI: Fix livelock in produce_free_peb() Richard Weinberger
@ 2014-09-24 12:36 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2014-09-24 12:36 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd, linux-kernel

On Fri, 2014-09-19 at 17:37 +0200, Richard Weinberger wrote:
> The while loop in produce_free_peb() assumes that each work will produce a
> free PEB. This is not true.
> If ubi->works_count is 1 and the only scheduled work is the
> wear_leveling_worker() produce_free_peb() can loop forever in case
> nobody schedules an erase work.
> Fix this issue by checking in the while loop whether work is scheduled.
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>

Pushed, thanks!

-- 
Best Regards,
Artem Bityutskiy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-24 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-19 15:37 [PATCH] UBI: Fix livelock in produce_free_peb() Richard Weinberger
2014-09-24 12:36 ` Artem Bityutskiy

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®