]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix crash in trim_caps
authorJohn Spray <john.spray@redhat.com>
Wed, 3 Sep 2014 01:00:33 +0000 (02:00 +0100)
committerJohn Spray <john.spray@redhat.com>
Mon, 15 Sep 2014 14:05:13 +0000 (15:05 +0100)
In a75af4c2, procedure was added to invalidate root's dentries
if the trimming failed to free enough caps.  This would sometimes
crash because root->dir wasn't necessarily open.

Fix by only doing it if root dir is open, though I suspect this
may not be the end of it...

Signed-off-by: John Spray <john.spray@redhat.com>
src/client/Client.cc

index 667b700b004e61cb5959c8eb949aede54138a878..d749dd05a3835977cc0ff50ca3f83f83a062089d 100644 (file)
@@ -3171,10 +3171,12 @@ void Client::trim_caps(MetaSession *s, int max)
       set<Dentry*>::iterator q = in->dn_set.begin();
       while (q != in->dn_set.end()) {
        Dentry *dn = *q++;
-       if (dn->lru_is_expireable())
+       if (dn->lru_is_expireable()) {
          trim_dentry(dn);
-       else
+        } else {
+          ldout(cct, 20) << "  not expirable: " << dn->name << dendl;
          all = false;
+        }
       }
       if (all)
        trimmed++;
@@ -3191,11 +3193,17 @@ void Client::trim_caps(MetaSession *s, int max)
   // notify kernel to invalidate top level directory entries. As a side effect,
   // unused inodes underneath these entries get pruned.
   if (dentry_invalidate_cb && s->caps.size() > max) {
-    for (ceph::unordered_map<string, Dentry*>::iterator p = root->dir->dentries.begin();
-        p != root->dir->dentries.end();
-        ++p) {
-      if (p->second->inode)
-       _schedule_invalidate_dentry_callback(p->second, false);
+    assert(root);
+    if (root->dir) {
+      for (ceph::unordered_map<string, Dentry*>::iterator p = root->dir->dentries.begin();
+           p != root->dir->dentries.end();
+           ++p) {
+        if (p->second->inode)
+          _schedule_invalidate_dentry_callback(p->second, false);
+      }
+    } else {
+      // This seems unnatural, as long as we are holding caps they must be on
+      // some descendent of the root, so why don't we have the root open?
     }
   }
 }