static __cacheline_aligned_in_smp DEFINE_SEQLOCK(ns_tree_lock);
+DEFINE_LOCK_GUARD_0(ns_tree_writer,
+ write_seqlock(&ns_tree_lock),
+ write_sequnlock(&ns_tree_lock))
+
+DEFINE_LOCK_GUARD_0(ns_tree_locked_reader,
+ read_seqlock_excl(&ns_tree_lock),
+ read_sequnlock_excl(&ns_tree_lock))
+
static struct ns_tree_root ns_unified_root = { /* protected by ns_tree_lock */
.ns_rb = RB_ROOT,
.ns_list_head = LIST_HEAD_INIT(ns_unified_root.ns_list_head),
VFS_WARN_ON_ONCE(!ns->ns_id);
- write_seqlock(&ns_tree_lock);
+ guard(ns_tree_writer)();
/* Add to per-type tree and list */
node = ns_tree_node_add(&ns->ns_tree_node, ns_tree, ns_cmp);
VFS_WARN_ON_ONCE(ns != to_ns_common(&init_user_ns));
}
}
- write_sequnlock(&ns_tree_lock);
VFS_WARN_ON_ONCE(node);
}
VFS_WARN_ON_ONCE(owner->ns_type != CLONE_NEWUSER);
- read_seqlock_excl(&ns_tree_lock);
- node = owner->ns_owner_root.ns_rb.rb_node;
+ guard(ns_tree_locked_reader)();
+ node = owner->ns_owner_root.ns_rb.rb_node;
while (node) {
struct ns_common *ns;
if (ret)
ret = ns_get_unless_inactive(ret);
- read_sequnlock_excl(&ns_tree_lock);
return ret;
}
return NULL;
}
- read_seqlock_excl(&ns_tree_lock);
+ guard(ns_tree_locked_reader)();
+
if (ns_tree)
node = ns_tree->ns_rb.rb_node;
else
if (ret)
ret = ns_get_unless_inactive(ret);
- read_sequnlock_excl(&ns_tree_lock);
return ret;
}