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 136ba4fba0b6c2d7ab81962637f79f58c4317fe5..e7a24d45a717b6b1714f1fcb4a0daf3d6acf03b1 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -192,6 +192,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;