linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] tracefs: dentry lookup crapectomy
Date: Tue, 30 Jan 2024 23:26:21 +0000	[thread overview]
Message-ID: <20240130232621.GL2087318@ZenIV> (raw)
In-Reply-To: <20240130190355.11486-3-torvalds@linux-foundation.org>

On Tue, Jan 30, 2024 at 11:03:52AM -0800, Linus Torvalds wrote:
> The dentry lookup for eventfs files was very broken, and had lots of
> signs of the old situation where the filesystem names were all created
> statically in the dentry tree, rather than being looked up dynamically
> based on the eventfs data structures.
> 
> You could see it in the naming - how it claimed to "create" dentries
> rather than just look up the dentries that were given it.
> 
> You could see it in various nonsensical and very incorrect operations,
> like using "simple_lookup()" on the dentries that were passed in, which
> only results in those dentries becoming negative dentries.  Which meant
> that any other lookup would possibly return ENOENT if it saw that
> negative dentry before the data rwas then later filled in.
> 
> You could see it in the immesnse amount of nonsensical code that didn't
> actually just do lookups.

> -static struct dentry *create_file(const char *name, umode_t mode,
> +static struct dentry *lookup_file(struct dentry *dentry,
> +				  umode_t mode,
>  				  struct eventfs_attr *attr,
> -				  struct dentry *parent, void *data,
> +				  void *data,
>  				  const struct file_operations *fop)
>  {
>  	struct tracefs_inode *ti;
> -	struct dentry *dentry;
>  	struct inode *inode;
>  
>  	if (!(mode & S_IFMT))
> @@ -307,12 +304,6 @@ static struct dentry *create_file(const char *name, umode_t mode,
>  	if (WARN_ON_ONCE(!S_ISREG(mode)))
>  		return NULL;
>  
> -	WARN_ON_ONCE(!parent);
> -	dentry = eventfs_start_creating(name, parent);

Used to lock the inode of parent.

>  	if (unlikely(!inode))
>  		return eventfs_failed_creating(dentry);

... and that still unlocks it.

> @@ -331,29 +322,25 @@ static struct dentry *create_file(const char *name, umode_t mode,
>  	ti->flags = TRACEFS_EVENT_INODE;
>  	ti->private = NULL;			// Directories have 'ei', files not
>  
> -	d_instantiate(dentry, inode);
> +	d_add(dentry, inode);
>  	fsnotify_create(dentry->d_parent->d_inode, dentry);
>  	return eventfs_end_creating(dentry);

... and so does this.

>  };

Where has that inode_lock() gone and how could that possibly work?

  reply	other threads:[~2024-01-30 23:26 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 19:03 [PATCH 1/6] tracefs: avoid using the ei->dentry pointer unnecessarily Linus Torvalds
2024-01-30 19:03 ` [PATCH 2/6] eventfsfs: initialize the tracefs inode properly Linus Torvalds
2024-01-30 19:48   ` Steven Rostedt
2024-01-30 19:56     ` Steven Rostedt
2024-01-30 19:49   ` Steven Rostedt
2024-01-30 19:03 ` [PATCH 3/6] tracefs: dentry lookup crapectomy Linus Torvalds
2024-01-30 23:26   ` Al Viro [this message]
2024-01-30 23:55     ` Steven Rostedt
2024-01-31  0:07       ` Al Viro
2024-01-31  0:23   ` Al Viro
2024-01-31  0:39     ` Linus Torvalds
2024-01-30 19:03 ` [PATCH 4/6] eventfs: remove unused 'd_parent' pointer field Linus Torvalds
2024-01-30 19:03 ` [PATCH 5/6] eventfs: get rid of dentry pointers without refcounts Linus Torvalds
2024-01-30 20:55   ` Steven Rostedt
2024-01-30 21:52     ` Linus Torvalds
2024-01-30 22:56       ` Steven Rostedt
2024-01-30 22:58         ` Linus Torvalds
2024-01-30 23:04           ` Steven Rostedt
2024-01-30 22:56       ` Linus Torvalds
2024-01-30 23:06         ` Linus Torvalds
2024-01-30 23:10           ` Steven Rostedt
2024-01-30 23:25             ` Linus Torvalds
2024-01-31  0:48   ` Al Viro
2024-01-31  5:09   ` Steven Rostedt
2024-01-31  5:25     ` Linus Torvalds
2024-01-31  5:33       ` Steven Rostedt
2024-01-31  5:57         ` Linus Torvalds
2024-01-31  6:20           ` Linus Torvalds
2024-01-31 12:57             ` Steven Rostedt
2024-01-31 13:14               ` Steven Rostedt
2024-01-31 18:08                 ` Linus Torvalds
2024-01-31 18:39                   ` Steven Rostedt
2024-01-30 19:03 ` [PATCH 6/6] eventfs: clean up dentry ops and add revalidate function Linus Torvalds
2024-01-30 21:25   ` Steven Rostedt
2024-01-30 21:36     ` Linus Torvalds
2024-01-31  1:12   ` Al Viro
2024-01-31  2:37     ` Linus Torvalds
2024-01-31  2:46       ` Al Viro
2024-01-31  3:39         ` Linus Torvalds
2024-01-31  4:28           ` Al Viro
2024-01-31 18:00   ` Steven Rostedt
2024-01-31 23:07     ` Masami Hiramatsu
2024-01-31 23:23       ` 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=20240130232621.GL2087318@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --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;
as well as URLs for NNTP newsgroup(s).