ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ceph: properly handle statfs on multifs setups
@ 2021-10-05 15:30 Jeff Layton
  0 siblings, 0 replies; only message in thread
From: Jeff Layton @ 2021-10-05 15:30 UTC (permalink / raw)
  To: ceph-devel; +Cc: idryomov, Sachin Prabhu

ceph_statfs currently stuffs the cluster fsid into the f_fsid field.
This was fine when we only had a single filesystem per cluster, but now
that we have multiples we need to use something that will vary between
them.

Change ceph_statfs to mix the current 64 bit hashed fsid down to 32 bits
using a trivial xor hash. Shift that to be the upper 32 bits in the
64 bit field and then fold in the fs_cluster_id from the mon client.

That should give us a value that is guaranteed to be unique between
filesystems within a cluster, and should minimize the chance of
collisions between mounts of different clusters.

URL: https://tracker.ceph.com/issues/52812
Reported-by: Sachin Prabhu <sprabhu@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/super.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 42c502eee80a..b6d2e20e857b 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -104,6 +104,12 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 	       le64_to_cpu(*((__le64 *)&monc->monmap->fsid + 1));
 	mutex_unlock(&monc->mutex);
 
+	/* mix the fsid down to 32 bits */
+	fsid = *(u32 *)&fsid ^ *((u32 *)&fsid + 1);
+
+	/* fold the fs_cluster_id into the upper bits */
+	fsid |= ((u64)monc->fs_cluster_id << 32);
+
 	buf->f_fsid = u64_to_fsid(fsid);
 
 	return 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-05 15:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 15:30 [PATCH] ceph: properly handle statfs on multifs setups Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).