*/
static int
cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
- void *data, int start)
+ void *data, int *pstart)
{
struct hlist_node *hnode;
struct hlist_node *next = NULL;
cfs_hash_for_each_bucket(hs, &bd, i) {
struct hlist_head *hhead;
- if (i < start)
+ if (pstart && i < *pstart)
continue;
else if (end > 0 && i >= end)
break;
break;
}
- if (start > 0 && rc == 0) {
- end = start;
- start = 0;
+ if (pstart && *pstart > 0 && rc == 0) {
+ end = *pstart;
+ *pstart = 0;
goto again;
}
cfs_hash_unlock(hs, 0);
+ if (pstart)
+ *pstart = i;
return count;
}
RETURN(-EOPNOTSUPP);
cfs_hash_for_each_enter(hs);
- cfs_hash_for_each_relax(hs, func, data, start);
+ cfs_hash_for_each_relax(hs, func, data, &start);
cfs_hash_for_each_exit(hs);
RETURN(0);
cfs_hash_for_each_cb_t func, void *data)
{
unsigned i = 0;
+ int start = 0;
ENTRY;
if (cfs_hash_with_no_lock(hs))
return -EOPNOTSUPP;
cfs_hash_for_each_enter(hs);
- while (cfs_hash_for_each_relax(hs, func, data, 0)) {
+ while (cfs_hash_for_each_relax(hs, func, data, &start)) {
CDEBUG(D_INFO, "Try to empty hash: %s, loop: %u\n",
hs->hs_name, i++);
}
cfs_hash_for_each_exit(hs);
+ LASSERT(atomic_read(&hs->hs_count) == 0);
RETURN(0);
}
EXPORT_SYMBOL(cfs_hash_for_each_empty);