Opened on 08/03/17 at 04:22:04
Closed on 04/11/18 at 01:57:45
#3089 closed defect (fixed)
Inconsistent blocking addressing in RFS
Reported by: | Fan Deng | Owned by: | Fan Deng |
---|---|---|---|
Priority: | normal | Milestone: | 5.1 |
Component: | fs | Version: | 4.11 |
Severity: | normal | Keywords: | |
Cc: | Chris Johns | Blocked By: | |
Blocking: |
Description
Background
There are two ways to address a block in RFS:
- Via a single 32bit block number (bno)
- Via a group number(gno) and a bit offset (bit)
They should be fully convertible (1-1 mapping). In other words, the equation to convert 1 to 2 should be unique within the RFS implementation.
The bug
The RFS implementation contains two different conversions between 1 and 2.
Details
- In rtems_rfs_group_bitmap_alloc (rtems-rfs-group.c, line 172)
bno = gno * group_blocks + bit
- In rtems_rfs_group_bitmap_alloc (rtems-rfs-group.c, line 228)
bno = gno * group_blocks + bit + 1 (via rtems_rfs_group_block() function)
- In rtems_rfs_group_bitmap_free (rtems-rfs-group.c, line 283)
bno = gno * group_blocks + bit + 1 (RTEMS_RFS_SUPERBLOCK_SIZE)
- In rtems_rfs_group_bitmap_test (rtems-rfs-group.c, line 332)
bno = gno * group_blocks + bit
To summarize, the implementation contains two ways of converting a bno to a (gno, bit) pair:
Either:
bno = gno * group_blocks + bit
Or:
bno = gno * group_blocks + bit + 1
The Fix
The RFS implementation should consistently convert a bno to a (gno, bit) pair with:
bno = gno * group_blocks + bit + RTEMS_RFS_SUPERBLOCK_SIZE
This is because the superblock is not accounted for in the block bitmaps. So places to change:
- rtems-rfs-group.c: all references to the conversion must be updated to use RTEMS_RFS_SUPERBLOCK_SIZE explicitly.
- rtems_rfs_group_block converts the pair to bno via:
#define rtems_rfs_group_block(_g, _b) (((_g)->base) + (_b))
(_g)->base is calculated via rtems-rfs-format.c from:
#define rtems_rfs_fs_block(_fs, _grp, _blk) \ ((((_fs)->group_blocks) * (_grp)) + (_blk) + 1)
The "+ 1" part should really be "+ RTEMS_RFS_SUPERBLOCK_SIZE" to be logically correct. As RTEMS_RFS_SUPERBLOCK_SIZE itself has a comment saying:
/** * Number of blocks in the superblock. Yes I know it is a superblock and not * superblocks but if for any reason this needs to change it is handled. */ #define RTEMS_RFS_SUPERBLOCK_SIZE (1)
Change History (2)
comment:1 Changed on 11/09/17 at 06:27:14 by Sebastian Huber
Milestone: | 4.12.0 → 5.1 |
---|
comment:2 Changed on 04/11/18 at 01:57:45 by Chris Johns <chrisj@…>
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
In 9e8df1fe/rtems:
Milestone renamed