ceph: fix debugfs entry, simplify fsid checks

We may first learn our fsid from any of the mon, osd, or mds maps
(whichever the monitor sends first).  Consolidate checks in a single
helper.  Initialize the client debugfs entry then, since we need the
fsid (and global_id) for the directory name.

Also remove dead mount code.

Signed-off-by: Sage Weil <sage@newdream.net>
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index df05617..3df6d4a 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -19,6 +19,7 @@
 #include "decode.h"
 #include "super.h"
 #include "mon_client.h"
+#include "auth.h"
 
 /*
  * Ceph superblock operations
@@ -510,14 +511,11 @@
 
 	client->sb = NULL;
 	client->mount_state = CEPH_MOUNT_MOUNTING;
-	client->whoami = -1;
 	client->mount_args = args;
 
 	client->msgr = NULL;
 
 	client->mount_err = 0;
-	client->signed_ticket = NULL;
-	client->signed_ticket_len = 0;
 
 	err = bdi_init(&client->backing_dev_info);
 	if (err < 0)
@@ -582,8 +580,6 @@
 	ceph_monc_stop(&client->monc);
 	ceph_osdc_stop(&client->osdc);
 
-	kfree(client->signed_ticket);
-
 	ceph_debugfs_client_cleanup(client);
 	destroy_workqueue(client->wb_wq);
 	destroy_workqueue(client->pg_inv_wq);
@@ -600,6 +596,32 @@
 }
 
 /*
+ * Initially learn our fsid, or verify an fsid matches.
+ */
+int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid)
+{
+	if (client->have_fsid) {
+		if (ceph_fsid_compare(&client->fsid, fsid)) {
+			print_hex_dump(KERN_ERR, "this fsid: ",
+				       DUMP_PREFIX_NONE, 16, 1,
+				       (void *)fsid, 16, 0);
+			print_hex_dump(KERN_ERR, " old fsid: ",
+				       DUMP_PREFIX_NONE, 16, 1,
+				       (void *)&client->fsid, 16, 0);
+			pr_err("fsid mismatch\n");
+			return -1;
+		}
+	} else {
+		pr_info("client%lld fsid " FSID_FORMAT "\n",
+			client->monc.auth->global_id, PR_FSID(fsid));
+		memcpy(&client->fsid, fsid, sizeof(*fsid));
+		ceph_debugfs_client_init(client);
+		client->have_fsid = true;
+	}
+	return 0;
+}
+
+/*
  * true if we have the mon map (and have thus joined the cluster)
  */
 static int have_mon_map(struct ceph_client *client)