summaryrefslogtreecommitdiffstats
path: root/fs/configfs
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2015-12-11 10:06:10 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2015-12-20 21:03:59 -0500
commit9fb434e7544b5013d1c2d8a2306f8b562cb52d80 (patch)
treee7ac8f098491f1d1b9c30239176169882946147d /fs/configfs
parent9a9e3415edd567813d52c8de402042b9720c54f5 (diff)
fs: configfs: Factor out configfs_do_depend_item()
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')
-rw-r--r--fs/configfs/dir.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index d390245965b1..43decd26851c 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1054,6 +1054,31 @@ out:
1054 return ret; 1054 return ret;
1055} 1055}
1056 1056
1057static int configfs_do_depend_item(struct dentry *subsys_dentry,
1058 struct config_item *target)
1059{
1060 struct configfs_dirent *p;
1061 int ret;
1062
1063 spin_lock(&configfs_dirent_lock);
1064 /* Scan the tree, return 0 if found */
1065 ret = configfs_depend_prep(subsys_dentry, target);
1066 if (ret)
1067 goto out_unlock_dirent_lock;
1068
1069 /*
1070 * We are sure that the item is not about to be removed by rmdir(), and
1071 * not in the middle of attachment by mkdir().
1072 */
1073 p = target->ci_dentry->d_fsdata;
1074 p->s_dependent_count += 1;
1075
1076out_unlock_dirent_lock:
1077 spin_unlock(&configfs_dirent_lock);
1078
1079 return ret;
1080}
1081
1057int configfs_depend_item(struct configfs_subsystem *subsys, 1082int configfs_depend_item(struct configfs_subsystem *subsys,
1058 struct config_item *target) 1083 struct config_item *target)
1059{ 1084{
@@ -1094,22 +1119,8 @@ int configfs_depend_item(struct configfs_subsystem *subsys,
1094 } 1119 }
1095 1120
1096 /* Ok, now we can trust subsys/s_item */ 1121 /* Ok, now we can trust subsys/s_item */
1122 ret = configfs_do_depend_item(subsys_sd->s_dentry, target);
1097 1123
1098 spin_lock(&configfs_dirent_lock);
1099 /* Scan the tree, return 0 if found */
1100 ret = configfs_depend_prep(subsys_sd->s_dentry, target);
1101 if (ret)
1102 goto out_unlock_dirent_lock;
1103
1104 /*
1105 * We are sure that the item is not about to be removed by rmdir(), and
1106 * not in the middle of attachment by mkdir().
1107 */
1108 p = target->ci_dentry->d_fsdata;
1109 p->s_dependent_count += 1;
1110
1111out_unlock_dirent_lock:
1112 spin_unlock(&configfs_dirent_lock);
1113out_unlock_fs: 1124out_unlock_fs:
1114 mutex_unlock(&d_inode(root)->i_mutex); 1125 mutex_unlock(&d_inode(root)->i_mutex);
1115 1126