From: Shang XiaoJing <shangxiaojing@huawei.com>
To: <jlbec@evilplan.org>, <hch@lst.de>, <linux-kernel@vger.kernel.org>
Cc: <shangxiaojing@huawei.com>
Subject: [PATCH -next 2/3] configfs: Add group_to_dentry helper
Date: Fri, 9 Sep 2022 14:56:10 +0800 [thread overview]
Message-ID: <20220909065611.31695-3-shangxiaojing@huawei.com> (raw)
In-Reply-To: <20220909065611.31695-1-shangxiaojing@huawei.com>
Add group_to_dentry helper function for more clear, which get the
corresponding dentry of the config_group.
Space is deleted due to checkpatch.pl.
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
---
fs/configfs/dir.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 4e086635b3ed..b5614b66add2 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -611,6 +611,11 @@ static int populate_attrs(struct config_item *item)
return error;
}
+static inline struct dentry *group_to_dentry(struct config_group *group)
+{
+ return group->cg_item.ci_dentry;
+}
+
static int configfs_attach_group(struct config_item *parent_item,
struct config_item *item,
struct dentry *dentry,
@@ -619,7 +624,7 @@ static void configfs_detach_group(struct config_item *item);
static void detach_groups(struct config_group *group)
{
- struct dentry * dentry = dget(group->cg_item.ci_dentry);
+ struct dentry *dentry = dget(group_to_dentry(group));
struct dentry *child;
struct configfs_dirent *parent_sd;
struct configfs_dirent *sd, *tmp;
@@ -668,7 +673,7 @@ static int create_default_group(struct config_group *parent_group,
int ret;
struct configfs_dirent *sd;
/* We trust the caller holds a reference to parent */
- struct dentry *child, *parent = parent_group->cg_item.ci_dentry;
+ struct dentry *child, *parent = group_to_dentry(parent_group);
if (!group->cg_item.ci_name)
group->cg_item.ci_name = group->cg_item.ci_namebuf;
@@ -1225,14 +1230,14 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys,
* additional locking to prevent other subsystem from being
* unregistered
*/
- inode_lock(d_inode(root->cg_item.ci_dentry));
+ inode_lock(d_inode(group_to_dentry(root)));
/*
* As we are trying to depend item from other subsystem
* we have to check if this subsystem is still registered
*/
subsys_sd = configfs_find_subsys_dentry(
- root->cg_item.ci_dentry->d_fsdata,
+ group_to_dentry(root)->d_fsdata,
&target_subsys->su_group.cg_item);
if (!subsys_sd)
goto out_root_unlock;
@@ -1249,7 +1254,7 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys,
* We were called from subsystem other than our target so we
* took some locks so now it's time to release them
*/
- inode_unlock(d_inode(root->cg_item.ci_dentry));
+ inode_unlock(d_inode(group_to_dentry(root)));
return ret;
}
@@ -1745,7 +1750,7 @@ int configfs_register_group(struct config_group *parent_group,
link_group(parent_group, group);
mutex_unlock(&subsys->su_mutex);
- parent = parent_group->cg_item.ci_dentry;
+ parent = group_to_dentry(parent_group);
inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
ret = create_default_group(parent_group, group, frag);
@@ -1753,7 +1758,7 @@ int configfs_register_group(struct config_group *parent_group,
goto err_out;
spin_lock(&configfs_dirent_lock);
- configfs_dir_set_ready(group->cg_item.ci_dentry->d_fsdata);
+ configfs_dir_set_ready(group_to_dentry(group)->d_fsdata);
spin_unlock(&configfs_dirent_lock);
inode_unlock(d_inode(parent));
put_fragment(frag);
@@ -1777,7 +1782,7 @@ EXPORT_SYMBOL(configfs_register_group);
void configfs_unregister_group(struct config_group *group)
{
struct configfs_subsystem *subsys = group->cg_subsys;
- struct dentry *dentry = group->cg_item.ci_dentry;
+ struct dentry *dentry = group_to_dentry(group);
struct dentry *parent = group->cg_item.ci_parent->ci_dentry;
struct configfs_dirent *sd = dentry->d_fsdata;
struct configfs_fragment *frag = sd->s_frag;
@@ -1913,7 +1918,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
{
struct config_group *group = &subsys->su_group;
- struct dentry *dentry = group->cg_item.ci_dentry;
+ struct dentry *dentry = group_to_dentry(group);
struct dentry *root = dentry->d_sb->s_root;
struct configfs_dirent *sd = dentry->d_fsdata;
struct configfs_fragment *frag = sd->s_frag;
--
2.17.1
next prev parent reply other threads:[~2022-09-09 6:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 6:56 [PATCH -next 0/3] configfs: Clean up by adding helpers Shang XiaoJing
2022-09-09 6:56 ` [PATCH -next 1/3] configfs: Add configfs_remove_drop_dirent helper Shang XiaoJing
2022-09-09 6:56 ` Shang XiaoJing [this message]
2022-09-09 6:56 ` [PATCH -next 3/3] configfs: Add subsys_to_item helper Shang XiaoJing
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=20220909065611.31695-3-shangxiaojing@huawei.com \
--to=shangxiaojing@huawei.com \
--cc=hch@lst.de \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®