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


Ignore:
Timestamp:
2008-11-18T20:28:17Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
18c485a
Parents:
26fa0f9f
Message:

Avoid unnecessary block reads in block_get().

File:
1 edited

Legend:

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

    r26fa0f9f r1d8cdb1  
    9595                fidx = clst % (bps / sizeof(fat_cluster_t));
    9696                /* read FAT1 */
    97                 b = block_get(dev_handle, rscnt + fsec);
     97                b = block_get(dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE);
    9898                clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]);
    9999                assert(clst != FAT_CLST_BAD);
     
    115115 *                      is empty.
    116116 * @param bn            Block number.
     117 * @param flags         Flags passed to libblock.
    117118 *
    118119 * @return              Block structure holding the requested block.
     
    120121block_t *
    121122_fat_block_get(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc,
    122     bn_t bn)
     123    bn_t bn, int flags)
    123124{
    124125        block_t *b;
     
    144145                /* root directory special case */
    145146                assert(bn < rds);
    146                 b = block_get(dev_handle, rscnt + bs->fatcnt * sf + bn);
     147                b = block_get(dev_handle, rscnt + bs->fatcnt * sf + bn, flags);
    147148                return b;
    148149        }
     
    154155
    155156        b = block_get(dev_handle, ssa + (lastc - FAT_CLST_FIRST) * bs->spc +
    156             bn % bs->spc);
     157            bn % bs->spc, flags);
    157158
    158159        return b;
     
    184185        for (o = nodep->size - 1; o < pos && o < boundary;
    185186            o = ALIGN_DOWN(o + bps, bps)) {
    186                 b = fat_block_get(bs, nodep, o / bps);
     187                int flags = (o % bps == 0) ?
     188                    BLOCK_FLAGS_NOREAD : BLOCK_FLAGS_NONE;
     189                b = fat_block_get(bs, nodep, o / bps, flags);
    187190                memset(b->data + o % bps, 0, bps - o % bps);
    188191                b->dirty = true;                /* need to sync node */
     
    196199        for (o = boundary; o < pos; o += bps) {
    197200                b = _fat_block_get(bs, nodep->idx->dev_handle, mcl,
    198                     (o - boundary) / bps);
     201                    (o - boundary) / bps, BLOCK_FLAGS_NOREAD);
    199202                memset(b->data, 0, min(bps, pos - o));
    200203                b->dirty = true;                /* need to sync node */
     
    222225        rscnt = uint16_t_le2host(bs->rscnt);
    223226
    224         b = block_get(dev_handle, rscnt + (clst * sizeof(fat_cluster_t)) / bps);
     227        b = block_get(dev_handle, rscnt + (clst * sizeof(fat_cluster_t)) / bps,
     228            BLOCK_FLAGS_NONE);
    225229        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    226230        value = uint16_t_le2host(*cp);
     
    254258        assert(fatno < bs->fatcnt);
    255259        b = block_get(dev_handle, rscnt + sf * fatno +
    256             (clst * sizeof(fat_cluster_t)) / bps);
     260            (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
    257261        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    258262        *cp = host2uint16_t_le(value);
     
    324328        futex_down(&fat_alloc_lock);
    325329        for (b = 0, cl = 0; b < sf; blk++) {
    326                 blk = block_get(dev_handle, rscnt + b);
     330                blk = block_get(dev_handle, rscnt + b, BLOCK_FLAGS_NOREAD);
    327331                for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) {
    328332                        fat_cluster_t *clst = (fat_cluster_t *)blk->data + c;
Note: See TracChangeset for help on using the changeset viewer.