]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix root inode number for fuse 7976/head
authorYan, Zheng <zyan@redhat.com>
Tue, 8 Mar 2016 14:46:31 +0000 (22:46 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 8 Mar 2016 23:57:40 +0000 (07:57 +0800)
fuse assigns a fix inode number (FUSE_ROOT_ID) for root inode
(FUSE_ROOT_ID is usually equal to MDS_INO_ROOT). But in the mount
into sub-directory case, FUSE_ROOT_ID is not equal to inode number
of the real mount root. This mismatch can confuse getattr and
fuse_lowlevel_notify_foo() functions.

Fixes: #15008
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc
src/client/fuse_ll.cc

index 31f31f86e99d3ee2589ecb64514b894e83f1dbd5..5b247671098b94a66cc823f20b0a2bcca3186c30 100644 (file)
@@ -362,7 +362,10 @@ void Client::tear_down_cache()
 
 inodeno_t Client::get_root_ino()
 {
-  return root->ino;
+  if (use_faked_inos())
+    return root->faked_ino;
+  else
+    return root->ino;
 }
 
 Inode *Client::get_root()
index 793cc4d1ab990e551ade3537f3f933cf0c399722..42c9304fcd1a6efd9bb58eaa72d5d7d3fc97281b 100644 (file)
@@ -1045,6 +1045,9 @@ int CephFuse::Handle::loop()
 
 uint64_t CephFuse::Handle::fino_snap(uint64_t fino)
 {
+  if (fino == FUSE_ROOT_ID)
+    return CEPH_NOSNAP;
+
   if (client->use_faked_inos()) {
     vinodeno_t vino  = client->map_faked_ino(fino);
     return vino.snapid;
@@ -1058,11 +1061,12 @@ uint64_t CephFuse::Handle::fino_snap(uint64_t fino)
 
 Inode * CephFuse::Handle::iget(fuse_ino_t fino)
 {
+  if (fino == FUSE_ROOT_ID)
+    return client->get_root();
+
   if (client->use_faked_inos()) {
     return client->ll_get_inode((ino_t)fino);
   } else {
-    if (fino == 1)
-      fino = inodeno_t(client->get_root_ino());
     vinodeno_t vino(FINO_INO(fino), fino_snap(fino));
     return client->ll_get_inode(vino);
   }
@@ -1077,8 +1081,14 @@ uint64_t CephFuse::Handle::make_fake_ino(inodeno_t ino, snapid_t snapid)
 {
   if (client->use_faked_inos()) {
     // already faked by libcephfs
+    if (ino == client->get_root_ino())
+      return FUSE_ROOT_ID;
+
     return ino;
   } else {
+    if (snapid == CEPH_NOSNAP && ino == client->get_root_ino())
+      return FUSE_ROOT_ID;
+
     Mutex::Locker l(stag_lock);
     uint64_t stag;
     if (snap_stag_map.count(snapid) == 0) {