Convert net_namespace to new IDA API

Signed-off-by: Matthew Wilcox <willy@infradead.org>
This commit is contained in:
Matthew Wilcox 2018-06-17 05:37:08 -04:00
parent 4c9ca2fd7c
commit 6e77cc4710
1 changed files with 6 additions and 10 deletions

View File

@ -973,22 +973,18 @@ static int register_pernet_operations(struct list_head *list,
int error; int error;
if (ops->id) { if (ops->id) {
again: error = ida_alloc_min(&net_generic_ids, MIN_PERNET_OPS_ID,
error = ida_get_new_above(&net_generic_ids, MIN_PERNET_OPS_ID, ops->id); GFP_KERNEL);
if (error < 0) { if (error < 0)
if (error == -EAGAIN) {
ida_pre_get(&net_generic_ids, GFP_KERNEL);
goto again;
}
return error; return error;
} *ops->id = error;
max_gen_ptrs = max(max_gen_ptrs, *ops->id + 1); max_gen_ptrs = max(max_gen_ptrs, *ops->id + 1);
} }
error = __register_pernet_operations(list, ops); error = __register_pernet_operations(list, ops);
if (error) { if (error) {
rcu_barrier(); rcu_barrier();
if (ops->id) if (ops->id)
ida_remove(&net_generic_ids, *ops->id); ida_free(&net_generic_ids, *ops->id);
} }
return error; return error;
@ -999,7 +995,7 @@ static void unregister_pernet_operations(struct pernet_operations *ops)
__unregister_pernet_operations(ops); __unregister_pernet_operations(ops);
rcu_barrier(); rcu_barrier();
if (ops->id) if (ops->id)
ida_remove(&net_generic_ids, *ops->id); ida_free(&net_generic_ids, *ops->id);
} }
/** /**