Skip to contentSkip to conversation

ubiattach reserves too many BEBs for each volume attached

PATCH [email protected] 2 participants 2 messages Feb 11, 2022

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

If there is more than one volume on the device, ubiattach reserves amount of BEBs as for the whole device, each time. Small volumes can be covered mainly by reserved blocks on big devices. With this the amount of BEBs is proportional to the volume size.

---
 drivers/mtd/ubi/build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/build.c +1 -1
index 94b4231..54e16f1 100644
@@ -237,7 +237,7 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
 	else
 		device_size = ubi->mtd->size;
 
-	device_pebs = mtd_div_by_eb(device_size, ubi->mtd);
+	device_pebs = mtd_div_by_eb(ubi->mtd->size, ubi->mtd);
 	limit = mult_frac(device_pebs, max_beb_per1024, 1024);
 
 	/* Round it up */
Signature · 9 lines
2.35.1

Regards,
Michał

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 4 lines · On Fri, Feb 11, 2022 at 04:23:46PM +0100, [email protected] wrote:

If there is more than one volume on the device, ubiattach reserves amount of BEBs as for the whole device, each time. Small volumes can be covered mainly by reserved blocks on big devices.
With this the amount of BEBs is proportional to the volume size.

This is done on purpose, see the comment above the place you changed:

/*
* Here we are using size of the entire flash chip and
* not just the MTD partition size because the maximum
* number of bad eraseblocks is a percentage of the
* whole device and bad eraseblocks are not fairly
* distributed over the flash chip. So the worst case
* is that all the bad eraseblocks of the chip are in
* the MTD partition we are attaching (ubi->mtd). */

Sascha

Quoted 29 lines
---
 drivers/mtd/ubi/build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/build.c +1 -1
index 94b4231..54e16f1 100644
@@ -237,7 +237,7 @@ static int get_bad_peb_limit(const struct ubi_device
 *ubi, int max_beb_per1024)
 	else
 		device_size = ubi->mtd->size;
 
-	device_pebs = mtd_div_by_eb(device_size, ubi->mtd);
+	device_pebs = mtd_div_by_eb(ubi->mtd->size, ubi->mtd);
 	limit = mult_frac(device_pebs, max_beb_per1024, 1024);
 

/* Round it up */

Signature · 9 lines
2.35.1

Regards,
Michał

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox