2014-10-02 13:29:00

by Tanya Brokhman

[permalink] [raw]
Subject: Re: [PATCH 3/4] UBI: Fastmap: Care about the protection queue

Hi Richard

On 9/30/2014 1:20 AM, Richard Weinberger wrote:
> Fastmap can miss a PEB if it is in the protection queue
> and not jet in the used tree.
> Treat every protected PEB as used.
>
> Signed-off-by: Richard Weinberger <[email protected]>
> ---
> drivers/mtd/ubi/fastmap.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
> index 2b0d8d6..2853a69 100644
> --- a/drivers/mtd/ubi/fastmap.c
> +++ b/drivers/mtd/ubi/fastmap.c
> @@ -1195,6 +1195,19 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
> fm_pos += sizeof(*fec);
> ubi_assert(fm_pos <= ubi->fm_size);
> }
> +
> + for (i = 0; i < UBI_PROT_QUEUE_LEN; i++) {
> + list_for_each_entry(wl_e, &ubi->pq[i], u.list) {

why not list_for_each_entry_safe?

> + fec = (struct ubi_fm_ec *)(fm_raw + fm_pos);
> +
> + fec->pnum = cpu_to_be32(wl_e->pnum);
> + fec->ec = cpu_to_be32(wl_e->ec);
> +
> + used_peb_count++;
> + fm_pos += sizeof(*fec);
> + ubi_assert(fm_pos <= ubi->fm_size);

Is fm_size ok with this addition or does it needs updating as well?

> + }
> + }
> fmh->used_peb_count = cpu_to_be32(used_peb_count);
>
> for (node = rb_first(&ubi->scrub); node; node = rb_next(node)) {
>

Thanks
Tanya Brokhman
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation


2014-10-02 13:33:04

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH 3/4] UBI: Fastmap: Care about the protection queue

Am 02.10.2014 15:28, schrieb Tanya Brokhman:
> Hi Richard
>
> On 9/30/2014 1:20 AM, Richard Weinberger wrote:
>> Fastmap can miss a PEB if it is in the protection queue
>> and not jet in the used tree.
>> Treat every protected PEB as used.
>>
>> Signed-off-by: Richard Weinberger <[email protected]>
>> ---
>> drivers/mtd/ubi/fastmap.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
>> index 2b0d8d6..2853a69 100644
>> --- a/drivers/mtd/ubi/fastmap.c
>> +++ b/drivers/mtd/ubi/fastmap.c
>> @@ -1195,6 +1195,19 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
>> fm_pos += sizeof(*fec);
>> ubi_assert(fm_pos <= ubi->fm_size);
>> }
>> +
>> + for (i = 0; i < UBI_PROT_QUEUE_LEN; i++) {
>> + list_for_each_entry(wl_e, &ubi->pq[i], u.list) {
>
> why not list_for_each_entry_safe?

Because we don't delete elements from this list while iterating over it.

>> + fec = (struct ubi_fm_ec *)(fm_raw + fm_pos);
>> +
>> + fec->pnum = cpu_to_be32(wl_e->pnum);
>> + fec->ec = cpu_to_be32(wl_e->ec);
>> +
>> + used_peb_count++;
>> + fm_pos += sizeof(*fec);
>> + ubi_assert(fm_pos <= ubi->fm_size);
>
> Is fm_size ok with this addition or does it needs updating as well?

It is okay. The fastmap size calculation reserves enough space for all possible
PEBs.

Thanks,
//richard

2014-10-02 14:14:38

by Tanya Brokhman

[permalink] [raw]
Subject: Re: [PATCH 3/4] UBI: Fastmap: Care about the protection queue

On 10/2/2014 4:32 PM, Richard Weinberger wrote:
> Am 02.10.2014 15:28, schrieb Tanya Brokhman:
>> Hi Richard
>>
>> On 9/30/2014 1:20 AM, Richard Weinberger wrote:
>>> Fastmap can miss a PEB if it is in the protection queue
>>> and not jet in the used tree.
>>> Treat every protected PEB as used.
>>>
>>> Signed-off-by: Richard Weinberger <[email protected]>
>>> ---
>>> drivers/mtd/ubi/fastmap.c | 13 +++++++++++++
>>> 1 file changed, 13 insertions(+)
>>>
>>> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
>>> index 2b0d8d6..2853a69 100644
>>> --- a/drivers/mtd/ubi/fastmap.c
>>> +++ b/drivers/mtd/ubi/fastmap.c
>>> @@ -1195,6 +1195,19 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
>>> fm_pos += sizeof(*fec);
>>> ubi_assert(fm_pos <= ubi->fm_size);
>>> }
>>> +
>>> + for (i = 0; i < UBI_PROT_QUEUE_LEN; i++) {
>>> + list_for_each_entry(wl_e, &ubi->pq[i], u.list) {
>>
>> why not list_for_each_entry_safe?
>
> Because we don't delete elements from this list while iterating over it.
>
>>> + fec = (struct ubi_fm_ec *)(fm_raw + fm_pos);
>>> +
>>> + fec->pnum = cpu_to_be32(wl_e->pnum);
>>> + fec->ec = cpu_to_be32(wl_e->ec);
>>> +
>>> + used_peb_count++;
>>> + fm_pos += sizeof(*fec);
>>> + ubi_assert(fm_pos <= ubi->fm_size);
>>
>> Is fm_size ok with this addition or does it needs updating as well?
>
> It is okay. The fastmap size calculation reserves enough space for all possible
> PEBs.
>
> Thanks,
> //richard
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>

Reviewed-by: Tanya Brokhman <[email protected]>

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation