コード例 #1
0
static int free_inodes(int goal)
{
	struct list_head *tmp, *head = &inode_in_use;
	LIST_HEAD(freeable);
	int found = 0, depth = goal << 1;

	while ((tmp = head->prev) != head && depth--) {
		struct inode * inode = list_entry(tmp, struct inode, i_list);
		list_del(tmp);
		if (CAN_UNUSE(inode)) {
			list_del(&inode->i_hash);
			INIT_LIST_HEAD(&inode->i_hash);
			list_add(tmp, &freeable);
			if (++found < goal)
				continue;
			break;
		}
		list_add(tmp, head);
	}
	if (found) {
		spin_unlock(&inode_lock);
		dispose_list(&freeable);
		spin_lock(&inode_lock);
	}
	return found;
}
コード例 #2
0
ファイル: inode.c プロジェクト: dzavalishin/oskit
static int free_inodes(void)
{
	struct list_head list, *entry, *freeable = &list;
	int found = 0;

	INIT_LIST_HEAD(freeable);
	entry = inode_in_use.next;
	while (entry != &inode_in_use) {
		struct list_head *tmp = entry;

		entry = entry->next;
		if (!CAN_UNUSE(INODE(tmp)))
			continue;
		list_del(tmp);
		list_del(&INODE(tmp)->i_hash);
		INIT_LIST_HEAD(&INODE(tmp)->i_hash);
		list_add(tmp, freeable);
		list_entry(tmp, struct inode, i_list)->i_state = I_FREEING;
		found = 1;
	}

	if (found)
		dispose_list(freeable);

	return found;
}