]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add/remove inodes to/from open file list based on wanted caps changes
authorSage Weil <sage@newdream.net>
Fri, 17 Apr 2009 23:00:50 +0000 (16:00 -0700)
committerSage Weil <sage@newdream.net>
Fri, 17 Apr 2009 23:01:20 +0000 (16:01 -0700)
We only want to track "open" files for things the client will have open
file handles for.  The rest we will recover opportunistically...

src/mds/Locker.cc

index d109baa3dadf96705386d40473f2bb0d9e393116..aae949ac160f03e2f80649d1b0421daed82a7566 100644 (file)
@@ -1493,9 +1493,30 @@ void Locker::adjust_cap_wanted(Capability *cap, int wanted, int issue_seq)
             << " -> " << ccap_string(wanted)
             << " (issue_seq " << issue_seq << " != last_issue "
             << cap->get_last_issue() << ")" << dendl;
+    return;
+  }
+
+  CInode *cur = cap->get_inode();
+  if (cap->wanted() == 0) {
+    if (cur->xlist_open_file.is_on_xlist() &&
+       cur->get_caps_wanted() == 0) {
+      dout(10) << " removing from open file list " << *cur << dendl;
+      cur->xlist_open_file.remove_myself();
+    }
+  } else {
+    if (!cur->xlist_open_file.is_on_xlist()) {
+      dout(10) << " adding to open file list " << *cur << dendl;
+      LogSegment *ls = mds->mdlog->get_current_segment();
+      EOpen *le = new EOpen(mds->mdlog);
+      le->add_clean_inode(cur);
+      ls->open_files.push_back(&cur->xlist_open_file);
+      mds->mdlog->submit_entry(le);
+    }
   }
+
 }
 
+
 /*
  * note: we only get these from the client if
  * - we are calling back previously issued caps (fewer than the client previously had)