linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Ajay Kaher <akaher@vmware.com>
Cc: shuah@kernel.org, mhiramat@kernel.org, chinglinyu@google.com,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, lkp@intel.com,
	namit@vmware.com, oe-lkp@lists.linux.dev, amakhalov@vmware.com,
	er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu,
	tkundu@vmware.com, vsirnapalli@vmware.com
Subject: Re: [PATCH v4 04/10] eventfs: Implement eventfs file add functions
Date: Fri, 14 Jul 2023 12:23:13 -0400	[thread overview]
Message-ID: <20230714122313.486990ea@gandalf.local.home> (raw)
In-Reply-To: <1689248004-8158-5-git-send-email-akaher@vmware.com>


More nits.

On Thu, 13 Jul 2023 17:03:18 +0530
Ajay Kaher <akaher@vmware.com> wrote:

> Adding following function to eventfs to add files:

Add the following functions to add files to evenfs:

> 
> eventfs_add_top_file() adds the info of top file to
> eventfs and dynamically create these files when they
> are accessed.

I wonder if we should rename this, because I didn't really know what "top"
meant. Perhaps:

 eventfs_add_events_file() to add the data needed to create a specific file
 located at the top level events directory. The dentry/inode will be
 created when the events directory is scanned.

> 
> eventfs_add_file() adds the info of nested files
> to eventfs and dynamically create these files when
> they are accessed.

 eventfs_add_file() to add the data needed for files within the directories
 below the top level events directory. The dentry/inode of the file will be
 created when the directory that the file is in is scanned.

> 
> Signed-off-by: Ajay Kaher <akaher@vmware.com>
> Co-developed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Tested-by: Ching-lin Yu <chinglinyu@google.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202305051619.9a469a9a-yujie.liu@intel.com
> ---
>  fs/tracefs/event_inode.c | 84 ++++++++++++++++++++++++++++++++++++++++
>  include/linux/tracefs.h  |  8 ++++
>  2 files changed, 92 insertions(+)
> 
> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> index 4e7a8eccaa0b..75dc8953d813 100644
> --- a/fs/tracefs/event_inode.c
> +++ b/fs/tracefs/event_inode.c
> @@ -215,3 +215,87 @@ struct eventfs_file *eventfs_add_dir(const char *name,
>  	mutex_unlock(&eventfs_mutex);
>  	return ef;
>  }
> +
> +/**
> + * eventfs_add_top_file - add event top file to list to create later

I'm still thinking we should rename this to eventfs_add_events_file() to
match the "eventfs_create_events_dir()".

 eventfs_add_events_file - add the data needed to create file in events dir


> + * @name: the name of the file to create.
> + * @mode: the permission that the file should have.
> + * @parent: parent dentry for this file.
> + * @data: something that the caller will want to get to later on. The
> + *        inode.i_private pointer will point to this value on the open() call.

Note, for kerneldoc, it's best to have the above be one line, and then add
anything else below it.
 * @data: something that the caller will want to get to later on.

> + * @fop: struct file_operations that should be used for this file.
> + *
> + * This function adds top files of event dir to list.
> + * And all these files are created on the fly when they are looked up,
> + * and the dentry and inodes will be removed when they are done.

 * This function is used to add the information needed to create a
 * dentry/inode within the top level events directory. The file created
 * will have the @mode permissions. The @data will be used to fill the
 * inode.i_private when the open() call is done. The dentry and inodes are
 * all created when they are referenced, and removed when they are no
 * longer referenced.


> + */
> +int eventfs_add_top_file(const char *name, umode_t mode,
> +			 struct dentry *parent, void *data,
> +			 const struct file_operations *fop)
> +{
> +	struct tracefs_inode *ti;
> +	struct eventfs_inode *ei;
> +	struct eventfs_file *ef;
> +
> +	if (!parent)
> +		return -EINVAL;
> +
> +	if (!(mode & S_IFMT))
> +		mode |= S_IFREG;
> +
> +	if (!parent->d_inode)
> +		return -EINVAL;
> +
> +	ti = get_tracefs(parent->d_inode);
> +	if (!(ti->flags & TRACEFS_EVENT_INODE))
> +		return -EINVAL;
> +
> +	ei = ti->private;
> +	ef = eventfs_prepare_ef(name, mode, fop, NULL, data);
> +
> +	if (IS_ERR(ef))
> +		return -ENOMEM;
> +
> +	mutex_lock(&eventfs_mutex);
> +	list_add_tail(&ef->list, &ei->e_top_files);
> +	ef->d_parent = parent;
> +	mutex_unlock(&eventfs_mutex);
> +	return 0;
> +}
> +
> +/**
> + * eventfs_add_file - add eventfs file to list to create later

Same idea here.

 eventfs_add_file - add the data needed to create a file for later reference

> + * @name: the name of the file to create.
> + * @mode: the permission that the file should have.
> + * @ef_parent: parent eventfs_file for this file.
> + * @data: something that the caller will want to get to later on. The
> + *        inode.i_private pointer will point to this value on the open() call.

And same note about the line.

> + * @fop: struct file_operations that should be used for this file.
> + *
> + * This function adds top files of event dir to list.

Seems you have a cut and paste error here.

> + * And all these files are created on the fly when they are looked up,
> + * and the dentry and inodes will be removed when they are done.

 * This function is used to add the information needed to create a
 * file within a subdirectory of the events directory. The file created
 * will have the @mode permissions. The @data will be used to fill the
 * inode.i_private when the open() call is done. The dentry and inodes are
 * all created when they are referenced, and removed when they are no
 * longer referenced.

-- Steve

> + */
> +int eventfs_add_file(const char *name, umode_t mode,
> +		     struct eventfs_file *ef_parent,
> +		     void *data,
> +		     const struct file_operations *fop)
> +{
> +	struct eventfs_file *ef;
> +
> +	if (!ef_parent)
> +		return -EINVAL;
> +
> +	if (!(mode & S_IFMT))
> +		mode |= S_IFREG;
> +
> +	ef = eventfs_prepare_ef(name, mode, fop, NULL, data);
> +	if (IS_ERR(ef))
> +		return -ENOMEM;
> +
> +	mutex_lock(&eventfs_mutex);
> +	list_add_tail(&ef->list, &ef_parent->ei->e_top_files);
> +	ef->d_parent = ef_parent->dentry;
> +	mutex_unlock(&eventfs_mutex);
> +	return 0;
> +}
> diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
> index 432e5e6f7901..a51312ff803c 100644
> --- a/include/linux/tracefs.h
> +++ b/include/linux/tracefs.h
> @@ -32,6 +32,14 @@ struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
>  struct eventfs_file *eventfs_add_dir(const char *name,
>  				     struct eventfs_file *ef_parent);
>  
> +int eventfs_add_file(const char *name, umode_t mode,
> +		     struct eventfs_file *ef_parent, void *data,
> +		     const struct file_operations *fops);
> +
> +int eventfs_add_top_file(const char *name, umode_t mode,
> +			 struct dentry *parent, void *data,
> +			 const struct file_operations *fops);
> +
>  struct dentry *tracefs_create_file(const char *name, umode_t mode,
>  				   struct dentry *parent, void *data,
>  				   const struct file_operations *fops);


  reply	other threads:[~2023-07-14 16:23 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 11:33 [PATCH v4 00/10] tracing: introducing eventfs Ajay Kaher
2023-07-13 11:33 ` [PATCH v4 01/10] tracing: Require all trace events to have a TRACE_SYSTEM Ajay Kaher
2023-07-13 11:33 ` [PATCH v4 02/10] tracefs: Rename some tracefs function Ajay Kaher
2023-07-14 15:11   ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 03/10] eventfs: Implement eventfs dir creation functions Ajay Kaher
2023-07-14 15:44   ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 04/10] eventfs: Implement eventfs file add functions Ajay Kaher
2023-07-14 16:23   ` Steven Rostedt [this message]
2023-07-13 11:33 ` [PATCH v4 05/10] eventfs: Implement eventfs file, directory remove function Ajay Kaher
2023-07-14 16:35   ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 06/10] eventfs: Implement functions to create eventfs files and directories Ajay Kaher
2023-07-14 16:47   ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 07/10] eventfs: Implement eventfs lookup, read, open functions Ajay Kaher
2023-07-14 20:17   ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 08/10] eventfs: Implement tracefs_inode_cache Ajay Kaher
2023-07-14 20:27   ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 09/10] eventfs: Move tracing/events to eventfs Ajay Kaher
2023-07-14 21:06   ` Steven Rostedt
2023-07-19 11:08     ` Ajay Kaher
2023-07-19 11:08     ` Ajay Kaher
2023-09-08 12:14   ` Sven Schnelle
2023-09-08 12:31     ` Steven Rostedt
2023-07-13 11:33 ` [PATCH v4 10/10] test: ftrace: Fix kprobe test for eventfs Ajay Kaher
2023-07-14  2:37   ` Steven Rostedt
2023-07-14 13:27     ` Masami Hiramatsu
2023-07-17  5:24       ` Ajay Kaher
2023-07-17 12:24         ` Steven Rostedt
2023-07-14 22:58 ` [PATCH v4 00/10] tracing: introducing eventfs Steven Rostedt
2023-07-16 17:32   ` Ajay Kaher
2023-07-18 13:40     ` Steven Rostedt
2023-07-19 10:25       ` Ajay Kaher
2023-07-19 14:23         ` Steven Rostedt
2023-07-19 18:37           ` Ajay Kaher
2023-07-19 18:40             ` Steven Rostedt
2023-07-21 13:18               ` Steven Rostedt
2023-07-21 19:14                 ` Steven Rostedt
     [not found]               ` <20230721084839.4a97a595@gandalf.local.home>
2023-07-21 13:19                 ` Steven Rostedt
2023-07-21 17:17                   ` Nadav Amit
2023-07-21 17:24                     ` Steven Rostedt
2023-07-21 17:30                     ` Steven Rostedt
2023-07-21 20:40                   ` Steven Rostedt
2023-07-26 18:54                     ` Ajay Kaher

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=20230714122313.486990ea@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akaher@vmware.com \
    --cc=amakhalov@vmware.com \
    --cc=chinglinyu@google.com \
    --cc=er.ajay.kaher@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mhiramat@kernel.org \
    --cc=namit@vmware.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=shuah@kernel.org \
    --cc=srivatsa@csail.mit.edu \
    --cc=tkundu@vmware.com \
    --cc=vsirnapalli@vmware.com \
    /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).