Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1664146 > unrolled thread

Re: [PATCH 02/11] kernfs: use idr instead of ida to manage inode number

Started byTejun Heo <tj@kernel.org>
First post2017-06-12 20:20 +0200
Last post2017-06-12 20:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 02/11] kernfs: use idr instead of ida to manage inode  number Tejun Heo <tj@kernel.org> - 2017-06-12 20:20 +0200

#1664146 — Re: [PATCH 02/11] kernfs: use idr instead of ida to manage inode number

FromTejun Heo <tj@kernel.org>
Date2017-06-12 20:20 +0200
SubjectRe: [PATCH 02/11] kernfs: use idr instead of ida to manage inode number
Message-ID<tRC6u-5IS-5@gated-at.bofh.it>
Hello,

On Fri, Jun 02, 2017 at 02:53:55PM -0700, Shaohua Li wrote:
> @@ -630,7 +633,11 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
>  	if (!kn)
>  		goto err_out1;
>  
> -	ret = ida_simple_get(&root->ino_ida, 1, 0, GFP_KERNEL);
> +	idr_preload(GFP_KERNEL);
> +	spin_lock(&kernfs_idr_lock);
> +	ret = idr_alloc(&root->ino_idr, kn, 1, 0, GFP_ATOMIC);
> +	spin_unlock(&kernfs_idr_lock);
> +	idr_preload_end();

So, this ends up populating the idr w/ a kn which isn't fully
initialized yet, which can lead to bugs which are difficult to hunt
down as we're gonna allow kn's to be looked up through ino / gen.  We
probably should allocate with NULL here and populate the actual
pointer with idr_replace() after the kn is fully initialized / online.

Thanks.

-- 
tejun

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web