Some filesystems on persistent storage backend use a digest of the filesystem's persistent uuid as the value for f_fsid returned by statfs(2). xfs, as many other filesystem provide the non-persistent block device number as the value of f_fsid. Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID for identifying objects using file_handle and f_fsid in events. The xfs specific ioctl XFS_IOC_PATH_TO_FSHANDLE similarly attaches an fsid to exported file handles, but it is not the same fsid exported via statfs(2) - it is a persistent fsid based on the filesystem's uuid. Use the same persistent value for f_fsid, so object identifiers in fanotify events will describe the objects more uniquely. Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> --- Guys, This change would be useful for fanotify users. Do you see any problems with that minor change of uapi? The way I see it, now f_fsid of an xfs filesystem can change on reboots. With this change, it will change once more and never more. I did not find any kernel internal user other than fanotify and as for userland expectations, there should not be much expectations from the value of f_fsid as it is persistent for some filesystems and bdev number for others - there is no standard. Thanks, Amir. fs/xfs/xfs_super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index e5e0713bebcd..37f8417b78c4 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -790,7 +790,7 @@ xfs_fs_statfs( struct xfs_mount *mp = XFS_M(dentry->d_sb); xfs_sb_t *sbp = &mp->m_sb; struct xfs_inode *ip = XFS_I(d_inode(dentry)); - uint64_t fakeinos, id; + uint64_t fakeinos; uint64_t icount; uint64_t ifree; uint64_t fdblocks; @@ -800,8 +800,8 @@ xfs_fs_statfs( statp->f_type = XFS_SUPER_MAGIC; statp->f_namelen = MAXNAMELEN - 1; - id = huge_encode_dev(mp->m_ddev_targp->bt_dev); - statp->f_fsid = u64_to_fsid(id); + statp->f_fsid.val[0] = mp->m_fixedfsid[0]; + statp->f_fsid.val[1] = mp->m_fixedfsid[1]; icount = percpu_counter_sum(&mp->m_icount); ifree = percpu_counter_sum(&mp->m_ifree); -- 2.25.1