Changeset 1196df6 in mainline


Ignore:
Timestamp:
2012-04-08T09:02:16Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6f41312
Parents:
3b5c119
Message:

extents: hotfix with writing to an existing empty file

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_extent.c

    r3b5c119 r1196df6  
    249249        ext4_extent_binsearch(header, &extent, iblock);
    250250
    251         assert(extent != NULL);
    252 
    253         uint32_t phys_block;
    254         phys_block = ext4_extent_get_start(extent) + iblock;
    255         phys_block -= ext4_extent_get_first_block(extent);
    256 
    257         *fblock = phys_block;
     251        if (extent == NULL) {
     252                *fblock = 0;
     253        } else {
     254                uint32_t phys_block;
     255                phys_block = ext4_extent_get_start(extent) + iblock;
     256                phys_block -= ext4_extent_get_first_block(extent);
     257
     258                *fblock = phys_block;
     259        }
    258260
    259261        if (block != NULL) {
    260262                block_put(block);
    261263        }
    262 
    263264
    264265        return EOK;
     
    396397}
    397398
    398 int ext4_extent_release_blocks_from(ext4_inode_ref_t *inode_ref, uint32_t iblock_from)
     399int ext4_extent_release_blocks_from(ext4_inode_ref_t *inode_ref,
     400                uint32_t iblock_from)
    399401{
    400402        int rc;
     
    600602
    601603        } else {
    602                 // try allocate succeeding extent block
     604                // try allocate scceeding extent block
    603605
    604606                // TODO
     
    609611
    610612finish:
     613
     614        *iblock = new_block_idx;
     615        *fblock = phys_block;
     616
    611617        // Put loaded blocks
    612618        // From 1 -> 0 is a block with inode data
  • uspace/lib/ext4/libext4_filesystem.c

    r3b5c119 r1196df6  
    541541                                ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS)) {
    542542
    543                 rc = ext4_extent_release_blocks_from(inode_ref, old_blocks_count - diff_blocks_count);
     543                rc = ext4_extent_release_blocks_from(inode_ref,
     544                                old_blocks_count - diff_blocks_count);
    544545                if (rc != EOK) {
    545546                        return rc;
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r3b5c119 r1196df6  
    10971097
    10981098        if (fblock == 0) {
    1099                 rc =  ext4_balloc_alloc_block(inode_ref, &fblock);
    1100                 if (rc != EOK) {
    1101                         ext4fs_node_put(fn);
    1102                         async_answer_0(callid, rc);
    1103                         return rc;
    1104                 }
    1105 
    1106                 rc = ext4_filesystem_set_inode_data_block_index(inode_ref, iblock, fblock);
    1107                 if (rc != EOK) {
    1108                         ext4_balloc_free_block(inode_ref, fblock);
    1109                         ext4fs_node_put(fn);
    1110                         async_answer_0(callid, rc);
    1111                         return rc;
    1112                 }
     1099
     1100                if (ext4_superblock_has_feature_incompatible(
     1101                                fs->superblock, EXT4_FEATURE_INCOMPAT_EXTENTS) &&
     1102                                (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
     1103
     1104                        uint32_t tmp_iblock = 0;
     1105                        do {
     1106                                rc = ext4_filesystem_append_inode_block(inode_ref, &fblock, &tmp_iblock);
     1107                                if (rc != EOK) {
     1108                                        ext4fs_node_put(fn);
     1109                                        async_answer_0(callid, rc);
     1110                                        return rc;
     1111                                }
     1112                        } while (tmp_iblock < iblock);
     1113
     1114                } else {
     1115                        rc =  ext4_balloc_alloc_block(inode_ref, &fblock);
     1116                        if (rc != EOK) {
     1117                                ext4fs_node_put(fn);
     1118                                async_answer_0(callid, rc);
     1119                                return rc;
     1120                        }
     1121
     1122                        rc = ext4_filesystem_set_inode_data_block_index(inode_ref, iblock, fblock);
     1123                        if (rc != EOK) {
     1124                                ext4_balloc_free_block(inode_ref, fblock);
     1125                                ext4fs_node_put(fn);
     1126                                async_answer_0(callid, rc);
     1127                                return rc;
     1128                        }
     1129                }
     1130
     1131                flags = BLOCK_FLAGS_NOREAD;
    11131132                inode_ref->dirty = true;
    1114 
    1115                 flags = BLOCK_FLAGS_NOREAD;
    11161133        }
    11171134
Note: See TracChangeset for help on using the changeset viewer.