From: Sage Weil Date: Sat, 20 Oct 2018 20:16:50 +0000 (-0500) Subject: os/bluestore: fix rename race with trim on replacement onode at old name X-Git-Tag: v12.2.11~142^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b49742054cc8dde5d929e3ea12bccf3d388bd2a4;p=ceph.git os/bluestore: fix rename race with trim on replacement onode at old name - 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 (cherry picked from commit 6e14a50e20c18d5f851d34d6979148128c12a279) Signed-off-by: Jonathan Brielmaier --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b326d39bcd2e..631c0cc61cb1 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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;