From: Rik van Riel <riel@redhat.com>
To: Carlos Maiolino <cmaiolino@redhat.com>, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC PATCH] vfs: avoid creation of inode number 0 in get_next_ino
Date: Tue, 30 Jun 2015 00:35:42 -0400 [thread overview]
Message-ID: <55921C9E.90405@redhat.com> (raw)
In-Reply-To: <1435245958-4507-1-git-send-email-cmaiolino@redhat.com>
On 06/25/2015 11:25 AM, Carlos Maiolino wrote:
> 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 <cmaiolino@redhat.com>
This approach makes a lot of sense to me. A very simple
change in the kernel helps userspace avoid a world of pain.
> 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 */
Would be nice if the comment explained why. Maybe something like this?
/*
* Glibc is unable to delete inode zero, which can cause all
* kinds of havoc for userspace. That trouble is easily avoided
* by never returning an inode number of zero.
*/
> + if (unlikely(!res))
> + res++;
> + *p = res;
> put_cpu_var(last_ino);
> return res;
> }
>
--
All rights reversed
prev parent reply other threads:[~2015-06-30 4:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 15:25 [RFC PATCH] vfs: avoid creation of inode number 0 in get_next_ino Carlos Maiolino
2015-06-30 4:35 ` Rik van Riel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55921C9E.90405@redhat.com \
--to=riel@redhat.com \
--cc=cmaiolino@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).