Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (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:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

File:
1 edited

Legend:

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

    r3061bc1 r8565a42  
    244244        if (rc != EOK)
    245245                return rc;
    246        
     246
    247247        block_t *block;
    248248        rc = block_get(&block, dir->fs->device, fblock, BLOCK_FLAGS_NONE);
    249249        if (rc != EOK)
    250250                return rc;
    251        
     251
    252252        /* Initialize pointers to data structures */
    253253        ext4_directory_dx_root_t *root = block->data;
    254254        ext4_directory_dx_root_info_t *info = &(root->info);
    255        
     255
    256256        /* Initialize root info structure */
    257257        uint8_t hash_version =
    258258            ext4_superblock_get_default_hash_version(dir->fs->superblock);
    259        
     259
    260260        ext4_directory_dx_root_info_set_hash_version(info, hash_version);
    261261        ext4_directory_dx_root_info_set_indirect_levels(info, 0);
    262262        ext4_directory_dx_root_info_set_info_length(info, 8);
    263        
     263
    264264        /* Set limit and current number of entries */
    265265        ext4_directory_dx_countlimit_t *countlimit =
    266266            (ext4_directory_dx_countlimit_t *) &root->entries;
    267267        ext4_directory_dx_countlimit_set_count(countlimit, 1);
    268        
     268
    269269        uint32_t block_size =
    270270            ext4_superblock_get_block_size(dir->fs->superblock);
     
    274274        uint16_t root_limit = entry_space / sizeof(ext4_directory_dx_entry_t);
    275275        ext4_directory_dx_countlimit_set_limit(countlimit, root_limit);
    276        
     276
    277277        /* Append new block, where will be new entries inserted in the future */
    278278        uint32_t iblock;
     
    282282                return rc;
    283283        }
    284        
     284
    285285        block_t *new_block;
    286286        rc = block_get(&new_block, dir->fs->device, fblock, BLOCK_FLAGS_NOREAD);
     
    289289                return rc;
    290290        }
    291        
     291
    292292        /* Fill the whole block with empty entry */
    293293        ext4_directory_entry_ll_t *block_entry = new_block->data;
    294294        ext4_directory_entry_ll_set_entry_length(block_entry, block_size);
    295295        ext4_directory_entry_ll_set_inode(block_entry, 0);
    296        
     296
    297297        new_block->dirty = true;
    298298        rc = block_put(new_block);
     
    301301                return rc;
    302302        }
    303        
     303
    304304        /* Connect new block to the only entry in index */
    305305        ext4_directory_dx_entry_t *entry = root->entries;
    306306        ext4_directory_dx_entry_set_block(entry, iblock);
    307        
     307
    308308        block->dirty = true;
    309        
     309
    310310        return block_put(block);
    311311}
     
    328328        ext4_directory_dx_root_t *root =
    329329            (ext4_directory_dx_root_t *) root_block->data;
    330        
     330
    331331        if ((root->info.hash_version != EXT4_HASH_VERSION_TEA) &&
    332332            (root->info.hash_version != EXT4_HASH_VERSION_HALF_MD4) &&
    333333            (root->info.hash_version != EXT4_HASH_VERSION_LEGACY))
    334334                return EXT4_ERR_BAD_DX_DIR;
    335        
     335
    336336        /* Check unused flags */
    337337        if (root->info.unused_flags != 0)
    338338                return EXT4_ERR_BAD_DX_DIR;
    339        
     339
    340340        /* Check indirect levels */
    341341        if (root->info.indirect_levels > 1)
    342342                return EXT4_ERR_BAD_DX_DIR;
    343        
     343
    344344        /* Check if node limit is correct */
    345345        uint32_t block_size = ext4_superblock_get_block_size(sb);
     
    348348        entry_space -= sizeof(ext4_directory_dx_root_info_t);
    349349        entry_space = entry_space / sizeof(ext4_directory_dx_entry_t);
    350        
     350
    351351        uint16_t limit = ext4_directory_dx_countlimit_get_limit(
    352352            (ext4_directory_dx_countlimit_t *) &root->entries);
    353353        if (limit != entry_space)
    354354                return EXT4_ERR_BAD_DX_DIR;
    355        
     355
    356356        /* Check hash version and modify if necessary */
    357357        hinfo->hash_version =
     
    362362                hinfo->hash_version += 3;
    363363        }
    364        
     364
    365365        /* Load hash seed from superblock */
    366366        hinfo->seed = ext4_superblock_get_hash_seed(sb);
    367        
     367
    368368        /* Compute hash value of name */
    369369        if (name)
    370370                ext4_hash_string(hinfo, name_len, name);
    371        
     371
    372372        return EOK;
    373373}
     
    393393        ext4_directory_dx_entry_t *entries =
    394394            (ext4_directory_dx_entry_t *) &root->entries;
    395        
     395
    396396        uint16_t limit = ext4_directory_dx_countlimit_get_limit(
    397397            (ext4_directory_dx_countlimit_t *) entries);
    398398        uint8_t indirect_level =
    399399            ext4_directory_dx_root_info_get_indirect_levels(&root->info);
    400        
     400
    401401        block_t *tmp_block = root_block;
    402402        ext4_directory_dx_entry_t *p;
     
    404404        ext4_directory_dx_entry_t *m;
    405405        ext4_directory_dx_entry_t *at;
    406        
     406
    407407        /* Walk through the index tree */
    408408        while (true) {
     
    411411                if ((count == 0) || (count > limit))
    412412                        return EXT4_ERR_BAD_DX_DIR;
    413                
     413
    414414                /* Do binary search in every node */
    415415                p = entries + 1;
    416416                q = entries + count - 1;
    417                
     417
    418418                while (p <= q) {
    419419                        m = p + (q - p) / 2;
     
    423423                                p = m + 1;
    424424                }
    425                
     425
    426426                at = p - 1;
    427                
     427
    428428                /* Write results */
    429429                tmp_dx_block->block = tmp_block;
    430430                tmp_dx_block->entries = entries;
    431431                tmp_dx_block->position = at;
    432                
     432
    433433                /* Is algorithm in the leaf? */
    434434                if (indirect_level == 0) {
     
    436436                        return EOK;
    437437                }
    438                
     438
    439439                /* Goto child node */
    440440                uint32_t next_block = ext4_directory_dx_entry_get_block(at);
    441                
     441
    442442                indirect_level--;
    443                
     443
    444444                uint32_t fblock;
    445445                errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref,
     
    447447                if (rc != EOK)
    448448                        return rc;
    449                
     449
    450450                rc = block_get(&tmp_block, inode_ref->fs->device, fblock,
    451451                    BLOCK_FLAGS_NONE);
    452452                if (rc != EOK)
    453453                        return rc;
    454                
     454
    455455                entries = ((ext4_directory_dx_node_t *) tmp_block->data)->entries;
    456456                limit = ext4_directory_dx_countlimit_get_limit(
    457457                    (ext4_directory_dx_countlimit_t *) entries);
    458                
     458
    459459                uint16_t entry_space =
    460460                    ext4_superblock_get_block_size(inode_ref->fs->superblock) -
    461461                    sizeof(ext4_directory_dx_dot_entry_t);
    462462                entry_space = entry_space / sizeof(ext4_directory_dx_entry_t);
    463                
     463
    464464                if (limit != entry_space) {
    465465                        block_put(tmp_block);
    466466                        return EXT4_ERR_BAD_DX_DIR;
    467467                }
    468                
     468
    469469                ++tmp_dx_block;
    470470        }
    471        
     471
    472472        /* Unreachable */
    473473        return EOK;
     
    490490        uint32_t num_handles = 0;
    491491        ext4_directory_dx_block_t *p = dx_block;
    492        
     492
    493493        /* Try to find data block with next bunch of entries */
    494494        while (true) {
     
    496496                uint16_t count = ext4_directory_dx_countlimit_get_count(
    497497                    (ext4_directory_dx_countlimit_t *) p->entries);
    498                
     498
    499499                if (p->position < p->entries + count)
    500500                        break;
    501                
     501
    502502                if (p == dx_blocks)
    503503                        return EOK;
    504                
     504
    505505                num_handles++;
    506506                p--;
    507507        }
    508        
     508
    509509        /* Check hash collision (if not occured - no next block cannot be used) */
    510510        uint32_t current_hash = ext4_directory_dx_entry_get_hash(p->position);
     
    513513                        return 0;
    514514        }
    515        
     515
    516516        /* Fill new path */
    517517        while (num_handles--) {
     
    519519                    ext4_directory_dx_entry_get_block(p->position);
    520520                uint32_t block_addr;
    521                
     521
    522522                errno_t rc = ext4_filesystem_get_inode_data_block_index(inode_ref,
    523523                    block_idx, &block_addr);
    524524                if (rc != EOK)
    525525                        return rc;
    526                
     526
    527527                block_t *block;
    528528                rc = block_get(&block, inode_ref->fs->device, block_addr, BLOCK_FLAGS_NONE);
    529529                if (rc != EOK)
    530530                        return rc;
    531                
     531
    532532                p++;
    533                
     533
    534534                /* Don't forget to put old block (prevent memory leak) */
    535535                rc = block_put(p->block);
    536536                if (rc != EOK)
    537537                        return rc;
    538                
     538
    539539                p->block = block;
    540540                p->entries = ((ext4_directory_dx_node_t *) block->data)->entries;
    541541                p->position = p->entries;
    542542        }
    543        
     543
    544544        return ENOENT;
    545545}
     
    566566        if (rc != EOK)
    567567                return rc;
    568        
     568
    569569        ext4_filesystem_t *fs = inode_ref->fs;
    570        
     570
    571571        block_t *root_block;
    572572        rc = block_get(&root_block, fs->device, root_block_addr,
     
    574574        if (rc != EOK)
    575575                return rc;
    576        
     576
    577577        /* Initialize hash info (compute hash value) */
    578578        ext4_hash_info_t hinfo;
     
    583583                return EXT4_ERR_BAD_DX_DIR;
    584584        }
    585        
     585
    586586        /*
    587587         * Hardcoded number 2 means maximum height of index tree,
     
    591591        ext4_directory_dx_block_t *dx_block;
    592592        ext4_directory_dx_block_t *tmp;
    593        
     593
    594594        rc = ext4_directory_dx_get_leaf(&hinfo, inode_ref, root_block,
    595595            &dx_block, dx_blocks);
     
    598598                return EXT4_ERR_BAD_DX_DIR;
    599599        }
    600        
     600
    601601        do {
    602602                /* Load leaf block */
     
    604604                    ext4_directory_dx_entry_get_block(dx_block->position);
    605605                uint32_t leaf_block_addr;
    606                
     606
    607607                rc = ext4_filesystem_get_inode_data_block_index(inode_ref,
    608608                    leaf_block_idx, &leaf_block_addr);
    609609                if (rc != EOK)
    610610                        goto cleanup;
    611                
     611
    612612                block_t *leaf_block;
    613613                rc = block_get(&leaf_block, fs->device, leaf_block_addr,
     
    615615                if (rc != EOK)
    616616                        goto cleanup;
    617                
     617
    618618                /* Linear search inside block */
    619619                ext4_directory_entry_ll_t *res_dentry;
    620620                rc = ext4_directory_find_in_block(leaf_block, fs->superblock,
    621621                    name_len, name, &res_dentry);
    622                
     622
    623623                /* Found => return it */
    624624                if (rc == EOK) {
     
    627627                        goto cleanup;
    628628                }
    629                
     629
    630630                /* Not found, leave untouched */
    631631                rc2 = block_put(leaf_block);
    632632                if (rc2 != EOK)
    633633                        goto cleanup;
    634                
     634
    635635                if (rc != ENOENT)
    636636                        goto cleanup;
    637                
     637
    638638                /* check if the next block could be checked */
    639639                rc = ext4_directory_dx_next_block(inode_ref, hinfo.hash,
     
    643643
    644644        } while (rc == ENOENT);
    645        
     645
    646646        /* Entry not found */
    647647        rc = ENOENT;
    648        
     648
    649649cleanup:
    650650        /* The whole path must be released (preventing memory leak) */
    651651        tmp = dx_blocks;
    652        
     652
    653653        while (tmp <= dx_block) {
    654654                rc2 = block_put(tmp->block);
     
    657657                ++tmp;
    658658        }
    659        
     659
    660660        return rc;
    661661}
     
    677677        ext4_dx_sort_entry_t const *entry1 = arg1;
    678678        ext4_dx_sort_entry_t const *entry2 = arg2;
    679        
     679
    680680        if (entry1->hash == entry2->hash)
    681681                return 0;
    682        
     682
    683683        if (entry1->hash < entry2->hash)
    684684                return -1;
     
    701701        ext4_directory_dx_entry_t *old_index_entry = index_block->position;
    702702        ext4_directory_dx_entry_t *new_index_entry = old_index_entry + 1;
    703        
     703
    704704        ext4_directory_dx_countlimit_t *countlimit =
    705705            (ext4_directory_dx_countlimit_t *) index_block->entries;
    706706        uint32_t count = ext4_directory_dx_countlimit_get_count(countlimit);
    707        
     707
    708708        ext4_directory_dx_entry_t *start_index = index_block->entries;
    709709        size_t bytes = (void *) (start_index + count) - (void *) (new_index_entry);
    710        
     710
    711711        memmove(new_index_entry + 1, new_index_entry, bytes);
    712        
     712
    713713        ext4_directory_dx_entry_set_block(new_index_entry, iblock);
    714714        ext4_directory_dx_entry_set_hash(new_index_entry, hash);
    715        
     715
    716716        ext4_directory_dx_countlimit_set_count(countlimit, count + 1);
    717        
     717
    718718        index_block->block->dirty = true;
    719719}
     
    733733{
    734734        errno_t rc = EOK;
    735        
     735
    736736        /* Allocate buffer for directory entries */
    737737        uint32_t block_size =
     
    740740        if (entry_buffer == NULL)
    741741                return ENOMEM;
    742        
     742
    743743        /* dot entry has the smallest size available */
    744744        uint32_t max_entry_count =
    745745            block_size / sizeof(ext4_directory_dx_dot_entry_t);
    746        
     746
    747747        /* Allocate sort entry */
    748748        ext4_dx_sort_entry_t *sort_array =
     
    752752                return ENOMEM;
    753753        }
    754        
     754
    755755        uint32_t idx = 0;
    756756        uint32_t real_size = 0;
    757        
     757
    758758        /* Initialize hinfo */
    759759        ext4_hash_info_t tmp_hinfo;
    760760        memcpy(&tmp_hinfo, hinfo, sizeof(ext4_hash_info_t));
    761        
     761
    762762        /* Load all valid entries to the buffer */
    763763        ext4_directory_entry_ll_t *dentry = old_data_block->data;
     
    769769                            inode_ref->fs->superblock, dentry);
    770770                        ext4_hash_string(&tmp_hinfo, len, (char *) dentry->name);
    771                        
     771
    772772                        uint32_t rec_len = 8 + len;
    773                        
     773
    774774                        if ((rec_len % 4) != 0)
    775775                                rec_len += 4 - (rec_len % 4);
    776                        
     776
    777777                        memcpy(entry_buffer_ptr, dentry, rec_len);
    778                        
     778
    779779                        sort_array[idx].dentry = entry_buffer_ptr;
    780780                        sort_array[idx].rec_len = rec_len;
    781781                        sort_array[idx].hash = tmp_hinfo.hash;
    782                        
     782
    783783                        entry_buffer_ptr += rec_len;
    784784                        real_size += rec_len;
    785785                        idx++;
    786786                }
    787                
     787
    788788                dentry = (void *) dentry +
    789789                    ext4_directory_entry_ll_get_entry_length(dentry);
    790790        }
    791        
     791
    792792        /* Sort all entries */
    793793        qsort(sort_array, idx, sizeof(ext4_dx_sort_entry_t),
    794794            ext4_directory_dx_entry_comparator);
    795        
     795
    796796        /* Allocate new block for store the second part of entries */
    797797        uint32_t new_fblock;
     
    804804                return rc;
    805805        }
    806        
     806
    807807        /* Load new block */
    808808        block_t *new_data_block_tmp;
     
    814814                return rc;
    815815        }
    816        
     816
    817817        /*
    818818         * Distribute entries to two blocks (by size)
     
    828828                        break;
    829829                }
    830                
     830
    831831                current_size += sort_array[i].rec_len;
    832832        }
    833        
     833
    834834        /* Check hash collision */
    835835        uint32_t continued = 0;
    836836        if (new_hash == sort_array[mid-1].hash)
    837837                continued = 1;
    838        
     838
    839839        uint32_t offset = 0;
    840840        void *ptr;
    841        
     841
    842842        /* First part - to the old block */
    843843        for (uint32_t i = 0; i < mid; ++i) {
    844844                ptr = old_data_block->data + offset;
    845845                memcpy(ptr, sort_array[i].dentry, sort_array[i].rec_len);
    846                
     846
    847847                ext4_directory_entry_ll_t *tmp = ptr;
    848848                if (i < (mid - 1))
     
    852852                        ext4_directory_entry_ll_set_entry_length(tmp,
    853853                            block_size - offset);
    854                
     854
    855855                offset += sort_array[i].rec_len;
    856856        }
    857        
     857
    858858        /* Second part - to the new block */
    859859        offset = 0;
     
    861861                ptr = new_data_block_tmp->data + offset;
    862862                memcpy(ptr, sort_array[i].dentry, sort_array[i].rec_len);
    863                
     863
    864864                ext4_directory_entry_ll_t *tmp = ptr;
    865865                if (i < (idx - 1))
     
    869869                        ext4_directory_entry_ll_set_entry_length(tmp,
    870870                            block_size - offset);
    871                
     871
    872872                offset += sort_array[i].rec_len;
    873873        }
    874        
     874
    875875        /* Do some steps to finish operation */
    876876        old_data_block->dirty = true;
    877877        new_data_block_tmp->dirty = true;
    878        
     878
    879879        free(sort_array);
    880880        free(entry_buffer);
    881        
     881
    882882        ext4_directory_dx_insert_entry(index_block, new_hash + continued,
    883883            new_iblock);
    884        
     884
    885885        *new_data_block = new_data_block_tmp;
    886        
     886
    887887        return EOK;
    888888}
     
    907907                entries =
    908908                    ((ext4_directory_dx_node_t *) dx_block->block->data)->entries;
    909        
     909
    910910        ext4_directory_dx_countlimit_t *countlimit =
    911911            (ext4_directory_dx_countlimit_t *) entries;
    912        
     912
    913913        uint16_t leaf_limit =
    914914            ext4_directory_dx_countlimit_get_limit(countlimit);
    915915        uint16_t leaf_count =
    916916            ext4_directory_dx_countlimit_get_count(countlimit);
    917        
     917
    918918        /* Check if is necessary to split index block */
    919919        if (leaf_limit == leaf_count) {
    920920                size_t levels = dx_block - dx_blocks;
    921                
     921
    922922                ext4_directory_dx_entry_t *root_entries =
    923923                    ((ext4_directory_dx_root_t *) dx_blocks[0].block->data)->entries;
    924                
     924
    925925                ext4_directory_dx_countlimit_t *root_countlimit =
    926926                    (ext4_directory_dx_countlimit_t *) root_entries;
     
    929929                uint16_t root_count =
    930930                    ext4_directory_dx_countlimit_get_count(root_countlimit);
    931                
     931
    932932                /* Linux limitation */
    933933                if ((levels > 0) && (root_limit == root_count))
    934934                        return ENOSPC;
    935                
     935
    936936                /* Add new block to directory */
    937937                uint32_t new_fblock;
     
    941941                if (rc != EOK)
    942942                        return rc;
    943                
     943
    944944                /* load new block */
    945945                block_t *new_block;
     
    948948                if (rc != EOK)
    949949                        return rc;
    950                
     950
    951951                ext4_directory_dx_node_t *new_node = new_block->data;
    952952                ext4_directory_dx_entry_t *new_entries = new_node->entries;
    953                
     953
    954954                uint32_t block_size =
    955955                    ext4_superblock_get_block_size(inode_ref->fs->superblock);
    956                
     956
    957957                /* Split leaf node */
    958958                if (levels > 0) {
     
    961961                        uint32_t hash_right =
    962962                            ext4_directory_dx_entry_get_hash(entries + count_left);
    963                        
     963
    964964                        /* Copy data to new node */
    965965                        memcpy((void *) new_entries, (void *) (entries + count_left),
    966966                            count_right * sizeof(ext4_directory_dx_entry_t));
    967                        
     967
    968968                        /* Initialize new node */
    969969                        ext4_directory_dx_countlimit_t *left_countlimit =
     
    971971                        ext4_directory_dx_countlimit_t *right_countlimit =
    972972                            (ext4_directory_dx_countlimit_t *) new_entries;
    973                        
     973
    974974                        ext4_directory_dx_countlimit_set_count(left_countlimit, count_left);
    975975                        ext4_directory_dx_countlimit_set_count(right_countlimit, count_right);
    976                        
     976
    977977                        uint32_t entry_space =
    978978                            block_size - sizeof(ext4_fake_directory_entry_t);
     
    980980                            entry_space / sizeof(ext4_directory_dx_entry_t);
    981981                        ext4_directory_dx_countlimit_set_limit(right_countlimit, node_limit);
    982                        
     982
    983983                        /* Which index block is target for new entry */
    984984                        uint32_t position_index = (dx_block->position - dx_block->entries);
    985985                        if (position_index >= count_left) {
    986986                                dx_block->block->dirty = true;
    987                                
     987
    988988                                block_t *block_tmp = dx_block->block;
    989989                                dx_block->block = new_block;
     
    991991                                    new_entries + position_index - count_left;
    992992                                dx_block->entries = new_entries;
    993                                
     993
    994994                                new_block = block_tmp;
    995995                        }
    996                        
     996
    997997                        /* Finally insert new entry */
    998998                        ext4_directory_dx_insert_entry(dx_blocks, hash_right, new_iblock);
    999                        
     999
    10001000                        return block_put(new_block);
    10011001                } else {
    10021002                        /* Create second level index */
    1003                        
     1003
    10041004                        /* Copy data from root to child block */
    10051005                        memcpy((void *) new_entries, (void *) entries,
    10061006                            leaf_count * sizeof(ext4_directory_dx_entry_t));
    1007                        
     1007
    10081008                        ext4_directory_dx_countlimit_t *new_countlimit =
    10091009                            (ext4_directory_dx_countlimit_t *) new_entries;
    1010                        
     1010
    10111011                        uint32_t entry_space =
    10121012                            block_size - sizeof(ext4_fake_directory_entry_t);
     
    10141014                            entry_space / sizeof(ext4_directory_dx_entry_t);
    10151015                        ext4_directory_dx_countlimit_set_limit(new_countlimit, node_limit);
    1016                        
     1016
    10171017                        /* Set values in root node */
    10181018                        ext4_directory_dx_countlimit_t *new_root_countlimit =
    10191019                            (ext4_directory_dx_countlimit_t *) entries;
    1020                        
     1020
    10211021                        ext4_directory_dx_countlimit_set_count(new_root_countlimit, 1);
    10221022                        ext4_directory_dx_entry_set_block(entries, new_iblock);
    1023                        
     1023
    10241024                        ((ext4_directory_dx_root_t *)
    10251025                            dx_blocks[0].block->data)->info.indirect_levels = 1;
    1026                        
     1026
    10271027                        /* Add new entry to the path */
    10281028                        dx_block = dx_blocks + 1;
     
    10321032                }
    10331033        }
    1034        
     1034
    10351035        return EOK;
    10361036}
     
    10491049{
    10501050        errno_t rc2 = EOK;
    1051        
     1051
    10521052        /* Get direct block 0 (index root) */
    10531053        uint32_t root_block_addr;
     
    10561056        if (rc != EOK)
    10571057                return rc;
    1058        
     1058
    10591059        ext4_filesystem_t *fs = parent->fs;
    1060        
     1060
    10611061        block_t *root_block;
    10621062        rc = block_get(&root_block, fs->device, root_block_addr,
     
    10641064        if (rc != EOK)
    10651065                return rc;
    1066        
     1066
    10671067        /* Initialize hinfo structure (mainly compute hash) */
    10681068        uint32_t name_len = str_size(name);
     
    10741074                return EXT4_ERR_BAD_DX_DIR;
    10751075        }
    1076        
     1076
    10771077        /*
    10781078         * Hardcoded number 2 means maximum height of index
     
    10821082        ext4_directory_dx_block_t *dx_block;
    10831083        ext4_directory_dx_block_t *dx_it;
    1084        
     1084
    10851085        rc = ext4_directory_dx_get_leaf(&hinfo, parent, root_block,
    10861086            &dx_block, dx_blocks);
     
    10891089                goto release_index;
    10901090        }
    1091        
     1091
    10921092        /* Try to insert to existing data block */
    10931093        uint32_t leaf_block_idx =
     
    10981098        if (rc != EOK)
    10991099                goto release_index;
    1100        
     1100
    11011101        block_t *target_block;
    11021102        rc = block_get(&target_block, fs->device, leaf_block_addr,
     
    11041104        if (rc != EOK)
    11051105                goto release_index;
    1106        
     1106
    11071107        /* Check if insert operation passed */
    11081108        rc = ext4_directory_try_insert_entry(fs->superblock, target_block, child,
     
    11101110        if (rc == EOK)
    11111111                goto release_target_index;
    1112        
     1112
    11131113        /*
    11141114         * Check if there is needed to split index node
     
    11181118        if (rc != EOK)
    11191119                goto release_target_index;
    1120        
     1120
    11211121        /* Split entries to two blocks (includes sorting by hash value) */
    11221122        block_t *new_block = NULL;
     
    11271127                goto release_target_index;
    11281128        }
    1129        
     1129
    11301130        /* Where to save new entry */
    11311131        uint32_t new_block_hash =
     
    11371137                rc = ext4_directory_try_insert_entry(fs->superblock, target_block,
    11381138                    child, name, name_len);
    1139        
     1139
    11401140        /* Cleanup */
    11411141        rc = block_put(new_block);
    11421142        if (rc != EOK)
    11431143                return rc;
    1144        
     1144
    11451145        /* Cleanup operations */
    1146        
     1146
    11471147release_target_index:
    11481148        rc2 = rc;
    1149        
     1149
    11501150        rc = block_put(target_block);
    11511151        if (rc != EOK)
    11521152                return rc;
    1153        
     1153
    11541154release_index:
    11551155        if (rc != EOK)
    11561156                rc2 = rc;
    1157        
     1157
    11581158        dx_it = dx_blocks;
    1159        
     1159
    11601160        while (dx_it <= dx_block) {
    11611161                rc = block_put(dx_it->block);
    11621162                if (rc != EOK)
    11631163                        return rc;
    1164                
     1164
    11651165                dx_it++;
    11661166        }
    1167        
     1167
    11681168        return rc2;
    11691169}
Note: See TracChangeset for help on using the changeset viewer.