aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/debugfs/inode.c')
-rw-r--r--fs/debugfs/inode.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index c9ee0dfe90b5..c1e7ffb0dab6 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -46,7 +46,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb)
46 46
47static inline int debugfs_positive(struct dentry *dentry) 47static inline int debugfs_positive(struct dentry *dentry)
48{ 48{
49 return dentry->d_inode && !d_unhashed(dentry); 49 return d_really_is_positive(dentry) && !d_unhashed(dentry);
50} 50}
51 51
52struct debugfs_mount_opts { 52struct debugfs_mount_opts {
@@ -124,7 +124,7 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
124static int debugfs_apply_options(struct super_block *sb) 124static int debugfs_apply_options(struct super_block *sb)
125{ 125{
126 struct debugfs_fs_info *fsi = sb->s_fs_info; 126 struct debugfs_fs_info *fsi = sb->s_fs_info;
127 struct inode *inode = sb->s_root->d_inode; 127 struct inode *inode = d_inode(sb->s_root);
128 struct debugfs_mount_opts *opts = &fsi->mount_opts; 128 struct debugfs_mount_opts *opts = &fsi->mount_opts;
129 129
130 inode->i_mode &= ~S_IALLUGO; 130 inode->i_mode &= ~S_IALLUGO;
@@ -188,7 +188,7 @@ static struct vfsmount *debugfs_automount(struct path *path)
188{ 188{
189 struct vfsmount *(*f)(void *); 189 struct vfsmount *(*f)(void *);
190 f = (struct vfsmount *(*)(void *))path->dentry->d_fsdata; 190 f = (struct vfsmount *(*)(void *))path->dentry->d_fsdata;
191 return f(path->dentry->d_inode->i_private); 191 return f(d_inode(path->dentry)->i_private);
192} 192}
193 193
194static const struct dentry_operations debugfs_dops = { 194static const struct dentry_operations debugfs_dops = {
@@ -270,20 +270,20 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
270 if (!parent) 270 if (!parent)
271 parent = debugfs_mount->mnt_root; 271 parent = debugfs_mount->mnt_root;
272 272
273 mutex_lock(&parent->d_inode->i_mutex); 273 mutex_lock(&d_inode(parent)->i_mutex);
274 dentry = lookup_one_len(name, parent, strlen(name)); 274 dentry = lookup_one_len(name, parent, strlen(name));
275 if (!IS_ERR(dentry) && dentry->d_inode) { 275 if (!IS_ERR(dentry) && d_really_is_positive(dentry)) {
276 dput(dentry); 276 dput(dentry);
277 dentry = ERR_PTR(-EEXIST); 277 dentry = ERR_PTR(-EEXIST);
278 } 278 }
279 if (IS_ERR(dentry)) 279 if (IS_ERR(dentry))
280 mutex_unlock(&parent->d_inode->i_mutex); 280 mutex_unlock(&d_inode(parent)->i_mutex);
281 return dentry; 281 return dentry;
282} 282}
283 283
284static struct dentry *failed_creating(struct dentry *dentry) 284static struct dentry *failed_creating(struct dentry *dentry)
285{ 285{
286 mutex_unlock(&dentry->d_parent->d_inode->i_mutex); 286 mutex_unlock(&d_inode(dentry->d_parent)->i_mutex);
287 dput(dentry); 287 dput(dentry);
288 simple_release_fs(&debugfs_mount, &debugfs_mount_count); 288 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
289 return NULL; 289 return NULL;
@@ -291,7 +291,7 @@ static struct dentry *failed_creating(struct dentry *dentry)
291 291
292static struct dentry *end_creating(struct dentry *dentry) 292static struct dentry *end_creating(struct dentry *dentry)
293{ 293{
294 mutex_unlock(&dentry->d_parent->d_inode->i_mutex); 294 mutex_unlock(&d_inode(dentry->d_parent)->i_mutex);
295 return dentry; 295 return dentry;
296} 296}
297 297
@@ -344,7 +344,7 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
344 inode->i_fop = fops ? fops : &debugfs_file_operations; 344 inode->i_fop = fops ? fops : &debugfs_file_operations;
345 inode->i_private = data; 345 inode->i_private = data;
346 d_instantiate(dentry, inode); 346 d_instantiate(dentry, inode);
347 fsnotify_create(dentry->d_parent->d_inode, dentry); 347 fsnotify_create(d_inode(dentry->d_parent), dentry);
348 return end_creating(dentry); 348 return end_creating(dentry);
349} 349}
350EXPORT_SYMBOL_GPL(debugfs_create_file); 350EXPORT_SYMBOL_GPL(debugfs_create_file);
@@ -384,7 +384,7 @@ struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
384 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops); 384 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops);
385 385
386 if (de) 386 if (de)
387 de->d_inode->i_size = file_size; 387 d_inode(de)->i_size = file_size;
388 return de; 388 return de;
389} 389}
390EXPORT_SYMBOL_GPL(debugfs_create_file_size); 390EXPORT_SYMBOL_GPL(debugfs_create_file_size);
@@ -426,8 +426,8 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
426 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 426 /* directory inodes start off with i_nlink == 2 (for "." entry) */
427 inc_nlink(inode); 427 inc_nlink(inode);
428 d_instantiate(dentry, inode); 428 d_instantiate(dentry, inode);
429 inc_nlink(dentry->d_parent->d_inode); 429 inc_nlink(d_inode(dentry->d_parent));
430 fsnotify_mkdir(dentry->d_parent->d_inode, dentry); 430 fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
431 return end_creating(dentry); 431 return end_creating(dentry);
432} 432}
433EXPORT_SYMBOL_GPL(debugfs_create_dir); 433EXPORT_SYMBOL_GPL(debugfs_create_dir);
@@ -525,9 +525,9 @@ static int __debugfs_remove(struct dentry *dentry, struct dentry *parent)
525 if (debugfs_positive(dentry)) { 525 if (debugfs_positive(dentry)) {
526 dget(dentry); 526 dget(dentry);
527 if (d_is_dir(dentry)) 527 if (d_is_dir(dentry))
528 ret = simple_rmdir(parent->d_inode, dentry); 528 ret = simple_rmdir(d_inode(parent), dentry);
529 else 529 else
530 simple_unlink(parent->d_inode, dentry); 530 simple_unlink(d_inode(parent), dentry);
531 if (!ret) 531 if (!ret)
532 d_delete(dentry); 532 d_delete(dentry);
533 dput(dentry); 533 dput(dentry);
@@ -557,12 +557,12 @@ void debugfs_remove(struct dentry *dentry)
557 return; 557 return;
558 558
559 parent = dentry->d_parent; 559 parent = dentry->d_parent;
560 if (!parent || !parent->d_inode) 560 if (!parent || d_really_is_negative(parent))
561 return; 561 return;
562 562
563 mutex_lock(&parent->d_inode->i_mutex); 563 mutex_lock(&d_inode(parent)->i_mutex);
564 ret = __debugfs_remove(dentry, parent); 564 ret = __debugfs_remove(dentry, parent);
565 mutex_unlock(&parent->d_inode->i_mutex); 565 mutex_unlock(&d_inode(parent)->i_mutex);
566 if (!ret) 566 if (!ret)
567 simple_release_fs(&debugfs_mount, &debugfs_mount_count); 567 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
568} 568}
@@ -588,12 +588,12 @@ void debugfs_remove_recursive(struct dentry *dentry)
588 return; 588 return;
589 589
590 parent = dentry->d_parent; 590 parent = dentry->d_parent;
591 if (!parent || !parent->d_inode) 591 if (!parent || d_really_is_negative(parent))
592 return; 592 return;
593 593
594 parent = dentry; 594 parent = dentry;
595 down: 595 down:
596 mutex_lock(&parent->d_inode->i_mutex); 596 mutex_lock(&d_inode(parent)->i_mutex);
597 loop: 597 loop:
598 /* 598 /*
599 * The parent->d_subdirs is protected by the d_lock. Outside that 599 * The parent->d_subdirs is protected by the d_lock. Outside that
@@ -608,7 +608,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
608 /* perhaps simple_empty(child) makes more sense */ 608 /* perhaps simple_empty(child) makes more sense */
609 if (!list_empty(&child->d_subdirs)) { 609 if (!list_empty(&child->d_subdirs)) {
610 spin_unlock(&parent->d_lock); 610 spin_unlock(&parent->d_lock);
611 mutex_unlock(&parent->d_inode->i_mutex); 611 mutex_unlock(&d_inode(parent)->i_mutex);
612 parent = child; 612 parent = child;
613 goto down; 613 goto down;
614 } 614 }
@@ -629,10 +629,10 @@ void debugfs_remove_recursive(struct dentry *dentry)
629 } 629 }
630 spin_unlock(&parent->d_lock); 630 spin_unlock(&parent->d_lock);
631 631
632 mutex_unlock(&parent->d_inode->i_mutex); 632 mutex_unlock(&d_inode(parent)->i_mutex);
633 child = parent; 633 child = parent;
634 parent = parent->d_parent; 634 parent = parent->d_parent;
635 mutex_lock(&parent->d_inode->i_mutex); 635 mutex_lock(&d_inode(parent)->i_mutex);
636 636
637 if (child != dentry) 637 if (child != dentry)
638 /* go up */ 638 /* go up */
@@ -640,7 +640,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
640 640
641 if (!__debugfs_remove(child, parent)) 641 if (!__debugfs_remove(child, parent))
642 simple_release_fs(&debugfs_mount, &debugfs_mount_count); 642 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
643 mutex_unlock(&parent->d_inode->i_mutex); 643 mutex_unlock(&d_inode(parent)->i_mutex);
644} 644}
645EXPORT_SYMBOL_GPL(debugfs_remove_recursive); 645EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
646 646
@@ -672,27 +672,27 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
672 672
673 trap = lock_rename(new_dir, old_dir); 673 trap = lock_rename(new_dir, old_dir);
674 /* Source or destination directories don't exist? */ 674 /* Source or destination directories don't exist? */
675 if (!old_dir->d_inode || !new_dir->d_inode) 675 if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))
676 goto exit; 676 goto exit;
677 /* Source does not exist, cyclic rename, or mountpoint? */ 677 /* Source does not exist, cyclic rename, or mountpoint? */
678 if (!old_dentry->d_inode || old_dentry == trap || 678 if (d_really_is_negative(old_dentry) || old_dentry == trap ||
679 d_mountpoint(old_dentry)) 679 d_mountpoint(old_dentry))
680 goto exit; 680 goto exit;
681 dentry = lookup_one_len(new_name, new_dir, strlen(new_name)); 681 dentry = lookup_one_len(new_name, new_dir, strlen(new_name));
682 /* Lookup failed, cyclic rename or target exists? */ 682 /* Lookup failed, cyclic rename or target exists? */
683 if (IS_ERR(dentry) || dentry == trap || dentry->d_inode) 683 if (IS_ERR(dentry) || dentry == trap || d_really_is_positive(dentry))
684 goto exit; 684 goto exit;
685 685
686 old_name = fsnotify_oldname_init(old_dentry->d_name.name); 686 old_name = fsnotify_oldname_init(old_dentry->d_name.name);
687 687
688 error = simple_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, 688 error = simple_rename(d_inode(old_dir), old_dentry, d_inode(new_dir),
689 dentry); 689 dentry);
690 if (error) { 690 if (error) {
691 fsnotify_oldname_free(old_name); 691 fsnotify_oldname_free(old_name);
692 goto exit; 692 goto exit;
693 } 693 }
694 d_move(old_dentry, dentry); 694 d_move(old_dentry, dentry);
695 fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name, 695 fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name,
696 d_is_dir(old_dentry), 696 d_is_dir(old_dentry),
697 NULL, old_dentry); 697 NULL, old_dentry);
698 fsnotify_oldname_free(old_name); 698 fsnotify_oldname_free(old_name);