diff options
Diffstat (limited to 'arch/s390/hypfs')
-rw-r--r-- | arch/s390/hypfs/inode.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index ad4ca75c0f04..5245717295b8 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
@@ -60,17 +60,28 @@ static void hypfs_add_dentry(struct dentry *dentry) | |||
60 | hypfs_last_dentry = dentry; | 60 | hypfs_last_dentry = dentry; |
61 | } | 61 | } |
62 | 62 | ||
63 | static inline int hypfs_positive(struct dentry *dentry) | ||
64 | { | ||
65 | return dentry->d_inode && !d_unhashed(dentry); | ||
66 | } | ||
67 | |||
63 | static void hypfs_remove(struct dentry *dentry) | 68 | static void hypfs_remove(struct dentry *dentry) |
64 | { | 69 | { |
65 | struct dentry *parent; | 70 | struct dentry *parent; |
66 | 71 | ||
67 | parent = dentry->d_parent; | 72 | parent = dentry->d_parent; |
68 | if (S_ISDIR(dentry->d_inode->i_mode)) | 73 | if (!parent || !parent->d_inode) |
69 | simple_rmdir(parent->d_inode, dentry); | 74 | return; |
70 | else | 75 | mutex_lock(&parent->d_inode->i_mutex); |
71 | simple_unlink(parent->d_inode, dentry); | 76 | if (hypfs_positive(dentry)) { |
77 | if (S_ISDIR(dentry->d_inode->i_mode)) | ||
78 | simple_rmdir(parent->d_inode, dentry); | ||
79 | else | ||
80 | simple_unlink(parent->d_inode, dentry); | ||
81 | } | ||
72 | d_delete(dentry); | 82 | d_delete(dentry); |
73 | dput(dentry); | 83 | dput(dentry); |
84 | mutex_unlock(&parent->d_inode->i_mutex); | ||
74 | } | 85 | } |
75 | 86 | ||
76 | static void hypfs_delete_tree(struct dentry *root) | 87 | static void hypfs_delete_tree(struct dentry *root) |
@@ -315,6 +326,7 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent) | |||
315 | } | 326 | } |
316 | hypfs_update_update(sb); | 327 | hypfs_update_update(sb); |
317 | sb->s_root = root_dentry; | 328 | sb->s_root = root_dentry; |
329 | printk(KERN_INFO "hypfs: Hypervisor filesystem mounted\n"); | ||
318 | return 0; | 330 | return 0; |
319 | 331 | ||
320 | err_tree: | 332 | err_tree: |
@@ -356,13 +368,17 @@ static struct dentry *hypfs_create_file(struct super_block *sb, | |||
356 | qname.name = name; | 368 | qname.name = name; |
357 | qname.len = strlen(name); | 369 | qname.len = strlen(name); |
358 | qname.hash = full_name_hash(name, qname.len); | 370 | qname.hash = full_name_hash(name, qname.len); |
371 | mutex_lock(&parent->d_inode->i_mutex); | ||
359 | dentry = lookup_one_len(name, parent, strlen(name)); | 372 | dentry = lookup_one_len(name, parent, strlen(name)); |
360 | if (IS_ERR(dentry)) | 373 | if (IS_ERR(dentry)) { |
361 | return ERR_PTR(-ENOMEM); | 374 | dentry = ERR_PTR(-ENOMEM); |
375 | goto fail; | ||
376 | } | ||
362 | inode = hypfs_make_inode(sb, mode); | 377 | inode = hypfs_make_inode(sb, mode); |
363 | if (!inode) { | 378 | if (!inode) { |
364 | dput(dentry); | 379 | dput(dentry); |
365 | return ERR_PTR(-ENOMEM); | 380 | dentry = ERR_PTR(-ENOMEM); |
381 | goto fail; | ||
366 | } | 382 | } |
367 | if (mode & S_IFREG) { | 383 | if (mode & S_IFREG) { |
368 | inode->i_fop = &hypfs_file_ops; | 384 | inode->i_fop = &hypfs_file_ops; |
@@ -379,6 +395,8 @@ static struct dentry *hypfs_create_file(struct super_block *sb, | |||
379 | inode->i_private = data; | 395 | inode->i_private = data; |
380 | d_instantiate(dentry, inode); | 396 | d_instantiate(dentry, inode); |
381 | dget(dentry); | 397 | dget(dentry); |
398 | fail: | ||
399 | mutex_unlock(&parent->d_inode->i_mutex); | ||
382 | return dentry; | 400 | return dentry; |
383 | } | 401 | } |
384 | 402 | ||
@@ -391,7 +409,6 @@ struct dentry *hypfs_mkdir(struct super_block *sb, struct dentry *parent, | |||
391 | if (IS_ERR(dentry)) | 409 | if (IS_ERR(dentry)) |
392 | return dentry; | 410 | return dentry; |
393 | hypfs_add_dentry(dentry); | 411 | hypfs_add_dentry(dentry); |
394 | parent->d_inode->i_nlink++; | ||
395 | return dentry; | 412 | return dentry; |
396 | } | 413 | } |
397 | 414 | ||