Changeset dba4a23 in mainline for uspace/srv/fs/fat/fat_fat.c


Ignore:
Timestamp:
2010-07-28T15:22:22Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4637c72, 9a1d8ab
Parents:
6da81e0
Message:

Speed up sequential I/O by caching the "current" cluster in fat_block_get().
This improves sequentil read of a 5m file (using the cat command) by 45 seconds
(73s → 28s).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_fat.c

    r6da81e0 rdba4a23  
    142142    aoff64_t bn, int flags)
    143143{
     144        fat_cluster_t firstc = nodep->firstc;
     145        fat_cluster_t currc;
     146        aoff64_t relbn = bn;
     147        int rc;
     148
    144149        if (!nodep->size)
    145150                return ELIMIT;
     
    158163        }
    159164
     165        if (nodep->currc_cached_valid && bn >= nodep->currc_cached_bn) {
     166                /*
     167                 * We can start with the cluster cached by the previous call to
     168                 * fat_block_get().
     169                 */
     170                firstc = nodep->currc_cached_value;
     171                relbn -= (nodep->currc_cached_bn / SPC(bs)) * SPC(bs);
     172        }
     173
    160174fall_through:
    161         return _fat_block_get(block, bs, nodep->idx->dev_handle, nodep->firstc,
    162             NULL, bn, flags);
     175        rc = _fat_block_get(block, bs, nodep->idx->dev_handle, firstc,
     176            &currc, relbn, flags);
     177        if (rc != EOK)
     178                return rc;
     179       
     180        /*
     181         * Update the "current" cluster cache.
     182         */
     183        nodep->currc_cached_valid = true;
     184        nodep->currc_cached_bn = bn;
     185        nodep->currc_cached_value = currc;
     186
     187        return rc;
    163188}
    164189
     
    567592        dev_handle_t dev_handle = nodep->idx->dev_handle;
    568593
     594        /*
     595         * Invalidate cached cluster numbers.
     596         */
    569597        nodep->lastc_cached_valid = false;
     598        if (nodep->currc_cached_value != lcl)
     599                nodep->currc_cached_valid = false;
     600
    570601        if (lcl == FAT_CLST_RES0) {
    571602                /* The node will have zero size and no clusters allocated. */
     
    597628        }
    598629
     630        /*
     631         * Update and re-enable the last cluster cache.
     632         */
    599633        nodep->lastc_cached_valid = true;
    600634        nodep->lastc_cached_value = lcl;
Note: See TracChangeset for help on using the changeset viewer.