Skip to contentSkip to conversation

mtd: ubi: Free peb's synchronously for fastmap

RFC/PATCH Applied Tanya Brokhman 6 participants 8 messages Apr 1, 2014 – Apr 8, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

drivers/mtd/ubi/wl.c +19 -0
index 457ead3..9a36f78 100644
@@ -595,10 +595,29 @@ static void refill_wl_pool(struct ubi_device *ubi)
 static void refill_wl_user_pool(struct ubi_device *ubi)
 {
 	struct ubi_fm_pool *pool = &ubi->fm_pool;
+	int err;
 
 	return_unused_pool_pebs(ubi, pool);
 
 	for (pool->size = 0; pool->size < pool->max_size; pool->size++) {
+retry:
+		if (!ubi->free.rb_node ||
+		   (ubi->free_count - ubi->beb_rsvd_pebs < 1)) {
+			/*
+			 * There are no available PEBs. Try to free
+			 * PEB by means of synchronous execution of
+			 * pending works.
+			 */
+			if (ubi->works_count == 0)
+				break;
+			spin_unlock(&ubi->wl_lock);
+			err = do_work(ubi);
+			spin_lock(&ubi->wl_lock);
+			if (err < 0)
+				break;
+			goto retry;
+		}
+
 		pool->pebs[pool->size] = __wl_get_peb(ubi);
 		if (pool->pebs[pool->size] < 0)
 			break;
Signature · 4 lines
1.7.6
-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Reviewed-by
#1 lore raw

Thanks,
Dolev

Signature · 2 lines
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

-----Original Message-----
From: linux-mtd [mailto:[email protected]] On Behalf Of Tanya Brokhman
Sent: Tuesday, April 01, 2014 11:02 AM
To: [email protected]
Cc: [email protected]; open list; Tanya Brokhman
Subject: [RFC/PATCH] mtd: ubi: Free peb's synchronously for fastmap

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty.
Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

drivers/mtd/ubi/wl.c index renamed from drivers/mtd/ubi/wl.c +0 -0

457ead3..9a36f78 100644

drivers/mtd/ubi/wl.c +0 -0
@@ -595,10 +595,29 @@ static void refill_wl_pool(struct ubi_device *ubi)

static void refill_wl_user_pool(struct ubi_device *ubi) {
struct ubi_fm_pool *pool = &ubi->fm_pool;
+ int err;

return_unused_pool_pebs(ubi, pool);

for (pool->size = 0; pool->size < pool->max_size; pool->size++) {
+retry:
+ if (!ubi->free.rb_node ||
+ (ubi->free_count - ubi->beb_rsvd_pebs < 1)) {
+ /*
+ * There are no available PEBs. Try to free
+ * PEB by means of synchronous execution of
+ * pending works.
+ */
+ if (ubi->works_count == 0)
+ break;
+ spin_unlock(&ubi->wl_lock);
+ err = do_work(ubi);
+ spin_lock(&ubi->wl_lock);
+ if (err < 0)
+ break;
+ goto retry;
+ }
+
pool->pebs[pool->size] = __wl_get_peb(ubi);
if (pool->pebs[pool->size] < 0)
break;
--
1.7.6
--
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw
In reply to Tanya Brokhman
Quoted 24 lines · Tanya Brokhman

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

drivers/mtd/ubi/wl.c +4 -0
index 457ead3..9a36f78 100644
@@ -595,10 +595,29 @@ static void refill_wl_pool(struct ubi_device *ubi)
 static void refill_wl_user_pool(struct ubi_device *ubi)
 {
        struct ubi_fm_pool *pool = &ubi->fm_pool;
+       int err;
 
        return_unused_pool_pebs(ubi, pool);
 
        for (pool->size = 0; pool->size < pool->max_size; pool->size++) {
+retry:
+               if (!ubi->free.rb_node ||
+                  (ubi->free_count - ubi->beb_rsvd_pebs < 1)) {

drivers/mtd/ubi/wl.c static void refill_wl_pool(struct ubi_device *ubi) · line 615

Quoted 10 lines
drivers/mtd/ubi/wl.c +10 -0
+                       /*
+                        * There are no available PEBs. Try to free
+                        * PEB by means of synchronous execution of
+                        * pending works.
+                        */
+                       if (ubi->works_count == 0)
+                               break;
+                       spin_unlock(&ubi->wl_lock);
+                       err = do_work(ubi);
+                       spin_lock(&ubi->wl_lock);

This is basically what produce_free_peb() does.

drivers/mtd/ubi/wl.c static void refill_wl_pool(struct ubi_device *ubi) · line 621

Quoted 6 lines
drivers/mtd/ubi/wl.c +5 -0
+                       if (err < 0)
+                               break;
+                       goto retry;
+               }
+
                pool->pebs[pool->size] = __wl_get_peb(ubi);

__wl_get_peb() already calls produce_free_peb() when we run out of free PEBs.

Does your patch really fix a problem you encounter or did you find the issue by reviewing
the code?

Signature · 2 lines
Thanks,
//richard
#3 lore raw
Quoted 21 lines · Richard Weinberger
Quoted 20 lines · Tanya Brokhman

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

drivers/mtd/ubi/wl.c +1 -0
index 457ead3..9a36f78 100644
@@ -595,10 +595,29 @@ static void refill_wl_pool(struct ubi_device *ubi)
  static void refill_wl_user_pool(struct ubi_device *ubi)
  {
         struct ubi_fm_pool *pool = &ubi->fm_pool;
+       int err;
 
         return_unused_pool_pebs(ubi, pool);
 
Quoted 16 lines
Quoted 4 lines
drivers/mtd/ubi/wl.c +3 -0
         for (pool->size = 0; pool->size < pool->max_size; pool->size++) {
+retry:
+               if (!ubi->free.rb_node ||
+                  (ubi->free_count - ubi->beb_rsvd_pebs < 1)) {

drivers/mtd/ubi/wl.c static void refill_wl_pool(struct ubi_device *ubi) · line 615

Quoted 10 lines
drivers/mtd/ubi/wl.c +10 -0
+                       /*
+                        * There are no available PEBs. Try to free
+                        * PEB by means of synchronous execution of
+                        * pending works.
+                        */
+                       if (ubi->works_count == 0)
+                               break;
+                       spin_unlock(&ubi->wl_lock);
+                       err = do_work(ubi);
+                       spin_lock(&ubi->wl_lock);

This is basically what produce_free_peb() does.

Right. I didn't use t just because of the termination condition. produce_free_peb stops if there is 1 free peb. I need more then 1

Quoted 8 lines

drivers/mtd/ubi/wl.c static void refill_wl_pool(struct ubi_device *ubi) · line 621

Quoted 7 lines
drivers/mtd/ubi/wl.c +5 -0
+                       if (err < 0)
+                               break;
+                       goto retry;
+               }
+
                 pool->pebs[pool->size] = __wl_get_peb(ubi);
Quoted 6 lines

__wl_get_peb() already calls produce_free_peb() when we run out of free PEBs.

Does your patch really fix a problem you encounter or did you find the issue by reviewing
the code?

Yes. We encountered this issue, as described in the commit message. This is the fix. Verified and working for us.

Signature · 2 lines
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

Am 07.04.2014 18:05, schrieb Tanya Brokhman:

Quoted 49 lines · Richard Weinberger
Quoted 21 lines · Tanya Brokhman
Quoted 20 lines

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

drivers/mtd/ubi/wl.c +1 -0
index 457ead3..9a36f78 100644
@@ -595,10 +595,29 @@ static void refill_wl_pool(struct ubi_device *ubi)
  static void refill_wl_user_pool(struct ubi_device *ubi)
  {
         struct ubi_fm_pool *pool = &ubi->fm_pool;
+       int err;
 
         return_unused_pool_pebs(ubi, pool);
 
Quoted 16 lines
Quoted 4 lines
drivers/mtd/ubi/wl.c +3 -0
         for (pool->size = 0; pool->size < pool->max_size; pool->size++) {
+retry:
+               if (!ubi->free.rb_node ||
+                  (ubi->free_count - ubi->beb_rsvd_pebs < 1)) {

drivers/mtd/ubi/wl.c static void refill_wl_pool(struct ubi_device *ubi) · line 615

Quoted 10 lines
drivers/mtd/ubi/wl.c +10 -0
+                       /*
+                        * There are no available PEBs. Try to free
+                        * PEB by means of synchronous execution of
+                        * pending works.
+                        */
+                       if (ubi->works_count == 0)
+                               break;
+                       spin_unlock(&ubi->wl_lock);
+                       err = do_work(ubi);
+                       spin_lock(&ubi->wl_lock);

This is basically what produce_free_peb() does.

Right. I didn't use t just because of the termination condition. produce_free_peb stops if there is 1 free peb. I need more then 1

Quoted 8 lines
Quoted 7 lines
drivers/mtd/ubi/wl.c +5 -0
+                       if (err < 0)
+                               break;
+                       goto retry;
+               }
+
                 pool->pebs[pool->size] = __wl_get_peb(ubi);
Quoted 8 lines
Quoted 6 lines

__wl_get_peb() already calls produce_free_peb() when we run out of free PEBs.

Does your patch really fix a problem you encounter or did you find the issue by reviewing
the code?

Yes. We encountered this issue, as described in the commit message. This is the fix. Verified and working for us.

Wouldn't it be better to fix produce_free_pep() instead of duplicating it? I.e. Such that you can tell it how many PEBs you need.

Thanks,
//richard

#5 lore raw
In reply to Tanya Brokhman
Quoted 7 lines · Tanya Brokhman

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

Pushed to linux-ubifs.git / master, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#6 lore raw
Quoted 10 lines · Artem Bityutskiy
Quoted 7 lines · Tanya Brokhman

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

Pushed to linux-ubifs.git / master, thanks!

Oh, sorry, this one I actually _dropped_. Would you please rather re-structure the code to avoid duplication. E.g., do what Richard suggested.

Signature · 12 lines
Best Regards,
Artem Bityutskiy
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#7 lore raw
Quoted 8 lines · Artem
Quoted 7 lines · Artem Bityutskiy
Quoted 6 lines · Tanya Brokhman

At first mount it's possible that there are not enough free PEBs since there are PEB's pending to be erased. In such scenario, fm_pool (which is the pool from which user required PEBs are allocated) will be empty. Try fixing the above described situation by synchronously performing pending erase work, thus produce another free PEB.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Pushed to linux-ubifs.git / master, thanks!

Oh, sorry, this one I actually _dropped_. Would you please rather re-structure the code to avoid duplication. E.g., do what Richard suggested.

Tatyana, can you also please find out how many PEBs you need? Strictly speaking we need only one (which should be produced by __wl_get_peb(). I want to make sure that we're not just papering over an issue. :-)

Signature · 2 lines
Thanks,
//richard