]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: only dump cache on umount if we time out
authorSage Weil <sage@inktank.com>
Fri, 30 Nov 2012 00:45:52 +0000 (16:45 -0800)
committerSage Weil <sage@inktank.com>
Fri, 30 Nov 2012 00:47:26 +0000 (16:47 -0800)
We don't want to dump the cache every time an item is trimmed and the
mount_cond gets signaled; this can make umount crazy-slow when logging is
turned up.

Instead, only dump if we wait 5 seconds without making any progress on
shrinking the cache.

Signed-off-by: Sage Weil <sage@inktank.com>
src/client/Client.cc

index 1c881828540cfa50493c5e2a96e152d1e0292e1e..84438e79acc8547591ade033a9ef831e0cac4aa8 100644 (file)
@@ -1692,14 +1692,14 @@ bool Client::ms_dispatch(Message *m)
   if (unmounting) {
     ldout(cct, 10) << "unmounting: trim pass, size was " << lru.lru_get_size() 
              << "+" << inode_map.size() << dendl;
+    long unsigned size = lru.lru_get_size() + inode_map.size();
     trim_cache();
-    if (lru.lru_get_size() == 0 && inode_map.empty()) {
-      ldout(cct, 10) << "unmounting: trim pass, cache now empty, waking unmount()" << dendl;
+    if (size < lru.lru_get_size() + inode_map.size()) {
+      ldout(cct, 10) << "unmounting: trim pass, cache shrank, poking unmount()" << dendl;
       mount_cond.Signal();
     } else {
       ldout(cct, 10) << "unmounting: trim pass, size still " << lru.lru_get_size() 
                << "+" << inode_map.size() << dendl;
-      dump_cache(NULL);      
     }
   }
 
@@ -3591,8 +3591,11 @@ void Client::unmount()
             << "+" << inode_map.size() << " items" 
            << ", waiting (for caps to release?)"
             << dendl;
-    dump_cache(NULL);
-    mount_cond.Wait(client_lock);
+    utime_t until = ceph_clock_now(cct) + utime_t(5, 0);
+    int r = mount_cond.WaitUntil(client_lock, until);
+    if (r == ETIMEDOUT) {
+      dump_cache(NULL);
+    }
   }
   assert(lru.lru_get_size() == 0);
   assert(inode_map.empty());