... and don't bother with debugfs_fsdata for those. Life's simpler that way... Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx> --- fs/debugfs/inode.c | 21 +++++---------------- fs/debugfs/internal.h | 19 +++++++++---------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 5d423bd92f93..2f5afd7b1b94 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -246,8 +246,8 @@ static void debugfs_release_dentry(struct dentry *dentry) if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT) return; - /* check it wasn't a dir (no fsdata) or automount (no real_fops) */ - if (fsd && (fsd->real_fops || fsd->short_fops)) { + /* check it wasn't a dir or automount (no fsdata) */ + if (fsd) { WARN_ON(!list_empty(&fsd->cancellations)); mutex_destroy(&fsd->cancellations_mtx); } @@ -257,9 +257,9 @@ static void debugfs_release_dentry(struct dentry *dentry) static struct vfsmount *debugfs_automount(struct path *path) { - struct debugfs_fsdata *fsd = path->dentry->d_fsdata; + struct inode *inode = path->dentry->d_inode; - return fsd->automount(path->dentry, d_inode(path->dentry)->i_private); + return DEBUGFS_I(inode)->automount(path->dentry, inode->i_private); } static const struct dentry_operations debugfs_dops = { @@ -642,23 +642,13 @@ struct dentry *debugfs_create_automount(const char *name, void *data) { struct dentry *dentry = start_creating(name, parent); - struct debugfs_fsdata *fsd; struct inode *inode; if (IS_ERR(dentry)) return dentry; - fsd = kzalloc(sizeof(*fsd), GFP_KERNEL); - if (!fsd) { - failed_creating(dentry); - return ERR_PTR(-ENOMEM); - } - - fsd->automount = f; - if (!(debugfs_allow & DEBUGFS_ALLOW_API)) { failed_creating(dentry); - kfree(fsd); return ERR_PTR(-EPERM); } @@ -666,14 +656,13 @@ struct dentry *debugfs_create_automount(const char *name, if (unlikely(!inode)) { pr_err("out of free dentries, can not create automount '%s'\n", name); - kfree(fsd); return failed_creating(dentry); } make_empty_dir_inode(inode); inode->i_flags |= S_AUTOMOUNT; inode->i_private = data; - dentry->d_fsdata = fsd; + DEBUGFS_I(inode)->automount = f; /* directory inodes start off with i_nlink == 2 (for "." entry) */ inc_nlink(inode); d_instantiate(dentry, inode); diff --git a/fs/debugfs/internal.h b/fs/debugfs/internal.h index 5cb940b0b8f6..a644e44a0ee4 100644 --- a/fs/debugfs/internal.h +++ b/fs/debugfs/internal.h @@ -13,6 +13,9 @@ struct file_operations; struct debugfs_inode_info { struct inode vfs_inode; + union { + debugfs_automount_t automount; + }; }; static inline struct debugfs_inode_info *DEBUGFS_I(struct inode *inode) @@ -29,17 +32,13 @@ extern const struct file_operations debugfs_full_short_proxy_file_operations; struct debugfs_fsdata { const struct file_operations *real_fops; const struct debugfs_short_fops *short_fops; - union { - /* automount_fn is used when real_fops is NULL */ - debugfs_automount_t automount; - struct { - refcount_t active_users; - struct completion active_users_drained; + struct { + refcount_t active_users; + struct completion active_users_drained; - /* protect cancellations */ - struct mutex cancellations_mtx; - struct list_head cancellations; - }; + /* protect cancellations */ + struct mutex cancellations_mtx; + struct list_head cancellations; }; }; -- 2.39.5