All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: use a unique and persistent value for f_fsid
@ 2021-03-22 17:11 Amir Goldstein
  2021-03-22 23:03 ` Dave Chinner
  0 siblings, 1 reply; 18+ messages in thread
From: Amir Goldstein @ 2021-03-22 17:11 UTC (permalink / raw)
  To: Darrick J . Wong
  Cc: Jan Kara, Christian Brauner, linux-xfs, linux-fsdevel, linux-api

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@gmail.com>
---

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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-03-27  9:16 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 17:11 [PATCH] xfs: use a unique and persistent value for f_fsid Amir Goldstein
2021-03-22 23:03 ` Dave Chinner
2021-03-23  4:50   ` Amir Goldstein
2021-03-23  6:35     ` Darrick J. Wong
2021-03-23  6:44       ` Amir Goldstein
2021-03-23  7:26     ` Dave Chinner
2021-03-23  9:35       ` Amir Goldstein
2021-03-24  0:54         ` Dave Chinner
2021-03-24  6:53           ` Amir Goldstein
2021-03-24  7:43             ` Christoph Hellwig
2021-03-24  9:18               ` Amir Goldstein
2021-03-25 23:03                 ` Dave Chinner
2021-03-25 22:53             ` Dave Chinner
2021-03-26  6:04               ` Amir Goldstein
2021-03-26 22:34                 ` Theodore Ts'o
2021-03-27  9:14                   ` Amir Goldstein
2021-03-26 19:15     ` J. Bruce Fields
2021-03-27  9:06       ` Amir Goldstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.