All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Hugh Dickins <hughd@google.com>
Cc: hooanon05g@gmail.com, Andrew Morton <akpm@linux-foundation.org>,
	Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, adilger@dilger.ca, hch@lst.de,
	dchinner@redhat.com, viro@zeniv.linux.org.uk, jlbec@evilplan.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [RFC 1/3] vfs: get_next_ino(), never inum=0
Date: Tue, 27 May 2014 22:53:09 -0700	[thread overview]
Message-ID: <CANn89i+PBEGp=9QGRioa7CUDZmApT-UNa=OJTdz4eu7AyO3Kbw@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1405272123020.1803@eggly.anvils>

On Tue, May 27, 2014 at 9:28 PM, Hugh Dickins <hughd@google.com> wrote:

>> Signed-off-by: J. R. Okajima <hooanon05g@gmail.com>
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Acked-by: Hugh Dickins <hughd@google.com>
>
>> ---
>>  fs/inode.c |    6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/inode.c b/fs/inode.c
>> index f96d2a6..a3e274a 100644
>> --- a/fs/inode.c
>> +++ b/fs/inode.c
>> @@ -848,7 +848,11 @@ unsigned int get_next_ino(void)
>>       }
>>  #endif
>>
>> -     *p = ++res;
>> +     res++;
>> +     /* never zero */
>> +     if (unlikely(!res))
>> +             res++;
>> +     *p = res;
>>       put_cpu_var(last_ino);
>>       return res;
>>  }

This is not right.

Each cpu 'owns' a window of 1024 consecutive inums.

If res == 0, then 1 does not necessarily belong to this cpu, and you
risk that about 1024 duplicate inums are given.

You need something like (sorry for bad formatting)

diff --git a/fs/inode.c b/fs/inode.c
index f96d2a6f88cc..66fd1189ddaa 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -839,6 +839,8 @@ unsigned int get_next_ino(void)
        unsigned int *p = &get_cpu_var(last_ino);
        unsigned int res = *p;

+start:
+
 #ifdef CONFIG_SMP
        if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
                static atomic_t shared_last_ino;
@@ -848,7 +850,10 @@ unsigned int get_next_ino(void)
        }
 #endif

-       *p = ++res;
+       if (unlikely(++res == 0))
+               goto start;
+       *p = res;
+
        put_cpu_var(last_ino);
        return res;
 }

  reply	other threads:[~2014-05-28  5:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 18:48 [RFC 0/3] vfs: get_next_ino(), never inum=0 and uniqueness hooanon05g
2014-05-21 18:48 ` [RFC 1/3] vfs: get_next_ino(), never inum=0 hooanon05g
2014-05-28  4:28   ` Hugh Dickins
2014-05-28  5:53     ` Eric Dumazet [this message]
2014-05-21 18:48 ` [RFC 2/3] vfs: get_next_ino(), support for the uniqueness hooanon05g
2014-05-22 11:56   ` Jan Kara
2014-05-22 15:03     ` J. R. Okajima
2014-05-22 15:12       ` Jan Kara
2014-05-22 15:14         ` Christoph Hellwig
2014-05-22 16:06           ` Jan Kara
2014-05-29 15:46           ` [PATCH v2 1/2] tmpfs: manage the inode-number by IDR J. R. Okajima
2014-05-29 15:46             ` [PATCH v2 2/2] tmpfs: refine a file handle for NFS-exporting J. R. Okajima
2014-05-31  2:43             ` [PATCH v2 1/2] tmpfs: manage the inode-number by IDR J. R. Okajima
2014-06-01 16:18           ` [RFC PATCH v3 0/2] the uniquness of tmpfs inode-number J. R. Okajima
2014-06-01 16:18             ` [RFC PATCH v3 1/2] tmpfs: manage the inode-number by IDR, signed int inum J. R. Okajima
2014-06-03  9:04               ` Jan Kara
2014-06-03 14:36                 ` J. R. Okajima
2014-06-05 12:27                 ` [RFC PATCH v4 0/2] tmpfs: manage the inode-number by IDR (performance measure) J. R. Okajima
2014-06-05 12:27                   ` [RFC PATCH v4 1/2] tmpfs: manage the inode-number by IDR, signed int inum J. R. Okajima
2014-06-05 12:27                   ` [RFC PATCH v4 2/2] tmpfs: refine a file handle for NFS-exporting J. R. Okajima
2014-06-01 16:18             ` [RFC PATCH v3 " J. R. Okajima
2014-05-21 18:49 ` [RFC 3/3] uniqueness of inode number, configfs, debugfs, procfs, ramfs and tmpfs hooanon05g
2014-05-22  1:03   ` J. R. Okajima
2014-05-22 11:53     ` Jan Kara
2014-05-22 14:58       ` J. R. Okajima
2014-05-22 15:09         ` Jan Kara

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='CANn89i+PBEGp=9QGRioa7CUDZmApT-UNa=OJTdz4eu7AyO3Kbw@mail.gmail.com' \
    --to=edumazet@google.com \
    --cc=adilger@dilger.ca \
    --cc=akpm@linux-foundation.org \
    --cc=dchinner@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=hooanon05g@gmail.com \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=jlbec@evilplan.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.