UBI Patch: Max Sequence no not updated in scan.c
Artem Bityutskiy
dedekind at infradead.org
Fri Jul 6 05:22:18 EDT 2007
Hi Brijesh,
thanks for the catch.
On Fri, 2007-07-06 at 14:30 +0530, brijesh.singh at calsoftinc.com wrote:
> Hi,I came across problem of having two leb with same sequence no.This
> happens when we continuously write one block again and again and reboot
> machine before background thread erases those blocks.
> The problem here was,when we find two blocks with same sequence no,we take
> the higher one,but we were not updating max seq no,so next block may have
> the same seqnum.
> This patch solves this problem.
Yeah, bu you probably wanted to say "when we find two blocks with same
volume ID and LEB number".
I would rather do the fix it other way - are you OK with that?
Also, it seems I have found one more problem:
What the haeck si->max_sqnum = 0; is doing in add_volume()?
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 23e30ac..ce26b1b 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -437,6 +437,9 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
if (IS_ERR(sv) < 0)
return PTR_ERR(sv);
+ if (si->max_sqnum < sqnum)
+ si->max_sqnum = sqnum;
+
/*
* Walk the RB-tree of logical eraseblocks of volume @vol_id to look
* if this is the first instance of this logical eraseblock or not.
@@ -563,9 +566,6 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
sv->last_data_size = be32_to_cpu(vid_hdr->data_size);
}
- if (si->max_sqnum < sqnum)
- si->max_sqnum = sqnum;
-
sv->leb_count += 1;
rb_link_node(&seb->u.rb, parent, p);
rb_insert_color(&seb->u.rb, &sv->root);
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
More information about the linux-mtd
mailing list