Changeset 3c8b0a8 in mainline for uspace/lib/ext4/src/superblock.c


Ignore:
Timestamp:
2018-12-15T15:48:59Z (6 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4bb4cf88
Parents:
b6d5e31 (diff), 6ea5e7a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Maurizio Lombardi <m.lombardi85@…> (2018-12-15 15:48:59)
git-committer:
GitHub <noreply@…> (2018-12-15 15:48:59)
Message:

Merge pull request #143 from maurizio-lombardi/ext4_fixes_v2

Ext4 fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/superblock.c

    rb6d5e31 r3c8b0a8  
    13151315            ext4_superblock_get_blocks_per_group(sb);
    13161316        uint64_t total_blocks =
    1317             ext4_superblock_get_blocks_count(sb) - 1;
     1317            ext4_superblock_get_blocks_count(sb);
     1318        uint32_t first_block =
     1319            ext4_superblock_get_first_data_block(sb);
    13181320
    13191321        if (bgid < block_group_count - 1)
    13201322                return blocks_per_group;
    13211323        else
    1322                 return (total_blocks - ((block_group_count - 1) * blocks_per_group));
     1324                return (total_blocks - ((block_group_count - 1) * blocks_per_group)) - first_block;
    13231325}
    13241326
     
    13921394{
    13931395        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;
    13941407}
    13951408
     
    14651478                 */
    14661479
    1467                 if (idx == 0 && block_size == 1024) {
    1468                         /*
    1469                          * Special case for first group were the boot block
    1470                          * resides
    1471                          */
    1472                         r++;
    1473                 }
    1474 
    14751480                /* This accounts for the superblock */
    14761481                r++;
     
    15051510        uuid_t uuid;
    15061511        uint32_t cur_ts;
    1507         uint64_t first_block;
     1512        uint64_t first_block = 0;
    15081513        uint64_t fs_blocks;
    15091514        uint32_t blocks_count;
     
    15181523        uint32_t idx;
    15191524        size_t fs_bsize;
     1525        size_t fs_bsize_log;
    15201526        errno_t rc;
    15211527        struct timespec ts;
     
    15331539        cur_ts = ts.tv_sec;
    15341540
    1535         fs_bsize = 1024;
    1536         first_block = 1; /* 1 for 1k block size, 0 otherwise */
     1541        fs_bsize = cfg->bsize;
     1542        switch (fs_bsize) {
     1543        case 1024:
     1544                first_block = 1;
     1545                fs_bsize_log = 0;
     1546                blocks_group = 8192;
     1547                break;
     1548        case 2048:
     1549                fs_bsize_log = 1;
     1550                blocks_group = 8192 * 2;
     1551                break;
     1552        case 4096:
     1553                fs_bsize_log = 2;
     1554                blocks_group = 8192 * 4;
     1555                break;
     1556        default:
     1557                return ENOTSUP;
     1558        }
    15371559
    15381560        if (fs_bsize % dev_bsize == 0) {
     
    15431565                fs_blocks = dev_bcnt * (dev_bsize / fs_bsize);
    15441566        }
    1545 
    1546         /* FS blocks per group */
    1547         blocks_group = 8 * fs_bsize;
    15481567
    15491568        /* Inodes per group */
     
    15811600        ext4_superblock_set_free_inodes_count(sb, inodes_count);
    15821601        ext4_superblock_set_first_data_block(sb, first_block);
    1583         /* Block size will be 1024 bytes */
    1584         ext4_superblock_set_log_block_size(sb, 0);
     1602        ext4_superblock_set_log_block_size(sb, fs_bsize_log);
    15851603        /* Fragment size should be equal to block size */
    1586         ext4_superblock_set_log_frag_size(sb, 0);
     1604        ext4_superblock_set_log_frag_size(sb, fs_bsize_log);
    15871605        ext4_superblock_set_blocks_per_group(sb, blocks_group);
    15881606        /* Should be the same as blocks per group. */
     
    16341652        /* Compute free blocks */
    16351653        free_blocks = blocks_count;
    1636         ++free_blocks; // XXX Why?
    16371654        for (idx = 0; idx < ngroups; idx++) {
    16381655                free_blocks -= ext4_superblock_get_group_backup_blocks(sb, idx);
Note: See TracChangeset for help on using the changeset viewer.