]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix iterator invalidation for backtrace removal
authorSage Weil <sage@inktank.com>
Fri, 21 Jun 2013 18:53:29 +0000 (11:53 -0700)
committerSage Weil <sage@inktank.com>
Fri, 21 Jun 2013 18:53:29 +0000 (11:53 -0700)
- Don't increment before we dereference!
- We need to update the iterator before we delete the item.

This code is changed in master, so this fix is for cuttlefish only.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/mds/journal.cc

index b8139e3a05b9e2fed33f12906cce9f122b10e6a5..0453fc8f1638fcfee51d1912d6dc96a76f254552 100644 (file)
@@ -305,10 +305,13 @@ void LogSegment::queue_backtrace_update(CInode *inode, int64_t location, int64_t
 
 void LogSegment::remove_pending_backtraces(inodeno_t ino, int64_t pool) {
   elist<BacktraceInfo*>::iterator i = update_backtraces.begin();
-  while(!i.end()) {
-    ++i;
-    if((*i)->bt.ino == ino && (*i)->location == pool) {
-      delete (*i);
+  while (!i.end()) {
+    BacktraceInfo *bi = *i;
+    if (bi->bt.ino == ino && bi->location == pool) {
+      ++i;
+      delete bi;
+    } else {
+      ++i;
     }
   }
 }