From 79e2f189c7fab0cd5781610bafee2a47b41dec9d Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 8 Mar 2016 22:46:31 +0800 Subject: [PATCH] client: fix root inode number for fuse 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 --- src/client/Client.cc | 5 ++++- src/client/fuse_ll.cc | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 31f31f86e99..5b247671098 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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() diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 793cc4d1ab9..42c9304fcd1 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -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) { -- 2.47.3