Skip to content

Commit 0a0fbbf

Browse files
author
Desnes Nunes
committed
debugfs: move ->automount into debugfs_inode_info
JIRA: https://issues.redhat.com/browse/RHEL-78931 commit bacaaf8 Author: Al Viro <viro@zeniv.linux.org.uk> Date: Sun, 12 Jan 2025 08:06:46 +0000 ... and don't bother with debugfs_fsdata for those. Life's simpler that way... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: Christian Brauner <brauner@kernel.org> Link: https://lore.kernel.org/r/20250112080705.141166-2-viro@zeniv.linux.org.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 112d0de commit 0a0fbbf

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

fs/debugfs/inode.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ static void debugfs_release_dentry(struct dentry *dentry)
246246
if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
247247
return;
248248

249-
/* check it wasn't a dir (no fsdata) or automount (no real_fops) */
250-
if (fsd && (fsd->real_fops || fsd->short_fops)) {
249+
/* check it wasn't a dir or automount (no fsdata) */
250+
if (fsd) {
251251
WARN_ON(!list_empty(&fsd->cancellations));
252252
mutex_destroy(&fsd->cancellations_mtx);
253253
}
@@ -257,9 +257,9 @@ static void debugfs_release_dentry(struct dentry *dentry)
257257

258258
static struct vfsmount *debugfs_automount(struct path *path)
259259
{
260-
struct debugfs_fsdata *fsd = path->dentry->d_fsdata;
260+
struct inode *inode = path->dentry->d_inode;
261261

262-
return fsd->automount(path->dentry, d_inode(path->dentry)->i_private);
262+
return DEBUGFS_I(inode)->automount(path->dentry, inode->i_private);
263263
}
264264

265265
static const struct dentry_operations debugfs_dops = {
@@ -642,38 +642,27 @@ struct dentry *debugfs_create_automount(const char *name,
642642
void *data)
643643
{
644644
struct dentry *dentry = start_creating(name, parent);
645-
struct debugfs_fsdata *fsd;
646645
struct inode *inode;
647646

648647
if (IS_ERR(dentry))
649648
return dentry;
650649

651-
fsd = kzalloc(sizeof(*fsd), GFP_KERNEL);
652-
if (!fsd) {
653-
failed_creating(dentry);
654-
return ERR_PTR(-ENOMEM);
655-
}
656-
657-
fsd->automount = f;
658-
659650
if (!(debugfs_allow & DEBUGFS_ALLOW_API)) {
660651
failed_creating(dentry);
661-
kfree(fsd);
662652
return ERR_PTR(-EPERM);
663653
}
664654

665655
inode = debugfs_get_inode(dentry->d_sb);
666656
if (unlikely(!inode)) {
667657
pr_err("out of free dentries, can not create automount '%s'\n",
668658
name);
669-
kfree(fsd);
670659
return failed_creating(dentry);
671660
}
672661

673662
make_empty_dir_inode(inode);
674663
inode->i_flags |= S_AUTOMOUNT;
675664
inode->i_private = data;
676-
dentry->d_fsdata = fsd;
665+
DEBUGFS_I(inode)->automount = f;
677666
/* directory inodes start off with i_nlink == 2 (for "." entry) */
678667
inc_nlink(inode);
679668
d_instantiate(dentry, inode);

fs/debugfs/internal.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ struct file_operations;
1313

1414
struct debugfs_inode_info {
1515
struct inode vfs_inode;
16+
union {
17+
debugfs_automount_t automount;
18+
};
1619
};
1720

1821
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;
2932
struct debugfs_fsdata {
3033
const struct file_operations *real_fops;
3134
const struct debugfs_short_fops *short_fops;
32-
union {
33-
/* automount_fn is used when real_fops is NULL */
34-
debugfs_automount_t automount;
35-
struct {
36-
refcount_t active_users;
37-
struct completion active_users_drained;
35+
struct {
36+
refcount_t active_users;
37+
struct completion active_users_drained;
3838

39-
/* protect cancellations */
40-
struct mutex cancellations_mtx;
41-
struct list_head cancellations;
42-
};
39+
/* protect cancellations */
40+
struct mutex cancellations_mtx;
41+
struct list_head cancellations;
4342
};
4443
};
4544

0 commit comments

Comments
 (0)