]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix CInode::remove_need_snapflush
authorYan, Zheng <zyan@redhat.com>
Wed, 17 Dec 2014 06:06:05 +0000 (14:06 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 5 Feb 2015 14:40:37 +0000 (22:40 +0800)
make sure client and snapid exist, then drop CInode::PIN_NEEDSNAPFLUSH

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/CInode.cc

index e0e176034d2f4425b496364d88b454cb558928ee..50c829b8a8c4f7d6d19d7b4d02b7f4c15a71e82b 100644 (file)
@@ -278,10 +278,18 @@ void CInode::add_need_snapflush(CInode *snapin, snapid_t snapid, client_t client
 void CInode::remove_need_snapflush(CInode *snapin, snapid_t snapid, client_t client)
 {
   dout(10) << "remove_need_snapflush client." << client << " snapid " << snapid << " on " << snapin << dendl;
-  set<client_t>& clients = client_need_snapflush[snapid];
-  clients.erase(client);
-  if (clients.empty()) {
-    client_need_snapflush.erase(snapid);
+  map<snapid_t, std::set<client_t> >::iterator p = client_need_snapflush.find(snapid);
+  if (p == client_need_snapflush.end()) {
+    dout(10) << " snapid not found" << dendl;
+    return;
+  }
+  if (!p->second.count(client)) {
+    dout(10) << " client not found" << dendl;
+    return;
+  }
+  p->second.erase(client);
+  if (p->second.empty()) {
+    client_need_snapflush.erase(p);
     snapin->auth_unpin(this);
 
     if (client_need_snapflush.empty()) {