diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-12-11 10:06:11 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-12-20 21:04:01 -0500 |
commit | 9a70adfff3379a6511483bd60dac06fda49b14a8 (patch) | |
tree | 35c22451e949ee443aa569fde651625154845706 /fs/configfs/dir.c | |
parent | 9fb434e7544b5013d1c2d8a2306f8b562cb52d80 (diff) |
fs: configfs: Factor out configfs_find_subsys_dentry()
configfs_depend_item() is quite complicated and should
be split up into smaller functions. This also allow to
share this code with other functions.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'fs/configfs/dir.c')
-rw-r--r-- | fs/configfs/dir.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 43decd26851c..3873ac10b68c 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -1079,11 +1079,30 @@ out_unlock_dirent_lock: | |||
1079 | return ret; | 1079 | return ret; |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | static inline struct configfs_dirent * | ||
1083 | configfs_find_subsys_dentry(struct configfs_dirent *root_sd, | ||
1084 | struct config_item *subsys_item) | ||
1085 | { | ||
1086 | struct configfs_dirent *p; | ||
1087 | struct configfs_dirent *ret = NULL; | ||
1088 | |||
1089 | list_for_each_entry(p, &root_sd->s_children, s_sibling) { | ||
1090 | if (p->s_type & CONFIGFS_DIR && | ||
1091 | p->s_element == subsys_item) { | ||
1092 | ret = p; | ||
1093 | break; | ||
1094 | } | ||
1095 | } | ||
1096 | |||
1097 | return ret; | ||
1098 | } | ||
1099 | |||
1100 | |||
1082 | int configfs_depend_item(struct configfs_subsystem *subsys, | 1101 | int configfs_depend_item(struct configfs_subsystem *subsys, |
1083 | struct config_item *target) | 1102 | struct config_item *target) |
1084 | { | 1103 | { |
1085 | int ret; | 1104 | int ret; |
1086 | struct configfs_dirent *p, *root_sd, *subsys_sd = NULL; | 1105 | struct configfs_dirent *subsys_sd; |
1087 | struct config_item *s_item = &subsys->su_group.cg_item; | 1106 | struct config_item *s_item = &subsys->su_group.cg_item; |
1088 | struct dentry *root; | 1107 | struct dentry *root; |
1089 | 1108 | ||
@@ -1102,17 +1121,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys, | |||
1102 | */ | 1121 | */ |
1103 | mutex_lock(&d_inode(root)->i_mutex); | 1122 | mutex_lock(&d_inode(root)->i_mutex); |
1104 | 1123 | ||
1105 | root_sd = root->d_fsdata; | 1124 | subsys_sd = configfs_find_subsys_dentry(root->d_fsdata, s_item); |
1106 | |||
1107 | list_for_each_entry(p, &root_sd->s_children, s_sibling) { | ||
1108 | if (p->s_type & CONFIGFS_DIR) { | ||
1109 | if (p->s_element == s_item) { | ||
1110 | subsys_sd = p; | ||
1111 | break; | ||
1112 | } | ||
1113 | } | ||
1114 | } | ||
1115 | |||
1116 | if (!subsys_sd) { | 1125 | if (!subsys_sd) { |
1117 | ret = -ENOENT; | 1126 | ret = -ENOENT; |
1118 | goto out_unlock_fs; | 1127 | goto out_unlock_fs; |