autoresize causes insufficient reservation of PEBs for bad PEB handling

Egli, Samuel samuel.egli at siemens.com
Tue Jul 7 03:59:25 PDT 2015


Hello Richard,

>-----Original Message-----
>From: Richard Weinberger [mailto:richard.weinberger at gmail.com]
>Sent: Dienstag, 7. Juli 2015 12:50
>To: Egli, Samuel
>Cc: linux-mtd at lists.infradead.org
>Subject: Re: autoresize causes insufficient reservation of PEBs for bad
>PEB handling
>
>Samuel,
>
>On Mon, Jul 6, 2015 at 1:04 PM, Egli, Samuel <samuel.egli at siemens.com>
>wrote:
>> Hi all,
>>
>> I have difficulties to understand why I get the following warning
>> message at linux start up:
>>
>> ...
>> [    4.777488] UBI warning: print_rsvd_warning: cannot reserve enough
>PEBs \
>> for bad PEB handling, reserved 40, need 80 ...
>>
>> My assumption is that if I don't specify the size of one volume UBI
>> will choose the right size for the volume and reserve the right amount
>> of PEBs for bad block handling. With 20/1024 set,vi I expect indeed to
>> have 80 blocks reserved. But somehow this does not work. I observed
>> that I get this warning when vol_flags is set to autoresize. In this
>> case only 40 blocks get reserved.
>> Using for all volumes the vol_size parameter and omitting autoresize,
>> I can avoid this situation and I get my 80 blocks reserved.
>>
>> However, I don't understand why and it seems odd to me that autoresize
>> would work this way.
>>
>> Can somebody confirm this observations or explain why this works like
>> this. Maybe I'm also doing something wrong.
>>
>> See below how I generate the ubi image.
>>
>> General setup
>> =============
>> flash size: 4096 PEBs
>> mtd partition size: 4065 PEBs
>> number of volumes: 3
>>
>> Linux version:
>> Linux dxr2 3.14.36-r2 #1 PREEMPT Tue Jun 30 10:26:05 CEST 2015 armv7l
>> GNU/Linux
>>
>>
>> Config 1
>> ========
>> 2 volumes with fixed size
>> 1 volume has vol_flags=autoresize and vol_size not defined
>>
>> mkfs.ubifs -r ../rootfs/path -o rootfs.ubifs -F -m 2048 -e 126976 -c
>> 4065 mkfs.ubifs -r ../conf/path -o conf.ubifs -F -m 2048 -e 126976 -c
>> 4065 ubinize -o rootfs.ubi -m 2048 -p 131072 -O 2048 ubinize.cfg
>>
>> ubinize.cfg:
>>  [rootfs_a]
>>  mode=ubi
>>  image=rootfs.ubifs
>>  vol_id=0
>>  vol_type=dynamic
>>  vol_name=rootfs_a
>>  vol_size=140MiB
>>  [rootfs_b]
>>  mode=ubi
>>  vol_id=1
>>  vol_type=dynamic
>>  vol_name=rootfs_b
>>  vol_size=140MiB
>>  [configuration]
>>  mode=ubi
>>  image=configuration.ubifs
>>  vol_id=2
>>  vol_type=dynamic
>>  vol_name=configuration
>>  vol_flags=autoresize
>>
>> --> only 40 blocks get reserved vor bad PEB handling
>>
>> Config 2
>> ========
>> All 3 volumes with fixed size
>>
>> mkfs.ubifs -r ../rootfs/path -o rootfs.ubifs -F -m 2048 -e 126976 -c
>> 4065 mkfs.ubifs -r ../conf/path -o conf.ubifs -F -m 2048 -e 126976 -c
>> 4065
>>
>> ubinize.cfg:
>>  [rootfs_a]
>>  mode=ubi
>>  image=rootfs.ubifs
>>  vol_id=0
>>  vol_type=dynamic
>>  vol_name=rootfs_a
>>  vol_size=140MiB
>>  [rootfs_b]
>>  mode=ubi
>>  vol_id=1
>>  vol_type=dynamic
>>  vol_name=rootfs_b
>>  vol_size=140MiB
>>  [configuration]
>>  mode=ubi
>>  image=configuration.ubifs
>>  vol_id=2
>>  vol_type=dynamic
>>  vol_name=configuration
>>  vol_size=341MiB
>
>Something I did not notice yesternight, 140+140+341 is 621.
>According to your logs the MTD partition is only 508MiB large.

oops. Sorry, this is my mistake. We have to products with same 
number of volumes and names but with different volume sizes.

The samples I linked on gist have vol_size for rootfs_a and 
rootfs_b set to 70MiB. So when setting the 3rd vol_size to
341MiB I get like linked before from "ubinfo -a" the following:

ubi0
Volumes count:                           3
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     4065 (516157440 bytes, 492.2 MiB)
Amount of available logical eraseblocks: 7 (888832 bytes, 868.0 KiB)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  80
Current maximum erase counter value:     2
Minimum input/output unit size:          2048 bytes
Character device major/minor:            251:0
Present volumes:                         0, 1, 2
 
Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        579 LEBs (73519104 bytes, 70.1 MiB)
State:       OK
Name:        rootfs_a
Character device major/minor: 251:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        579 LEBs (73519104 bytes, 70.1 MiB)
State:       OK
Name:        rootfs_b
Character device major/minor: 251:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        2816 LEBs (357564416 bytes, 341.0 MiB)
State:       OK
Name:        configuration
Character device major/minor: 251:3

So this is actually ok. I get my 80 blocks reserved.

Sorry for the confusion.

Sam



More information about the linux-mtd mailing list