From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Ajay Kaher <ajay.kaher@broadcom.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [RESEND] [PATCH] eventfs: Have inodes have unique inode numbers
Date: Fri, 26 Jan 2024 15:24:17 -0500 [thread overview]
Message-ID: <e3548c86-7422-432c-8b72-8de99fa9772f@efficios.com> (raw)
In-Reply-To: <20240126151251.74cb9285@gandalf.local.home>
On 2024-01-26 15:12, Steven Rostedt wrote:
[...]
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index e1b172c0e091..2187be6d7b23 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -223,13 +223,41 @@ static const struct inode_operations tracefs_file_inode_operations = {
> .setattr = tracefs_setattr,
> };
>
> +/* Copied from get_next_ino() but adds allocation for multiple inodes */
> +#define LAST_INO_BATCH 1024
> +#define LAST_INO_MASK (~(LAST_INO_BATCH - 1))
> +static DEFINE_PER_CPU(unsigned int, last_ino);
> +
> +unsigned int tracefs_get_next_ino(int files)
> +{
> + unsigned int *p = &get_cpu_var(last_ino);
> + unsigned int res = *p;
> +
> +#ifdef CONFIG_SMP
> + /* Check if adding files+1 overflows */
How does it handle a @files input where:
* (files+1 > LAST_INO_BATCH) ?
* (files+1 == LAST_INO_BATCH) ?
> + if (unlikely(!res || (res & LAST_INO_MASK) != ((res + files + 1) & LAST_INO_MASK))) {
> + static atomic_t shared_last_ino;
> + int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
> +
> + res = next - LAST_INO_BATCH;
> + }
> +#endif
> +
> + res++;
> + /* get_next_ino should not provide a 0 inode number */
> + if (unlikely(!res))
> + res++;
I suspect that bumping this res++ in the 0 case can cause inode range
reservation issues at (files+1 == LAST_INO_BATCH-1).
Thanks,
Mathieu
> + *p = res + files;
> + put_cpu_var(last_ino);
> + return res;
> +}
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2024-01-26 20:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 20:12 [RESEND] [PATCH] eventfs: Have inodes have unique inode numbers Steven Rostedt
2024-01-26 20:24 ` Mathieu Desnoyers [this message]
2024-01-26 21:27 ` Steven Rostedt
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=e3548c86-7422-432c-8b72-8de99fa9772f@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=ajay.kaher@broadcom.com \
--cc=brauner@kernel.org \
--cc=geert@linux-m68k.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.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