Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbdFLSOw (ORCPT ); Mon, 12 Jun 2017 14:14:52 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:34926 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422AbdFLSOu (ORCPT ); Mon, 12 Jun 2017 14:14:50 -0400 Date: Mon, 12 Jun 2017 14:14:47 -0400 From: Tejun Heo To: Shaohua Li Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, gregkh@linuxfoundation.org, hch@lst.de, axboe@fb.com, rostedt@goodmis.org, lizefan@huawei.com, Kernel-team@fb.com, Shaohua Li Subject: Re: [PATCH 02/11] kernfs: use idr instead of ida to manage inode number Message-ID: <20170612181447.GG19206@htj.duckdns.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 794 Lines: 24 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