struct klist_node * klist_next(struct klist_iter * i)
{
	struct list_head * next;
	struct klist_node * lnode = i->i_cur;
	struct klist_node * knode = NULL;
	void (*put)(struct klist_node *) = i->i_klist->put;

#if defined(__VMKLNX__)
	VMK_ASSERT(vmk_PreemptionIsEnabled() == VMK_FALSE);
#endif
	spin_lock(&i->i_klist->k_lock);
	if (lnode) {
		next = lnode->n_node.next;
		if (!klist_dec_and_del(lnode))
			put = NULL;
	} else
		next = i->i_head->next;

	if (next != i->i_head) {
		knode = to_klist_node(next);
		kref_get(&knode->n_ref);
	}
	i->i_cur = knode;
	spin_unlock(&i->i_klist->k_lock);
	if (put && lnode)
		put(lnode);
	return knode;
}
예제 #2
0
struct klist_node *klist_next(struct klist_iter *i)
{
	struct klist_node *last = i->i_cur;
	struct klist_node *next;

	if (last) {
		next = to_klist_node(last->n_node.next);
	} else {
		next = to_klist_node(i->i_klist->k_list.next);
	}

	i->i_cur = NULL;
	while (next != to_klist_node(&i->i_klist->k_list)) {
        /* if the knode is not deleted */
		if (!knode_dead(next)) {
			i->i_cur = next;
			break;
		}
        /* skip the deleted knode */
		next = to_klist_node(next->n_node.next);
	}

	return i->i_cur;
}
예제 #3
0
struct klist_node * klist_next(struct klist_iter * i)
{
	struct list_head * next;
	struct klist_node * knode = NULL;

	spin_lock(&i->i_klist->k_lock);
	if (i->i_cur) {
		next = i->i_cur->n_node.next;
		klist_dec_and_del(i->i_cur);
	} else
		next = i->i_head->next;

	if (next != i->i_head) {
		knode = to_klist_node(next);
		kref_get(&knode->n_ref);
	}
	i->i_cur = knode;
	spin_unlock(&i->i_klist->k_lock);
	return knode;
}