Changeset 0c2d9bb in mainline for uspace/srv/fs/mfs/mfs_ops.c


Ignore:
Timestamp:
2013-12-25T22:54:29Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b51cf2c
Parents:
f7a33de (diff), ac36aed (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 mainline changes

File:
1 edited

Legend:

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

    rf7a33de r0c2d9bb  
    6464static int mfs_check_sanity(struct mfs_sb_info *sbi);
    6565static bool is_power_of_two(uint32_t n);
     66static int mfs_size_block(service_id_t service_id, uint32_t *size);
     67static int mfs_total_block_count(service_id_t service_id, uint64_t *count);
     68static int mfs_free_block_count(service_id_t service_id, uint64_t *count);
    6669
    6770static hash_table_t open_nodes;
     
    8487        .destroy = mfs_destroy_node,
    8588        .has_children = mfs_has_children,
    86         .lnkcnt_get = mfs_lnkcnt_get
     89        .lnkcnt_get = mfs_lnkcnt_get,
     90        .size_block = mfs_size_block,
     91        .total_block_count = mfs_total_block_count,
     92        .free_block_count = mfs_free_block_count
    8793};
    8894
     
    210216        sbi->isearch = 0;
    211217        sbi->zsearch = 0;
     218        sbi->nfree_zones_valid = false;
     219        sbi->nfree_zones = 0;
    212220
    213221        if (version == MFS_VERSION_V3) {
     
    11291137}
    11301138
     1139static int
     1140mfs_size_block(service_id_t service_id, uint32_t *size)
     1141{
     1142        struct mfs_instance *inst;
     1143        int rc;
     1144
     1145        rc = mfs_instance_get(service_id, &inst);
     1146        if (rc != EOK)
     1147                return rc;
     1148
     1149        if (NULL == inst)
     1150                return ENOENT;
     1151       
     1152        *size = inst->sbi->block_size;
     1153
     1154        return EOK;
     1155}
     1156
     1157static int
     1158mfs_total_block_count(service_id_t service_id, uint64_t *count)
     1159{
     1160        struct mfs_instance *inst;
     1161        int rc;
     1162       
     1163        rc = mfs_instance_get(service_id, &inst);
     1164        if (rc != EOK)
     1165                return rc;
     1166
     1167        if (NULL == inst)
     1168                return ENOENT;
     1169       
     1170        *count = (uint64_t) MFS_BMAP_SIZE_BITS(inst->sbi, BMAP_ZONE);
     1171
     1172        return EOK;
     1173}
     1174
     1175static int
     1176mfs_free_block_count(service_id_t service_id, uint64_t *count)
     1177{
     1178        uint32_t block_free;
     1179       
     1180        struct mfs_instance *inst;
     1181        int rc = mfs_instance_get(service_id, &inst);
     1182        if (rc != EOK)
     1183                return rc;
     1184
     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;
     1202
     1203        return rc;
     1204}
     1205
    11311206vfs_out_ops_t mfs_ops = {
    11321207        .mounted = mfs_mounted,
Note: See TracChangeset for help on using the changeset viewer.