From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlos Maiolino Subject: [RFC PATCH] vfs: avoid creation of inode number 0 in get_next_ino Date: Thu, 25 Jun 2015 12:25:58 -0300 Message-ID: <1435245958-4507-1-git-send-email-cmaiolino@redhat.com> To: linux-fsdevel@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51686 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbbFYP0I (ORCPT ); Thu, 25 Jun 2015 11:26:08 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6C8402B6483 for ; Thu, 25 Jun 2015 15:26:08 +0000 (UTC) Received: from hades.maiolino.org.com ([10.3.112.5]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5PFQ47i018068 for ; Thu, 25 Jun 2015 11:26:06 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: currently, get_next_ino() is able to create inodes with inode number = 0. This have a bad impact in the filesystems relying in this function to generate inode numbers. While there is no problem at all in having inodes with number 0, userspace tools which handle file management tasks can have problems handling these files, like for example, the impossiblity of users to delete these files, since glibc will ignore them. So, I believe the best way is kernel to avoid creating them. This problem has been raised previously, but the old thread didn't have any other update for a year+, and I've seen too many users hitting the same issue regarding the impossibility to delete files while using filesystems relying on this function. So, I'm starting the thread again, with the same patch that I believe is enough to address this problem. Signed-off-by: Carlos Maiolino --- fs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index ea37cd1..01c3a4a 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -839,7 +839,11 @@ unsigned int get_next_ino(void) } #endif - *p = ++res; + res++; + /* get_next_ino should not provide a 0 inode number */ + if (unlikely(!res)) + res++; + *p = res; put_cpu_var(last_ino); return res; } -- 2.1.0