Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d2663d8 in mainline


Ignore:
Timestamp:
2013-09-13T16:02:09Z (7 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
master
Children:
8c5ba67
Parents:
cc8044e (diff), fd7dbbb (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.
Message:

merge mfs changes

Location:
uspace/srv/fs/mfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/mfs/mfs.h

    rcc8044e rd2663d8  
    4444#include <errno.h>
    4545#include <assert.h>
     46#include <stdbool.h>
    4647#include "../../vfs/vfs.h"
    4748
     
    105106        unsigned isearch;
    106107        unsigned zsearch;
     108
     109        /* Indicates wether if the cached number of free zones
     110         * is to be considered valid or not.
     111         */
     112        bool nfree_zones_valid;
     113        /* Cached number of free zones, used to avoid to scan
     114         * the whole bitmap every time the mfs_free_block_count()
     115         * is invoked.
     116         */
     117        unsigned nfree_zones;
    107118};
    108119
  • uspace/srv/fs/mfs/mfs_balloc.c

    rcc8044e rd2663d8  
    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
  • uspace/srv/fs/mfs/mfs_ops.c

    rcc8044e rd2663d8  
    216216        sbi->isearch = 0;
    217217        sbi->zsearch = 0;
     218        sbi->nfree_zones_valid = false;
     219        sbi->nfree_zones = 0;
    218220
    219221        if (version == MFS_VERSION_V3) {
     
    11811183                return rc;
    11821184
    1183         rc = mfs_count_free_zones(inst, &block_free);
    1184         *count = block_free;
     1185        struct mfs_sb_info *sbi = inst->sbi;
     1186
     1187        if (!sbi->nfree_zones_valid) {
     1188                /* The cached number of free zones is not valid,
     1189                 * we need to scan the bitmap to retrieve the
     1190                 * current value.
     1191                 */
     1192
     1193                rc = mfs_count_free_zones(inst, &block_free);
     1194                if (rc != EOK)
     1195                        return rc;
     1196
     1197                sbi->nfree_zones = block_free;
     1198                sbi->nfree_zones_valid = true;
     1199        }
     1200
     1201        *count = sbi->nfree_zones;
    11851202
    11861203        return rc;
Note: See TracChangeset for help on using the changeset viewer.