[PATCH] ceph: properly handle statfs on multifs setups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
 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




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux