]> git-server-git.apps.pok.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)
committerSage Weil <sage@redhat.com>
Mon, 22 Oct 2018 13:29:26 +0000 (08:29 -0500)
- 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>
src/os/bluestore/BlueStore.cc

index 2be713c06d8261db7a3633aa99f55d98ca817b19..844d95d302f3257ddb21e95f4582a0c98c5b5f96 100644 (file)
@@ -12126,6 +12126,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;