]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
blk-mq-debugfs: use debugfs_get_aux()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 2 Jul 2025 21:28:18 +0000 (22:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2025 11:30:29 +0000 (13:30 +0200)
instead of manually stashing the data pointer into parent directory inode's
->i_private, just pass it to debugfs_create_file_aux() so that it can
be extracted without that insane chasing through ->d_parent.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250702212818.GJ3406663@ZenIV
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/blk-mq-debugfs.c

index 29b3540dd1804dd2afd40e1dd54e3d30fab9552c..7ed3e71f2fc0c33122e4ce4f34d787e260b89a8b 100644 (file)
@@ -521,7 +521,7 @@ CTX_RQ_SEQ_OPS(poll, HCTX_TYPE_POLL);
 static int blk_mq_debugfs_show(struct seq_file *m, void *v)
 {
        const struct blk_mq_debugfs_attr *attr = m->private;
-       void *data = d_inode(m->file->f_path.dentry->d_parent)->i_private;
+       void *data = debugfs_get_aux(m->file);
 
        return attr->show(data, m);
 }
@@ -531,7 +531,7 @@ static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf,
 {
        struct seq_file *m = file->private_data;
        const struct blk_mq_debugfs_attr *attr = m->private;
-       void *data = d_inode(file->f_path.dentry->d_parent)->i_private;
+       void *data = debugfs_get_aux(file);
 
        /*
         * Attributes that only implement .seq_ops are read-only and 'attr' is
@@ -546,7 +546,7 @@ static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf,
 static int blk_mq_debugfs_open(struct inode *inode, struct file *file)
 {
        const struct blk_mq_debugfs_attr *attr = inode->i_private;
-       void *data = d_inode(file->f_path.dentry->d_parent)->i_private;
+       void *data = debugfs_get_aux(file);
        struct seq_file *m;
        int ret;
 
@@ -612,11 +612,9 @@ static void debugfs_create_files(struct dentry *parent, void *data,
        if (IS_ERR_OR_NULL(parent))
                return;
 
-       d_inode(parent)->i_private = data;
-
        for (; attr->name; attr++)
-               debugfs_create_file(attr->name, attr->mode, parent,
-                                   (void *)attr, &blk_mq_debugfs_fops);
+               debugfs_create_file_aux(attr->name, attr->mode, parent,
+                                   (void *)attr, data, &blk_mq_debugfs_fops);
 }
 
 void blk_mq_debugfs_register(struct request_queue *q)