aboutsummaryrefslogtreecommitdiffstats
path: root/fs/configfs/dir.c
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2015-10-23 18:57:10 +0200
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2015-10-23 18:57:10 +0200
commitde04df3a2555ac04d19c3ad6528503d5bf4ab0e7 (patch)
treefb3c0b36662106c463ad73b2ed5f1c48d325484a /fs/configfs/dir.c
parent25fbe5ca4d0f37170451b682bd150a70f944aca0 (diff)
downloadkernel_samsung_smdk4412-de04df3a2555ac04d19c3ad6528503d5bf4ab0e7.zip
kernel_samsung_smdk4412-de04df3a2555ac04d19c3ad6528503d5bf4ab0e7.tar.gz
kernel_samsung_smdk4412-de04df3a2555ac04d19c3ad6528503d5bf4ab0e7.tar.bz2
getting newer filesystem code working
Diffstat (limited to 'fs/configfs/dir.c')
-rw-r--r--fs/configfs/dir.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 9a37a9b..5ef72c8 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -56,10 +56,19 @@ static void configfs_d_iput(struct dentry * dentry,
struct configfs_dirent *sd = dentry->d_fsdata;
if (sd) {
- BUG_ON(sd->s_dentry != dentry);
/* Coordinate with configfs_readdir */
spin_lock(&configfs_dirent_lock);
- sd->s_dentry = NULL;
+ /* Coordinate with configfs_attach_attr where will increase
+ * sd->s_count and update sd->s_dentry to new allocated one.
+ * Only set sd->dentry to null when this dentry is the only
+ * sd owner.
+ * If not do so, configfs_d_iput may run just after
+ * configfs_attach_attr and set sd->s_dentry to null
+ * even it's still in use.
+ */
+ if (atomic_read(&sd->s_count) <= 2)
+ sd->s_dentry = NULL;
+
spin_unlock(&configfs_dirent_lock);
configfs_put(sd);
}
@@ -436,8 +445,11 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
struct configfs_attribute * attr = sd->s_element;
int error;
+ spin_lock(&configfs_dirent_lock);
dentry->d_fsdata = configfs_get(sd);
sd->s_dentry = dentry;
+ spin_unlock(&configfs_dirent_lock);
+
error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,
configfs_init_file);
if (error) {