All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ajay Kaher <akaher@vmware.com>
To: Zheng Yejian <zhengyejian1@huawei.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	"mhiramat@kernel.org" <mhiramat@kernel.org>,
	"shuah@kernel.org" <shuah@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-trace-kernel@vger.kernel.org" 
	<linux-trace-kernel@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"chinglinyu@google.com" <chinglinyu@google.com>,
	Nadav Amit <namit@vmware.com>,
	"srivatsab@vmware.com" <srivatsab@vmware.com>,
	"srivatsa@csail.mit.edu" <srivatsa@csail.mit.edu>,
	Alexey Makhalov <amakhalov@vmware.com>,
	Vasavi Sirnapalli <vsirnapalli@vmware.com>,
	Tapas Kundu <tkundu@vmware.com>,
	"er.ajay.kaher@gmail.com" <er.ajay.kaher@gmail.com>
Subject: Re: [PATCH v2 2/9] eventfs: adding eventfs dir add functions
Date: Mon, 19 Jun 2023 05:24:48 +0000	[thread overview]
Message-ID: <5543FD40-36FC-4459-BF78-E2C0A361E9AE@vmware.com> (raw)
In-Reply-To: <A1697525-CE86-4CA3-A8D5-3452E9310A4C@vmware.com>



> On 10-May-2023, at 4:55 PM, Ajay Kaher <akaher@vmware.com> wrote:
>> 
>> Hi,
>> eventfs_add_subsystem_dir() and eventfs_add_dir() are almost the same,
>> how about extract a common help function to simplify them, like:
>> 
>> +static struct eventfs_file *__eventfs_add_dir(const char *name,
>> +                                             struct dentry *d_parent,
>> +                                             struct eventfs_inode
>> *ei_parent,
>> +                                             struct rw_semaphore
>> *eventfs_rwsem)
>> +{
>> +       struct eventfs_file *ef;
>> +
>> +       ef = kzalloc(sizeof(*ef), GFP_KERNEL);
>> +       if (!ef)
>> +               return ERR_PTR(-ENOMEM);
>> +
>> +       ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
>> +       if (!ef->ei) {
>> +               kfree(ef);
>> +               return ERR_PTR(-ENOMEM);
>> +       }
>> +
>> +       INIT_LIST_HEAD(&ef->ei->e_top_files);
>> +
>> +       ef->name = kstrdup(name, GFP_KERNEL);
>> +       if (!ef->name) {
>> +               kfree(ef->ei);
>> +               kfree(ef);
>> +               return ERR_PTR(-ENOMEM);
>> +       }
>> +
>> +       ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
>> +       ef->iop = &eventfs_root_dir_inode_operations;
>> +       ef->fop = &eventfs_file_operations;
>> +       ef->dentry = NULL;
>> +       ef->created = false;
>> +       ef->d_parent = d_parent;
>> +       ef->data = eventfs_rwsem;
>> +
>> +       eventfs_down_write(eventfs_rwsem);
>> +       list_add_tail(&ef->list, &ei_parent->e_top_files);
>> +       eventfs_up_write(eventfs_rwsem);
>> +       return ef;
>> +}
>> +
>> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
>> +                                              struct dentry *parent,
>> +                                              struct rw_semaphore
>> *eventfs_rwsem)
>> +{
>> +       struct tracefs_inode *ti_parent;
>> +       struct eventfs_inode *ei_parent;
>> +
>> +       if (!parent)
>> +               return ERR_PTR(-EINVAL);
>> +       ti_parent = get_tracefs(parent->d_inode);
>> +       ei_parent = ti_parent->private;
>> +       return __eventfs_add_dir(name, parent, ei_parent, eventfs_rwsem);
>> +}
>> +
>> +struct eventfs_file *eventfs_add_dir(const char *name,
>> +                                    struct eventfs_file *ef_parent,
>> +                                    struct rw_semaphore *eventfs_rwsem)
>> +{
>> +       if (!ef_parent)
>> +               return ERR_PTR(-EINVAL);
>> +       return __eventfs_add_dir(name, NULL, ef_parent->ei, eventfs_rwsem);
>> +}
> 
> Sounds good. Thanks for sharing code snippet. I will consider in v3.
> 

Hi Zheng, I have moved common code to eventfs_prepare_ef() in v3 3/10, 4/10:
https://lore.kernel.org/all/1685610013-33478-1-git-send-email-akaher@vmware.com/

-Ajay


  reply	other threads:[~2023-06-19  5:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 1/9] eventfs: introducing struct tracefs_inode Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 2/9] eventfs: adding eventfs dir add functions Ajay Kaher
2023-05-08  9:32   ` Zheng Yejian
2023-05-10 11:25     ` Ajay Kaher
2023-06-19  5:24       ` Ajay Kaher [this message]
2023-05-02 11:23 ` [PATCH v2 3/9] eventfs: adding eventfs file " Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
2023-05-02 14:21   ` kernel test robot
2023-05-02 16:04   ` kernel test robot
2023-05-02 22:15   ` kernel test robot
2023-05-02 11:23 ` [PATCH v2 5/9] eventfs: adding functions to create eventfs files and directories Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 6/9] eventfs: adding eventfs lookup, read, open functions Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 7/9] eventfs: creating tracefs_inode_cache Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
2023-05-02 13:40   ` kernel test robot
2023-05-02 18:07   ` kernel test robot
2023-05-09 12:29     ` Ajay Kaher
2023-05-09 16:45       ` Steven Rostedt
2023-05-10 11:11         ` Ajay Kaher
2023-05-12 22:59           ` Steven Rostedt
2023-05-15 11:35             ` Ajay Kaher
2023-05-05  9:37   ` kernel test robot
2023-05-17 12:40     ` Ajay Kaher
2023-05-17 14:14       ` Steven Rostedt
2023-05-02 11:23 ` [PATCH v2 9/9] test: ftrace: fix kprobe test for eventfs 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=5543FD40-36FC-4459-BF78-E2C0A361E9AE@vmware.com \
    --to=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=mhiramat@kernel.org \
    --cc=namit@vmware.com \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=srivatsa@csail.mit.edu \
    --cc=srivatsab@vmware.com \
    --cc=tkundu@vmware.com \
    --cc=vsirnapalli@vmware.com \
    --cc=zhengyejian1@huawei.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 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.