diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 853a69e493f5b994f720b1d043d1c49b9339ec43..a4a538abcaf9a4c31ace90976b14fcf800204f1e 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -624,7 +624,6 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, { struct kernfs_node *kn; u32 gen; - int cursor; int ret; name = kstrdup_const(name, GFP_KERNEL); @@ -637,11 +636,11 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, idr_preload(GFP_KERNEL); spin_lock(&kernfs_idr_lock); - cursor = idr_get_cursor(&root->ino_idr); ret = idr_alloc_cyclic(&root->ino_idr, kn, 1, 0, GFP_ATOMIC); - if (ret >= 0 && ret < cursor) + if (ret >= 0 && ret < root->last_ino) root->next_generation++; gen = root->next_generation; + root->last_ino = ret; spin_unlock(&kernfs_idr_lock); idr_preload_end(); if (ret < 0) diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 814643f7ee529eb6c9e27ec3e1653487d818595e..84e9358d605f8778d484678d08ede89e4e0f1178 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -186,6 +186,7 @@ struct kernfs_root { /* private fields, do not use outside kernfs proper */ struct idr ino_idr; + u32 last_ino; u32 next_generation; struct kernfs_syscall_ops *syscall_ops;