]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add new routine to get fscid from a ceph_mount 24747/head
authorJeff Layton <jlayton@redhat.com>
Tue, 23 Oct 2018 18:20:25 +0000 (14:20 -0400)
committerJeff Layton <jlayton@kernel.org>
Thu, 25 Oct 2018 18:28:48 +0000 (14:28 -0400)
Ceph recently gained the ability to create alternate named filesystems
within a cluster. We want to allow nfs-ganesha to export them, but it
currently generates filehandles using a inode number+snapid tuple, and
that will not be unique across multiple filesystems.

Add a new field to hold the fscid in the Client, as that is generated
on a per-filesystem basis via monotonic counter. When we mount, fetch
the fscid and store it in that field. Add a new Client accessor, and a
libcephfs function that returns that value.

Tracker: http://tracker.ceph.com/issues/36585
Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 86cde92945a2b78265c8de34b15d41ead1ff46a9..c2bad5efbccfbba4fb326af1ebd113e495653f77 100644 (file)
@@ -243,7 +243,8 @@ Client::Client(Messenger *m, MonClient *mc, Objecter *objecter_)
     interrupt_finisher(m->cct),
     remount_finisher(m->cct),
     objecter_finisher(m->cct),
-    m_command_hook(this)
+    m_command_hook(this),
+    fscid(0)
 {
   _reset_faked_inos();
 
@@ -5741,13 +5742,13 @@ int Client::subscribe_mdsmap(const std::string &fs_name)
     r = fetch_fsmap(true);
     if (r < 0)
       return r;
-    fs_cluster_id_t cid = fsmap_user->get_fs_cid(resolved_fs_name);
-    if (cid == FS_CLUSTER_ID_NONE) {
+    fscid = fsmap_user->get_fs_cid(resolved_fs_name);
+    if (fscid == FS_CLUSTER_ID_NONE) {
       return -ENOENT;
     }
 
     std::ostringstream oss;
-    oss << want << "." << cid;
+    oss << want << "." << fscid;
     want = oss.str();
   }
   ldout(cct, 10) << "Subscribing to map '" << want << "'" << dendl;
index 80836753ac632d1d048a7491dcaef7eddcee8e2b..82890a811ec33ecdde80d9afcd2b4ebc74b6382a 100644 (file)
@@ -303,6 +303,10 @@ public:
                    const std::string& fs_name);
   void finish_reclaim();
 
+  fs_cluster_id_t get_fs_cid() {
+    return fscid;
+  }
+
   int mds_command(
     const std::string &mds_spec,
     const std::vector<std::string>& cmd,
@@ -1238,6 +1242,9 @@ private:
 
   bool _use_faked_inos;
 
+  // Cluster fsid
+  fs_cluster_id_t fscid;
+
   // file handles, etc.
   interval_set<int> free_fd_set;  // unused fds
   ceph::unordered_map<int, Fh*> fd_map;
index 31e319509737f65cd05e427d1781a67dbf115684..dbb84a1e2d2cd50c775f7aa21a4fe3239028ab63 100644 (file)
@@ -278,6 +278,15 @@ int ceph_select_filesystem(struct ceph_mount_info *cmount, const char *fs_name);
  */
 int ceph_mount(struct ceph_mount_info *cmount, const char *root);
 
+/**
+ * Return cluster ID for a mounted ceph filesystem
+ *
+ * Every ceph filesystem has a filesystem ID associated with it. This
+ * function returns that value. If the ceph_mount_info does not refer to a
+ * mounted filesystem, this returns a negative error code.
+ */
+int64_t ceph_get_fs_cid(struct ceph_mount_info *cmount);
+
 /**
  * Execute a management command remotely on an MDS.
  *
index 0d8ad43f9f5817991904695ec1b334c34f698531..38f9fc7ddd516d887fb8f17e068253f8b93e0579 100644 (file)
@@ -538,6 +538,13 @@ extern "C" struct UserPerm *ceph_mount_perms(struct ceph_mount_info *cmount)
   return &cmount->default_perms;
 }
 
+extern "C" int64_t ceph_get_fs_cid(struct ceph_mount_info *cmount)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->get_fs_cid();
+}
+
 extern "C" int ceph_mount_perms_set(struct ceph_mount_info *cmount,
                                    struct UserPerm *perms)
 {