Skip to content

Commit 76eafe4

Browse files
bssinghArtem Bityutskiy
authored andcommitted
UBI: bugfix in sqnum calculation
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. Signed-off-by: Brijesh Singh <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
1 parent 2f176f7 commit 76eafe4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/mtd/ubi/scan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
437437
if (IS_ERR(sv) < 0)
438438
return PTR_ERR(sv);
439439

440+
if (si->max_sqnum < sqnum)
441+
si->max_sqnum = sqnum;
442+
440443
/*
441444
* Walk the RB-tree of logical eraseblocks of volume @vol_id to look
442445
* 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,
563566
sv->last_data_size = be32_to_cpu(vid_hdr->data_size);
564567
}
565568

566-
if (si->max_sqnum < sqnum)
567-
si->max_sqnum = sqnum;
568-
569569
sv->leb_count += 1;
570570
rb_link_node(&seb->u.rb, parent, p);
571571
rb_insert_color(&seb->u.rb, &sv->root);

0 commit comments

Comments
 (0)