Exemple #1
0
status_t dlist_add(nspace *vol, ino_t vnid)
{
	DPRINTF(0, ("dlist_add vnid %Lx\n", vnid));

	ASSERT(IS_DIR_CLUSTER_VNID(vnid));
	ASSERT(dlist_find(vol, CLUSTER_OF_DIR_CLUSTER_VNID(vnid)) == -1LL);
	ASSERT(vnid != 0);

	if (vol->dlist.entries == vol->dlist.allocated) {
		if (dlist_realloc(vol, vol->dlist.allocated + DLIST_ENTRY_QUANTUM) < 0)
			return -ENOMEM;
	}
	vol->dlist.vnid_list[vol->dlist.entries++] = vnid;

	return B_OK;
}
Exemple #2
0
status_t
dlist_add(nspace *vol, ino_t vnid)
{
	DPRINTF(0, ("dlist_add vnid %" B_PRIdINO "\n", vnid));

	ASSERT(IS_DIR_CLUSTER_VNID(vnid) || IS_ARTIFICIAL_VNID(vnid));
	ASSERT(vnid != 0);
	// XXX: check for duplicate entries

	if (vol->dlist.entries == vol->dlist.allocated) {
		if (dlist_realloc(vol, vol->dlist.allocated + DLIST_ENTRY_QUANTUM) < 0)
			return B_ERROR;
	}
	vol->dlist.vnid_list[vol->dlist.entries++] = vnid;

	return B_OK;
}
Exemple #3
0
status_t dlist_remove(nspace *vol, ino_t vnid)
{
	int i;

	DPRINTF(0, ("dlist_remove vnid %Lx\n", vnid));
	ASSERT(IS_DIR_CLUSTER_VNID(vnid));

	for (i=0;i<vol->dlist.entries;i++)
		if (vol->dlist.vnid_list[i] == vnid)
			break;
	ASSERT(i < vol->dlist.entries);
	if (i == vol->dlist.entries)
		return -ENOENT;
	for (;i<vol->dlist.entries-1;i++)
		vol->dlist.vnid_list[i] = vol->dlist.vnid_list[i+1];
	vol->dlist.entries--;

	if (vol->dlist.allocated - vol->dlist.entries > 2*DLIST_ENTRY_QUANTUM)
		return dlist_realloc(vol, vol->dlist.allocated - DLIST_ENTRY_QUANTUM);

	return B_OK;
}
Exemple #4
0
ino_t
dlist_find(nspace *vol, uint32 cluster)
{
	uint32 i;

	DPRINTF(1, ("dlist_find cluster %" B_PRIu32 "\n", cluster));

	ASSERT(((cluster >= 2) && (cluster < vol->total_clusters + 2)) || (cluster == 1));

	for (i = 0; i < vol->dlist.entries; i++) {
		ino_t loc;

		if (vcache_vnid_to_loc(vol, vol->dlist.vnid_list[i], &loc) < B_OK)
			loc = vol->dlist.vnid_list[i];
		ASSERT(IS_DIR_CLUSTER_VNID(loc));
		if (CLUSTER_OF_DIR_CLUSTER_VNID(loc) == cluster)
			return vol->dlist.vnid_list[i];
	}

	DPRINTF(1, ("dlist_find cluster %" B_PRIu32 " not found\n", cluster));

	return -1LL;
}