osd: fix deadlock in map handler

To avoid deadlock,
- we need to drop osd_lock while we flush.
- we need to take map_lock _after_ we flush.

Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
Sage Weil 2010-10-22 10:11:21 -07:00
parent 28d899285c
commit 78352b32cd

View File

@ -2338,8 +2338,6 @@ void OSD::handle_osd_map(MOSDMap *m)
store->flush();
osd_lock.Lock();
map_lock.get_write();
assert(osd_lock.is_locked());
ObjectStore::Transaction t;
@ -2404,7 +2402,12 @@ void OSD::handle_osd_map(MOSDMap *m)
}
// flush new maps (so they are readable)
osd_lock.Unlock();
store->flush();
osd_lock.Lock();
// finally, take map_lock _after_ we do this flush, to avoid deadlock
map_lock.get_write();
// advance if we can
bool advanced = false;