|
@@ -623,6 +623,8 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
|
|
unsigned flags)
|
|
unsigned flags)
|
|
{
|
|
{
|
|
struct kernfs_node *kn;
|
|
struct kernfs_node *kn;
|
|
|
|
+ u32 gen;
|
|
|
|
+ int cursor;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
name = kstrdup_const(name, GFP_KERNEL);
|
|
name = kstrdup_const(name, GFP_KERNEL);
|
|
@@ -635,12 +637,17 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
|
|
|
|
|
|
idr_preload(GFP_KERNEL);
|
|
idr_preload(GFP_KERNEL);
|
|
spin_lock(&kernfs_idr_lock);
|
|
spin_lock(&kernfs_idr_lock);
|
|
- ret = idr_alloc(&root->ino_idr, kn, 1, 0, GFP_ATOMIC);
|
|
|
|
|
|
+ cursor = idr_get_cursor(&root->ino_idr);
|
|
|
|
+ ret = idr_alloc_cyclic(&root->ino_idr, kn, 1, 0, GFP_ATOMIC);
|
|
|
|
+ if (ret >= 0 && ret < cursor)
|
|
|
|
+ root->next_generation++;
|
|
|
|
+ gen = root->next_generation;
|
|
spin_unlock(&kernfs_idr_lock);
|
|
spin_unlock(&kernfs_idr_lock);
|
|
idr_preload_end();
|
|
idr_preload_end();
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
goto err_out2;
|
|
goto err_out2;
|
|
kn->ino = ret;
|
|
kn->ino = ret;
|
|
|
|
+ kn->generation = gen;
|
|
|
|
|
|
atomic_set(&kn->count, 1);
|
|
atomic_set(&kn->count, 1);
|
|
atomic_set(&kn->active, KN_DEACTIVATED_BIAS);
|
|
atomic_set(&kn->active, KN_DEACTIVATED_BIAS);
|
|
@@ -884,6 +891,7 @@ struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
|
|
|
|
|
|
idr_init(&root->ino_idr);
|
|
idr_init(&root->ino_idr);
|
|
INIT_LIST_HEAD(&root->supers);
|
|
INIT_LIST_HEAD(&root->supers);
|
|
|
|
+ root->next_generation = 1;
|
|
|
|
|
|
kn = __kernfs_new_node(root, "", S_IFDIR | S_IRUGO | S_IXUGO,
|
|
kn = __kernfs_new_node(root, "", S_IFDIR | S_IRUGO | S_IXUGO,
|
|
KERNFS_DIR);
|
|
KERNFS_DIR);
|