Skip to content

ODS2: Does not calculate interleave correctly #24

@al20878

Description

@al20878

The formula in phyvirt.c for the maplbn() function is wrong:

    if( s >= dp->sectors / dp->interleave )
        s = (s * dp->interleave) - (dp->sectors -1);  /* <<< BUG HERE! */
    else
        s = s * dp->interleave;

    s = (s + (dp->skew * c)) % dp->sectors;

First, since the last line shown in the snippet above operates with the reminders modulo dp->sectors, then subtracting dp->sectors -1 on the line marked "BUG HERE" is the same as just adding 1. Thus, the formula on that line can be simplified as:

s = (s * dp->interleave) +1;

That, however, is a problem for dp->sectors not being a multiple of dp->interleave (given, DEC did not use those values in practice, so it may not "trigger" the bug, but still). An example: if sectors:=10 and interleave:=3, the mapping sequence of sectors, which the code calculates, yields:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -> 0, 3, 6, 0, 3, 6, 9, 2, 5, 8

The problem is quite obvious -- there cannot be any repeated sectors! Instead, the correct output sector sequence in these conditions would be:

0, 3, 6, 9, 2, 5, 8, 1, 4, 7

The correct interleave formula can be found in the lbn2pbn tool, which was added recently to the simtools/converters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions