]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix rename race with trim on replacement onode at old name
authorSage Weil <sage@redhat.com>
Sat, 20 Oct 2018 20:16:50 +0000 (15:16 -0500)
committerJonathan Brielmaier <jbrielmaier@suse.de>
Thu, 8 Nov 2018 09:11:40 +0000 (10:11 +0100)
- rename from foo to bar
 - foo onode is moved to bar in onode_map
 - keys removed at position foo as part of txc
 - new onode for foo is installed at foo in map
...
- cache trims foo
...
- new txn B does get_onode on foo, reads old foo (now bar) onode into foo ***
- txn A commits
-> onode cache has foo with stale bar content

Fix by holding a ref to the replacement foo onode so that get_onode cannot
read stale metadata out of kvdb before txn A commits.

Fixes: http://tracker.ceph.com/issues/36541
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 6e14a50e20c18d5f851d34d6979148128c12a279)
Signed-off-by: Jonathan Brielmaier <jbrielmaier@suse.de>
src/os/bluestore/BlueStore.cc

index b326d39bcd2ecaa9e3bf15ca3667abb5a0b5812c..631c0cc61cb14fa9a22fddf8b541e881176f2d75 100644 (file)
@@ -11551,6 +11551,11 @@ int BlueStore::_rename(TransContext *txc,
   c->onode_map.rename(oldo, old_oid, new_oid, new_okey);
   r = 0;
 
+  // hold a ref to new Onode in old name position, to ensure we don't drop
+  // it from the cache before this txc commits (or else someone may come along
+  // and read newo's metadata via the old name).
+  txc->note_modified_object(oldo);
+
  out:
   dout(10) << __func__ << " " << c->cid << " " << old_oid << " -> "
           << new_oid << " = " << r << dendl;