Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e2f20b9e in mainline


Ignore:
Timestamp:
2018-12-13T13:29:38Z (3 years ago)
Author:
Maurizio Lombardi <mlombard@…>
Branches:
lfn, master
Children:
6ea5e7a
Parents:
91fcbabc
Message:

libext4: fixes to flex support in ext4_balloc_get_first_data_block_in_group()

The "first data block in group" was not calculated correctly.
As a consequence, the ext4 filesystem was not able to fully utilize
the available disk space

Location:
uspace/lib/ext4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/include/ext4/superblock.h

    r91fcbabc re2f20b9e  
    147147extern void ext4_superblock_set_reserved_gdt_blocks(ext4_superblock_t *sb,
    148148    uint32_t n);
     149extern uint32_t ext4_superblock_get_flex_group_size(ext4_superblock_t *sb);
    149150
    150151/* More complex superblock functions */
  • uspace/lib/ext4/src/balloc.c

    r91fcbabc re2f20b9e  
    261261                 * is always after the inode table.
    262262                 */
     263                return itable + itable_sz;
     264        }
     265
     266        uint32_t flex_group_size = ext4_superblock_get_flex_group_size(sb);
     267        if ((bg_ref->index % flex_group_size) == 0) {
     268                /* This is the base group */
     269                uint32_t i;
     270
    263271                r = itable + itable_sz;
    264                 return ext4_filesystem_blockaddr2_index_in_group(sb, r);
    265         }
    266 
    267         uint64_t bbmap = ext4_block_group_get_block_bitmap(bg_ref->block_group,
    268             sb);
    269         uint64_t ibmap = ext4_block_group_get_inode_bitmap(bg_ref->block_group,
    270             sb);
    271 
    272         r = ext4_filesystem_index_in_group2blockaddr(sb, 0, bg_ref->index);
    273         r += ext4_filesystem_bg_get_backup_blocks(bg_ref);
    274 
    275         if (ext4_filesystem_blockaddr2group(sb, bbmap) != bg_ref->index)
    276                 bbmap = -1; /* Invalid */
    277 
    278         if (ext4_filesystem_blockaddr2group(sb, ibmap) != bg_ref->index)
    279                 ibmap = -1;
    280 
    281         while (true) {
    282                 if (r == bbmap || r == ibmap)
    283                         r++;
    284                 else if (r >= itable && r < (itable + itable_sz))
    285                         r = itable + itable_sz;
    286                 else
    287                         break;
    288         }
    289 
    290         return r;
     272
     273                uint32_t total_groups = ext4_superblock_get_block_group_count(sb);
     274                for (i = bg_ref->index + 1;
     275                    i < min(total_groups, bg_ref->index + flex_group_size); ++i) {
     276                        r += ext4_filesystem_bg_get_itable_size(sb, i);
     277                }
     278
     279                return r;
     280        }
     281
     282        uint64_t base_addr = ext4_filesystem_index_in_group2blockaddr(sb, 0,
     283            bg_ref->index);
     284        uint32_t reserved = ext4_filesystem_bg_get_backup_blocks(bg_ref);
     285
     286        return base_addr + reserved;
    291287}
    292288
  • uspace/lib/ext4/src/superblock.c

    r91fcbabc re2f20b9e  
    13941394{
    13951395        sb->reserved_gdt_blocks = host2uint32_t_le(n);
     1396}
     1397
     1398/** Get the size of the flex groups
     1399 *
     1400 * @param sb    Pointer to the superblock
     1401 *
     1402 * @return      Size of the flex groups
     1403 */
     1404uint32_t ext4_superblock_get_flex_group_size(ext4_superblock_t *sb)
     1405{
     1406        return 2 << sb->log_groups_per_flex;
    13961407}
    13971408
Note: See TracChangeset for help on using the changeset viewer.