Skip to content

Commit a85b46d

Browse files
Goldwyn Rodrigueskdave
authored andcommitted
btrfs: tracepoints: get correct superblock from dentry in event btrfs_sync_file()
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 <[email protected]> Signed-off-by: Goldwyn Rodrigues <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0dcabcb commit a85b46d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

include/trace/events/btrfs.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,12 +769,15 @@ TRACE_EVENT(btrfs_sync_file,
769769
),
770770

771771
TP_fast_assign(
772-
const struct dentry *dentry = file->f_path.dentry;
773-
const struct inode *inode = d_inode(dentry);
772+
struct dentry *dentry = file_dentry(file);
773+
struct inode *inode = file_inode(file);
774+
struct dentry *parent = dget_parent(dentry);
775+
struct inode *parent_inode = d_inode(parent);
774776

775-
TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
777+
dput(parent);
778+
TP_fast_assign_fsid(btrfs_sb(inode->i_sb));
776779
__entry->ino = btrfs_ino(BTRFS_I(inode));
777-
__entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
780+
__entry->parent = btrfs_ino(BTRFS_I(parent_inode));
778781
__entry->datasync = datasync;
779782
__entry->root_objectid = btrfs_root_id(BTRFS_I(inode)->root);
780783
),

0 commit comments

Comments
 (0)