]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: tracepoints: get correct superblock from dentry in event btrfs_sync_file()
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Fri, 13 Mar 2026 18:11:39 +0000 (14:11 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2026 19:11:12 +0000 (20:11 +0100)
If overlay is used on top of btrfs, dentry->d_sb translates to overlay's
super block and fsid assignment will lead to a crash.

Use file_inode(file)->i_sb to always get btrfs_sb.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
include/trace/events/btrfs.h

index 125bdc166bfed7aa8d447cd65597929873068aa2..0864700f76e0a14c5ae8e73a7c3c4852ddb4909c 100644 (file)
@@ -769,12 +769,15 @@ TRACE_EVENT(btrfs_sync_file,
        ),
 
        TP_fast_assign(
-               const struct dentry *dentry = file->f_path.dentry;
-               const struct inode *inode = d_inode(dentry);
+               struct dentry *dentry = file_dentry(file);
+               struct inode *inode = file_inode(file);
+               struct dentry *parent = dget_parent(dentry);
+               struct inode *parent_inode = d_inode(parent);
 
-               TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
+               dput(parent);
+               TP_fast_assign_fsid(btrfs_sb(inode->i_sb));
                __entry->ino            = btrfs_ino(BTRFS_I(inode));
-               __entry->parent         = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
+               __entry->parent         = btrfs_ino(BTRFS_I(parent_inode));
                __entry->datasync       = datasync;
                __entry->root_objectid  = btrfs_root_id(BTRFS_I(inode)->root);
        ),