Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] xfs: publish UUID in struct super_block
@ 2017-04-27  7:58 Amir Goldstein
  2017-04-27  7:59 ` Christoph Hellwig
  2017-04-27 19:31 ` Darrick J. Wong
  0 siblings, 2 replies; 18+ messages in thread
From: Amir Goldstein @ 2017-04-27  7:58 UTC (permalink / raw)
  To: Darrick J . Wong
  Cc: Christoph Hellwig, Miklos Szeredi, Vivek Goyal, Al Viro,
	linux-xfs, linux-unionfs, linux-fsdevel

Unless mounted with nouuid, copy the uuid of the filesystem to
struct super block s_uuid field, as several other filesystems do.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/xfs/xfs_mount.c | 3 +++
 1 file changed, 3 insertions(+)

Darrick,

The VFS sb->s_uuid field is needed for a new overlay feature
'constant inode numbers' [1].

We store the filesystem uuid along with encoded file handles, so that
we can verify later that we are encoding file handles from the same
filesystem from which the handles were encoded.

At least the following filesystems set sb->s_uuid: ext4, f2fs, jfs, ocfs2.

Specifically, btrfs does not set sb->s_uuid, I think because it has many
uuid's per super_block struct.

I see no obvious reason for xfs not to set sb->s_uuid so here goes.

I made a choice not to set sb->s_uuid in case xfs was mounted with nouuid,
to maintain a self inflicted rule that sb->s_uuid is unique in a system
for an xfs super_block.  This is an arbitrary decision so others may not
agree with it.

My reasoning in the context of verifying file handles is this -
If a file handle was exported from one copy of an xfs filesystem, I rather
it was not decoded from another copy of the filesystem (i.e. LVM snapshot),
at least not while both copies are mounted on the same system.

I tested the patch is working correctly with and without nouuid with my
overlayfs constant inode tests. I do have xfstests that check overlay
constant inodes, but they are of little use to you without the overlayfs
patches.

Here is what it looks like when running constant inode verification test
for overlayfs above xfs mounted with nouuid:
~/unionmount-testsuite# ./run --ov=0 --samefs hard-link
...
XFS (vdf): Ending clean mount
overlayfs: lower fs needs to report s_uuid.
 ./run --link /mnt/a/foo100 /mnt/a/no_foo100
sh (2748): drop_caches: 3
overlayfs: lower fs needs to report s_uuid.
/mnt/a/no_foo100: inode number wrong (got 442, want 137)

The same test passes with overlayfs over ext4 and with overlay over xfs
mounted without nouuid (and with this patch applied naturally).

I'd appreciate if you could queue this simple patch for v4.12.

Thanks,
Amir.

[1] https://marc.info/?l=linux-unionfs&m=149324252301397&w=2

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 450bde6..29e45a0 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -100,6 +100,9 @@ xfs_uuid_mount(
 	xfs_uuid_table[hole] = *uuid;
 	mutex_unlock(&xfs_uuid_table_mutex);
 
+	/* Publish UUID in struct super_block */
+	BUILD_BUG_ON(sizeof(mp->m_super->s_uuid) != sizeof(uuid_t));
+	memcpy(&mp->m_super->s_uuid, uuid, sizeof(uuid_t));
 	return 0;
 
  out_duplicate:
-- 
2.7.4


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

end of thread, other threads:[~2017-04-28  6:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-27  7:58 [PATCH] xfs: publish UUID in struct super_block Amir Goldstein
2017-04-27  7:59 ` Christoph Hellwig
2017-04-27  8:01   ` Amir Goldstein
2017-04-27  8:36     ` Amir Goldstein
2017-04-27 12:57   ` David Howells
2017-04-27 13:08     ` Amir Goldstein
2017-04-27 13:22       ` David Howells
2017-04-27 13:50         ` Eric Sandeen
2017-04-27 13:55           ` Amir Goldstein
2017-04-27 14:00           ` David Howells
2017-04-27 14:08             ` Amir Goldstein
2017-04-27 19:31 ` Darrick J. Wong
2017-04-27 20:30   ` Eric Sandeen
2017-04-28  5:49     ` Andy Whitcroft
2017-04-28  5:56       ` Darrick J. Wong
2017-04-28  6:18         ` Amir Goldstein
2017-04-28  6:24           ` Miklos Szeredi
2017-04-28  6:11   ` Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox