Пример #1
0
static ssm_bitmap_t *
ctn_space_bmap_init(int col_size, int unit_size)
{
	int		nbits;
	bitmap_t	*bitmap;
	ssm_bitmap_t	*bmap;

	nbits = (col_size + unit_size - 1) / unit_size;
	bitmap = bmap_alloc(nbits);
	if (!bitmap) {
		fprintf(stderr,	"Failed to allocate bitmap.\n");
		return NULL;
	}

	bmap = (ssm_bitmap_t *)malloc(sizeof(ssm_bitmap_t));
	if (!bmap) {
		fprintf(stderr,	"Failed to allocate bitmap structure.\n");
		free(bitmap);
		return NULL;
	}

	bmap->sb_magic = SSM_MAGIC_1_0;
	bmap->sb_seqno = ssm_seqno;
	bmap->sb_bitmap = bitmap;
	bmap->sb_nbit = nbits;

	return bmap;
}
Пример #2
0
	clear_bit(buf->buf.bmap, bit);
	bdirty(buf, TRUE);
    }
    brelse(buf);
    return TRUE;
}


/* Data-block bitmap handling. */

/* Allocate a new block from DEV's bitmap. LOCALITY is where you want the
   new block to be close to. Note that LOCALITY is ignored for now... */
blkno
alloc_block(struct fs_device *dev, __attribute__ ((unused)) blkno locality)
{
    blkno blk = bmap_alloc(dev, dev->sup.data_bitmap, dev->sup.data_size);
    return (blk == NO_FREE_BLOCK) ? 0 : dev->sup.data + blk;
}

/* Deallocate the block BLK from DEV. */
bool
free_block(struct fs_device *dev, blkno blk)
{
    return bmap_free(dev, dev->sup.data_bitmap, blk - dev->sup.data);
}


/* Returns the total number of used blocks in the device DEV. This takes
   into account the boot-block, inode-blocks and the bitmap-blocks. */
u_long
used_blocks(struct fs_device *dev)
Пример #3
0
/* Allocate a new block from DEV's bitmap. LOCALITY is where you want the
   new block to be close to. Note that LOCALITY is ignored for now... */
blkno
alloc_block(struct fs_device *dev, blkno locality)
{
    blkno blk = bmap_alloc(dev, dev->sup.data_bitmap, dev->sup.data_size);
    return (blk == -1) ? 0 : dev->sup.data + blk;
}