Changeset 1eaa3cf in mainline for uspace/srv/fs/mfs/mfs_balloc.c


Ignore:
Timestamp:
2013-09-13T15:52:21Z (11 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eb40d86
Parents:
b5ba8f6
Message:

mfs: cache the number of free zones to speed up subsequent requests (do not scan the whole bitmap every time statfs() is invoked).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/mfs/mfs_balloc.c

    rb5ba8f6 r1eaa3cf  
    8888{
    8989        int r = mfs_alloc_bit(inst, zone, BMAP_ZONE);
     90        if (r != EOK)
     91                return r;
     92
     93        /* Update the cached number of free zones */
     94        struct mfs_sb_info *sbi = inst->sbi;
     95        if (sbi->nfree_zones_valid)
     96                sbi->nfree_zones--;
    9097
    9198        *zone += inst->sbi->firstdatazone - 1;
     
    103110mfs_free_zone(struct mfs_instance *inst, uint32_t zone)
    104111{
     112        int r;
     113
    105114        zone -= inst->sbi->firstdatazone - 1;
    106115
    107         return mfs_free_bit(inst, zone, BMAP_ZONE);
     116        r = mfs_free_bit(inst, zone, BMAP_ZONE);
     117        if (r != EOK)
     118                return r;
     119
     120        /* Update the cached number of free zones */
     121        struct mfs_sb_info *sbi = inst->sbi;
     122        if (sbi->nfree_zones_valid)
     123                sbi->nfree_zones++;
     124
     125        return r;
    108126}
    109127
Note: See TracChangeset for help on using the changeset viewer.