]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix incorrect snaprealm when adding caps
authorYan, Zheng <zyan@redhat.com>
Wed, 27 Dec 2017 03:57:57 +0000 (11:57 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 9 Feb 2018 10:42:29 +0000 (18:42 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Client.cc

index 18235bfbce08a33bc8c437b9140248bffbba81eb..8c25ae468fda9ad2a23a557332f3e889308522e6 100644 (file)
@@ -3834,6 +3834,16 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id
     in->snaprealm = get_snap_realm(realm);
     in->snaprealm->inodes_with_caps.push_back(&in->snaprealm_item);
     ldout(cct, 15) << __func__ << " first one, opened snaprealm " << in->snaprealm << dendl;
+  } else {
+    assert(in->snaprealm);
+    if ((flags & CEPH_CAP_FLAG_AUTH) &&
+       realm != inodeno_t(-1) && in->snaprealm->ino != realm) {
+      in->snaprealm_item.remove_myself();
+      auto oldrealm = in->snaprealm;
+      in->snaprealm = get_snap_realm(realm);
+      in->snaprealm->inodes_with_caps.push_back(&in->snaprealm_item);
+      put_snap_realm(oldrealm);
+    }
   }
 
   mds_rank_t mds = mds_session->mds_num;